MailBot: AI-Powered Email Reply Assistant
MailBot is a combined Chrome extension and Spring Boot backend that automatically generates professional email replies in Gmail using Google Gemini AI. The extension injects an "AI Reply" button into Gmail's compose toolbar. When clicked, it sends the selected email content and tone preference to the backend, which calls the Gemini API, processes the response, and returns a suggested reply.
[Gmail (Chrome)] <– HTTPS –> [Nginx (HTTPS, port 443)] → [Spring Boot App (HTTP, port 8080)] → [Gemini AI API]
-
Chrome Extension
- Manifest V3 (
manifest.json) configures content scripts and host permissions - content.js watches for Gmail compose windows, injects an AI Reply button, captures email body, and issues a POST request to the backend
- Manifest V3 (
-
Backend (Spring Boot)
- EmailGeneratorApplication: application entry point
- EmailRequest: DTO representing incoming JSON (emailContent & tone)
- EmailGeneratorService: calls Gemini API using Spring WebClient, parses JSON response via Jackson
- EmailGeneratorController: REST endpoint
/api/email/generatehandling POST requests, with CORS enabled
-
Deployment
- AWS EC2 instance running Amazon Linux 2
- Nginx as HTTPS reverse proxy with self-signed or Let’s Encrypt certificate
- Java 21 (Corretto) installed manually under
/opt/corretto
- Frontend: Chrome Extension (Manifest V3), JavaScript, DOM API, MutationObserver,
fetch - Backend: Java 21, Spring Boot (WebFlux for WebClient), Lombok, Jackson, Maven wrapper (
mvnw) - AI API: Google Gemini Generative Language API
- Deployment: AWS EC2 (Amazon Linux 2), Nginx, self-signed/Let’s Encrypt SSL
- Java 21 installed on your local machine (for backend build)
- Maven (via
mvnw) or Gradle wrapper available - Google Cloud API Key with access to Gemini API
- AWS account for EC2 and optional domain
- Chrome browser (for extension) with Developer Mode enabled
# Clone the repository
git clone https://github.com/yourusername/mailbot.git
cd mailbot/backend
# Build the executable JAR
./mvnw clean package
# or: ./gradlew bootJarCreate an application.properties under src/main/resources or in an external config/ directory:
spring.application.name=email-generator
gemini.api.url=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=
gemini.api.key=${GEMINI_API_KEY}Then export your key in the shell:
export GEMINI_API_KEY=YOUR_GOOGLE_API_KEYjava -jar target/email-gen-0.0.1-SNAPSHOT.jarThe service listens on port 8080 by default.
-
Open Chrome and navigate to
chrome://extensions -
Enable Developer mode (top-right)
-
Click Load unpacked and select the extension folder containing:
manifest.jsoncontent.jscontent.css(if present)icons/directory
-
Ensure host_permissions include your backend URL:
"host_permissions": [ "https://your-domain-or-ip/*", "*://mail.google.com/*" ]
- Navigate to Gmail in Chrome and compose a new email.
- Click the AI Reply button in the toolbar.
- The extension captures the email content, calls the backend, and inserts the generated reply.
- Provision EC2: Ubuntu or Amazon Linux 2 instance, open ports 22, 80, 443
- Install Java 21: download Corretto, extract to
/opt/corretto, configurealternatives - Install Nginx and generate a certificate (self-signed or Let’s Encrypt)
- Configure Nginx to proxy
HTTPS 443→localhost:8080 - Run the Spring Boot JAR as a background service (via
screen,systemd, ortmux)
mailbot/
├── backend/
│ ├── src/main/java/com/email_gen/
│ │ ├── EmailGeneratorApplication.java
│ │ ├── EmailGeneratorController.java
│ │ ├── EmailGeneratorService.java
│ │ └── EmailRequest.java
│ ├── src/main/resources/application.properties
│ └── pom.xml
├── extension/
│ ├── manifest.json
│ ├── content.js
│ ├── content.css
│ ├── icons/
│ └── ...
└── README.md
credits to : EmbarkX | Learn Programming