Correspa AI is an autonomous, multi-agent email support system that monitors a business inbox, understands each incoming message, and produces accurate, on-brand draft replies, without a human having to read every ticket first.
It is built around a LangGraph-orchestrated pipeline in which specialized AI agents collaborate to categorize incoming mail, research answers from internal knowledge using Retrieval-Augmented Generation (RAG), draft a response, and proofread it before it ever reaches a customer.
Support teams are expected to respond quickly, accurately, and consistently, even as ticket volume grows. Manually triaging, researching, and drafting every email is slow and error-prone, and inconsistent answers erode customer trust.
Correspa AI addresses this by giving each stage of the response process to a dedicated AI agent, so incoming mail is classified correctly, answered with information grounded in real company documentation, and checked for quality before being queued as a Gmail draft, reducing response time while keeping a human in the loop for final approval.
Inbox monitoring & triage
- Continuously polls a connected Gmail inbox for new, unanswered messages
- Classifies each email as a product inquiry, customer complaint, customer feedback, or unrelated
- Filters out irrelevant messages automatically so agents only spend effort where it counts
Grounded response generation
- For product or service questions, generates targeted retrieval queries and pulls relevant context from a vector store built on the company's own documents (RAG)
- For complaints and feedback, drafts an empathetic, context-aware reply directly
- Produces natural, personalized email copy rather than generic templates
Automated quality review
- A dedicated proofreading agent checks tone, accuracy, and formatting against the original customer message
- Emails that don't meet the bar are sent back for a rewrite, up to a bounded number of attempts, before being queued
- Approved responses are saved as Gmail drafts, keeping a human in the loop before anything is sent
- Load inbox: the workflow fetches unanswered emails from Gmail via the Gmail API.
- Categorize: an LLM agent classifies the email as a product inquiry, complaint/feedback, or unrelated.
- Route:
- Product inquiry → the system builds RAG queries, retrieves supporting context from the vector store, and passes it to the writer agent.
- Complaint / feedback → the writer agent drafts a reply directly.
- Unrelated → the email is skipped.
- Draft: the writer agent composes a response using the email content (and any retrieved context).
- Proofread: a reviewer agent checks the draft; if it doesn't pass, it's sent back to the writer for revision (bounded by a retry limit).
- Queue for send: once approved, the reply is saved as a Gmail draft, and the workflow moves on to the next email in the inbox.
This loop repeats until the inbox has no more unanswered emails to process.
| Layer | Technology |
|---|---|
| Agent orchestration | LangChain & LangGraph |
| LLM inference | Groq (Llama 3.3 70B) & Google Gemini |
| Retrieval / vector store | Chroma, Google Generative AI Embeddings |
| Email integration | Gmail API (google-api-python-client) |
| API deployment | FastAPI & LangServe |
| Language | Python |
correspa-ai/
├── main.py # Entry point — runs the workflow as a continuous local process
├── deploy_api.py # Exposes the workflow as a FastAPI/LangServe endpoint
├── create_index.py # Builds/refreshes the Chroma vector store from source documents
├── requirements.txt # Python dependencies
├── workflow.png # Visual diagram of the LangGraph workflow
├── data/
│ └── agency.txt # Source knowledge documents used to ground RAG responses
├── db/ # Persisted Chroma vector store (generated by create_index.py)
├── src/
│ ├── agents.py # Defines each LLM-backed agent (categorizer, RAG chain, writer, proofreader)
│ ├── graph.py # Assembles the agents into the LangGraph state machine
│ ├── nodes.py # Node functions executed at each step of the graph
│ ├── prompts.py # Prompt templates driving each agent's behavior
│ ├── state.py # Shared graph state and Email data model (Pydantic)
│ ├── structure_outputs.py # Structured output schemas for LLM responses
│ └── tools/
│ └── GmailTools.py # Gmail API wrapper - fetch, read, and draft emails
- Python 3.7+
- A Groq API key
- A Google Gemini API key (used for embeddings)
- Gmail API credentials for the inbox you want to automate
- Clone the repository
git clone https://github.com/<your-username>/correspa-ai.git
cd correspa-ai- Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt-
Configure environment variables
Create a
.envfile in the project root:
MY_EMAIL=your_email@gmail.com
GROQ_API_KEY=your_groq_api_key
GOOGLE_API_KEY=your_gemini_api_key-
Enable the Gmail API
Follow Google's Python quickstart guide to enable the Gmail API and obtain your OAuth credentials.
Run the workflow locally
python main.pyThe application will continuously check the inbox, categorize new emails, generate responses, and verify them before queuing drafts.
Deploy as an API
python deploy_api.pyThis starts a FastAPI/LangServe server on localhost:8000. API docs are available at /docs, and an interactive LangServe playground is available at /playground.
- Adjust agent behavior by editing the corresponding methods in
src/nodes.pyor the prompt templates insrc/prompts.py. - Add your own company/product knowledge to the
data/folder, then rebuild the vector index:
python create_index.pyThis project is derived from the work of Aimen Kerrour (@kaymen99). The original implementation can be found at langgraph-email-automation.
Contributions are welcome. Please open an issue to discuss proposed changes or submit a pull request directly.
This project is licensed under the MIT License.
MOSTAFA ABDELHAMED | Junior AI & DS Researcher | NVIDIA Gen AI Certified LinkedIn

