Build Your Own AI Gmail Assistant: A Complete Guide to Creating Chithi
Ever wish you had an AI assistant right inside Gmail to help you write better emails? In this tutorial, I'll show you how to build Chithi (চিঠি - Bengali for "letter"), a Chrome extension that brings AI-powered email assistance directly into your Gmail compose window.
Unlike cloud-based solutions, Chithi runs entirely on your local machine using Llama 3, ensuring your email data stays private. Let's build this together!
What We're Building
Chithi is a Chrome extension that adds AI superpowers to Gmail:
Enhance Emails: Transform your rough drafts into polished, professional messages
Generate Emails: Create complete emails from just a few bullet points
Analyze Writing: Get instant feedback on tone, clarity, and effectiveness
Customizable Tone: Choose from 9 different writing styles (professional, friendly, formal, etc.)
Smart Purpose Detection: AI automatically understands if you're writing an apology, request, follow-up, etc.
The best part? It appears as a sleek toolbar right inside Gmail's compose window!
Architecture Overview
Before we dive in, here's how Chithi works:
Chrome Extension: Injects a custom toolbar into Gmail's compose window
Spring Boot Backend: Processes AI requests using LangChain4j
Ollama + Llama 3: Runs the AI model locally on your machine
Privacy-First: No data leaves your computer
Prerequisites
Here's what you'll need:
Java 21 or higher (Download here)
Maven 3.6+ (Usually comes with Java)
Google Chrome browser
Ollama (We'll install this together)
Basic familiarity with terminal/command line
Step 1: Install Ollama and Llama 3
First, let's set up the AI brain of our application:
On macOS/Linux:
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Pull the Llama 3.1 model (8B parameters)
ollama pull llama3.1:8b
# Start Ollama server
ollama serve
On Windows:
Download the installer from ollama.com and follow the installation wizard. Then open PowerShell and run:
ollama pull llama3.1:8b
ollama serve
You should see Ollama running at
http://localhost:11434
. Keep this terminal window open!
Step 2: Set Up the Spring Boot Backend
Now let's get the backend running:
The repository is available at: https://github.com/rokon12/chithi.git
# Clone the repository
git clone https://github.com/rokon12/chithi.git
cd Chithi
# Build the project
./mvnw clean install
# Run the Spring Boot application
./mvnw spring-boot:run
If you're on Windows, use mvnw.cmd instead of ./mvnw.
You should see Spring Boot start up with a message like:
Started ChithiApplication in 3.456 seconds (JVM running for 4.123)
The backend is now running at
http://localhost:8080
Let's test it:
curl http://localhost:8080/api/email/health
You should see: {"status":"ok","message":"Email AI Assistant is running"}
Step 3: Install the Chrome Extension
This is where the magic happens! Let's add Chithi to Chrome:
Open Chrome and go to
chrome://extensions/Toggle "Developer mode" ON (top right corner)
Click "Load unpacked"
Navigate to the
Chithi/chrome-extensionfolder and select itYou should see the Chithi icon appear in your Chrome toolbar!
Step 4: Test Drive Your AI Assistant
Time for the fun part! Let's see Chithi in action:
Open Gmail in Chrome
Click "Compose" to start a new email
Look for the new Chithi toolbar that appears above the email body
Try these examples:
Example 1: Enhance a Rough Draft
Type this in the email body:
hey john, sorry bout missing the meeting yesterday. had car trouble. can we reschedule? maybe thursday?
Select Tone: Professional and Purpose: Apology, then click Enhance. Watch as Chithi transforms it into:
Dear John,
I sincerely apologize for missing our meeting yesterday. I experienced unexpected car trouble that prevented me from attending.
Would it be possible to reschedule our discussion? I'm available on Thursday if that works with your schedule. Please let me know a time that would be convenient for you.
Thank you for your understanding.
Best regards,
Example 2: Generate from Ideas
Click in an empty compose window and use the extension popup (click the Chithi icon in toolbar). Select Generate Emails and enter:
Need to follow up with Sarah about Q4 budget proposal. Remind about Friday deadline. Offer help if needed.
Select Tone: Business Casual and Purpose: Follow-up. Chithi creates:
Hi Sarah,
I hope you're having a good week. I wanted to touch base regarding the Q4 budget proposal we discussed last week.
Just a friendly reminder that the deadline is this Friday. I know these proposals can be time-consuming, so if you need any assistance with data analysis or formatting, I'd be happy to help.
Let me know if you'd like to go over anything together or if you have any questions.
Best,
Example 3: Analyze Your Writing
Write any email draft and click Analyze. Chithi will provide feedback like:
Analysis of your email:
**Strengths:**
- Clear and direct communication
- Appropriate professional tone
- Well-structured with logical flow
**Areas for Improvement:**
- Consider adding a specific call-to-action
- The closing could be warmer to maintain relationship
- Second paragraph could be more concise
**Suggestions:**
- Add specific next steps or deadlines
- Consider using "Best regards" instead of just "Thanks"
- Break the long paragraph into two shorter ones for better readabilityCustomization and Configuration
Adjust AI Behavior
Edit src/main/resources/application.properties:
# Make responses more creative (0.0 = focused, 1.0 = creative)
langchain4j.ollama.temperature=0.7
# Increase timeout for longer emails
langchain4j.ollama.timeout=120s
# Use a different model
langchain4j.ollama.model-name=llama3.1:70b
Modify the Extension UI
The extension uses a modern purple/blue gradient theme. To customize, edit chrome-extension/styles/chithi.css:
/* Change the primary gradient */
.chithi-enhance-btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
/* Modify the panel size */
.chithi-panel {
max-width: 600px; /* Make it wider */
}
Extending Chithi
Want to add more features? Here are some ideas:
1. Add Email Templates
Create pre-defined templates for common scenarios:
@UserMessage("""
Generate a {{template}} email with a {{tone}} tone.
Templates: welcome_new_employee, project_update, meeting_request
""")
String generateFromTemplate(@V("template") String template, @V("tone") String tone);
2. Multi-language Support
Add support for other languages:
@UserMessage("""
Translate this email to {{language}} while maintaining a {{tone}} tone:
{{content}}
""")
String translateEmail(@V("content") String content, @V("language") String language, @V("tone") String tone);
3. Smart Signatures
Automatically append appropriate signatures based on context:
if (purpose.equals("formal")) {
email += "\n\nSincerely,\n[Your name]\n[Title]";
} else if (purpose.equals("casual")) {
email += "\n\nCheers,\n[Your name]";
}
What's Next?
Congratulations! You've built your own AI-powered Gmail assistant. Here are some next steps:
Experiment with Different Models: Try
mixtral,neural-chat, oryiwith OllamaBuild a Settings Page: Let users configure their preferences
Share with Your Team: Package it for easy distribution
Conclusion
You've just built a powerful, privacy-focused AI email assistant that runs entirely on your local machine. No more worrying about cloud services reading your emails or paying for API calls. Chithi demonstrates how we can leverage open-source AI models to create practical tools that respect user privacy.
The combination of Spring Boot, LangChain4j, and Ollama makes it surprisingly easy to add AI capabilities to any application. And with Chrome extensions, we can enhance the tools we use every day.
Happy emailing! 🚀
Found this helpful? Follow for more tutorials on building practical AI applications.
Have questions? Drop them in the comments below!




