Note: Last stable code version is available at branch 0.9: Click Here
This AI-powered solution, built with a Go-driven workflow, uses multiple AI agents to efficiently manage, categorize, and respond to customer emails. It also leverages Retrieval-Augmented Generation (RAG) technology to provide accurate answers to any business or product questions, ensuring your customers always get the precise information they need.

- Continuously monitors the agency's Gmail inbox
- Categorizes emails into 'customer complaint,' 'product inquiry,' 'customer feedback,' or 'unrelated'
- Automatically handles irrelevant emails to maintain efficiency
- Quickly drafts emails for customer complaints and feedback using a customizable workflow
- Utilizes RAG techniques to answer product/service-related questions accurately
- Creates personalized email content tailored to each customer's needs
- Automatically checks email quality, formatting, and relevance
- Ensures every response meets high standards before reaching the client
- Email Monitoring: The system constantly checks for new emails in the agency's Gmail inbox using the Gmail API.
- Email Categorization: AI agents sort each email into predefined categories.
- Response Generation:
- For complaints or feedback: The system quickly drafts a tailored email response.
- For service/product questions: The system uses RAG to retrieve accurate information from agency documents and generates a response.
- Quality Assurance: Each draft email undergoes AI quality and formatting checks.
- Sending: Approved emails are sent to the client promptly, ensuring timely communication.
This is the detailed flow of the system:
- Custom Graph Implementation (Go): For developing the AI agents workflow, replacing Langchain & Langgraph.
- Google Gemini API: For large language model (LLM) access and embeddings.
- Google Gmail API: For email inbox management.
- Go (version 1.22+)
- Google Gemini API Key
- Gmail API credentials
-
Clone the repository (or set up your Go module):
git clone https://github.com/zaynkorai/mailflow.git cd mailflow
-
Set up environment variables:
Create a
.env
file in the root directory of your project and add your Gmail address and Google Gemini API key:PORT=8080 MY_EMAIL=[email protected] GOOGLE_API_KEY=your_gemini_api_key
-
Ensure Gmail API is enabled:
Follow this guide to enable the Gmail API for your Google Cloud project and obtain your
credentials.json
file. Placecredentials.json
in your project's root directory.
-
Indexing RAG (console application):
Fill out agency/company data in
data/agency.txt
and run given commandgo run data/indexing.go
-
Start the workflow (console application):
go run main.go
The application will start checking for new emails, categorizing them, synthesizing queries, drafting responses, and verifying email quality, logging progress to your console.
Contributions are welcome! Please open an issue or submit a pull request for any changes.
If you have any questions or suggestions, feel free to contact me at [email protected]
.