Three AI-powered agents for email outreach, inbox reply, and smart compose — built with LangGraph, Groq LLM, and Streamlit.
This project is a fully functional AI email automation system that uses LangGraph state machines to orchestrate three independent agents. Each agent follows a human-in-the-loop pattern — no email is ever sent without explicit human approval.
| Agent | What it does |
|---|---|
| System 1 — HR Outreach | Reads an Excel spreadsheet of companies, researches each one online, and generates personalised internship outreach emails |
| System 2 — Inbox Reply | Fetches unread emails via IMAP, classifies their intent with LLM, and generates professional replies |
| System 3 — Smart Compose | Takes a brief topic and tone, generates a complete email with subject line, and sends after approval |
- 🤖 LangGraph Agents — Each system is a proper LangGraph
StateGraphwith nodes, edges, conditional routing, and interrupt-based human review - 🧠 Groq LLM (Free) — Uses
llama-3.3-70b-versatilevia Groq's free API for all text generation - 📬 Gmail IMAP/SMTP — Reads inbox via IMAP and sends via SMTP using App Passwords
- 🔍 Tavily Web Search — Researches companies online before generating outreach emails
- 📄 Resume Parsing — Extracts text from PDF resumes and generates structured summaries
- 🎨 Streamlit UI — Clean, dark-themed 3-tab interface with live previews
- ✅ Human-in-the-Loop — Every email must be approved, edited, or regenerated before sending
- 📊 CSV Logging — All sent emails are logged to
sent_emails_log.csv - 🧵 Thread Preservation — Reply agent uses
In-Reply-To/Referencesheaders to keep email threads intact
Email Automation AI/
│
├── app.py # Streamlit UI (3 tabs)
│
├── agents/ # LangGraph agent definitions
│ ├── __init__.py
│ ├── outreach_agent.py # System 1 — HR Outreach
│ ├── reply_agent.py # System 2 — Inbox Reply
│ └── compose_agent.py # System 3 — Smart Compose
│
├── tools/ # Utility modules
│ ├── __init__.py
│ ├── email_sender.py # SMTP send / reply / compose
│ ├── email_fetcher.py # IMAP inbox reader
│ ├── resume_parser.py # PDF text extraction + LLM summary
│ └── research_tool.py # Tavily search + LLM summary
│
├── data/ # Sample data files
│ ├── HR_Contacts_Cleaned.xlsx
│ └── RushikeshBhabad_Resume.pdf
│
├── .env # API keys & credentials (git-ignored)
├── .env.example # Template for .env
├── .gitignore
├── requirements.txt
├── README.md # This file
└── AGENTS_DOCUMENTATION.md # Deep-dive agent documentation
load_data ──→ research_company ──→ generate_email ──→ human_review
│
┌───────────────┼───────────────┐
▼ ▼ ▼
send_email generate_email END
(approve) (regenerate) (skip)
│
▼
END
fetch_emails ──→ classify_email ──→ generate_reply ──→ human_review
│
┌───────────────┼───────────────┐
▼ ▼ ▼
send_reply generate_reply END
(send) (regenerate) (discard)
│
▼
END
generate_email ──→ human_review
│
┌───────────────┼───────────────┐
▼ ▼ ▼
send_email generate_email END
(send) (regenerate) (discard)
│
▼
END
| Component | Technology | Cost |
|---|---|---|
| LLM | Groq (llama-3.3-70b-versatile) |
Free |
| Agent Framework | LangGraph (StateGraph) |
Free |
| Web Search | Tavily API | Free tier |
| Email Send | Python smtplib (SMTP) |
Free |
| Email Read | Python imaplib (IMAP) |
Free |
| PDF Parsing | PyPDF | Free |
| UI | Streamlit | Free |
git clone https://github.com/yourusername/email-automation-ai.git
cd email-automation-aipython -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windowspip install -r requirements.txtcp .env.example .envEdit .env with your actual credentials:
GROQ_API_KEY=gsk_your_key_here
TAVILY_API_KEY=tvly-your_key_here
EMAIL_ADDRESS=your_email@gmail.com
EMAIL_PASSWORD=your_gmail_app_password
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
IMAP_SERVER=imap.gmail.com- Go to Google Account Security
- Enable 2-Step Verification
- Go to App Passwords → Generate a new one
- Use this 16-character password as
EMAIL_PASSWORD
streamlit run app.pyThe app opens at http://localhost:8501 with three tabs.
- Upload your Resume PDF and HR Contacts Excel (columns:
Company Name,Email ID,Industry,Location) - Click Load Data — resume is parsed, companies are loaded
- Select a company from the dropdown
- Click Research & Generate Email — AI researches the company online and drafts a personalised email
- Review the email — edit subject/body if needed
- Click Approve & Send, Regenerate, or Skip
- Ensure email credentials are in the sidebar
- Click Fetch Unread Emails — connects via IMAP
- Click Generate Reply on any email — AI classifies intent and drafts a reply
- Review the reply — edit if needed
- Click Send Reply, Regenerate, or Discard
- Enter recipient email, topic, and select tone
- Click Generate Email — AI creates subject + body
- Review the email — edit if needed
- Click Send Email, Regenerate, or Discard
| Variable | Description | Required |
|---|---|---|
GROQ_API_KEY |
Groq API key for LLM | Yes |
TAVILY_API_KEY |
Tavily API key for web search | Yes (Outreach only) |
EMAIL_ADDRESS |
Gmail address | Yes |
EMAIL_PASSWORD |
Gmail App Password | Yes |
SMTP_SERVER |
SMTP server | Yes (default: smtp.gmail.com) |
SMTP_PORT |
SMTP port | Yes (default: 587) |
IMAP_SERVER |
IMAP server | Yes (default: imap.gmail.com) |
The HR Contacts Excel file should have these columns:
| Company Name | Email ID | Industry | Location |
|---|---|---|---|
| hr@google.com | Technology | Mountain View, CA | |
| Microsoft | careers@microsoft.com | Technology | Redmond, WA |
For a deep dive into how each agent works internally — every node, edge, state field, LLM prompt, and execution flow — see:
This documentation is designed to be comprehensive enough to explain the entire system architecture in an interview setting.
This project is open source under the MIT License.