Skip to content

mohakbiswas-coding/email-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ‰οΈ AI Email Agent

A full-stack Email Assistant using Flask, Django, and Groq LLaMA 3.1.
The system can:

  • Categorize emails
image
  • Extract actionable tasks
  • Generate draft replies with AI
image
  • Allow user instructions for personalized responses
  • Save AI-generated drafts
image
  • Manage customizable prompt templates
image
  • Browse inbox and run agent actions interactively

πŸš€ Features

βœ” AI-Powered Email Processing

Uses Groq LLaMA 3.1 (70B or 8B) to:

  • Categorize incoming emails
  • Extract JSON-formatted tasks
  • Draft intelligent email replies
  • Combine user instructions with prompt templates

βœ” Django Frontend

Provides a clean UI for:

  • Viewing inbox emails
  • Running the AI processing agent
  • Editing prompt templates
  • Saving and reviewing generated drafts

βœ” Flask Backend API

Handles:

  • Prompt storage (SQLite)
  • Local inbox (mock data)
  • AI model calls via Groq
  • Draft storage
  • Email processing pipeline (categorize + action extraction)

🧩 Project Structure

email-agent/
β”‚
β”œβ”€β”€ backend-flask/
β”‚   β”œβ”€β”€ app.py              # Flask API server
β”‚   β”œβ”€β”€ llm.py              # Groq LLaMA 3.1 integration
β”‚   β”œβ”€β”€ db.py               # SQLite database helpers
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   └── mock_inbox.json # Fake inbox used for development
β”‚   β”œβ”€β”€ seed_prompts.py     # Seed default prompt templates
β”‚   └── .env                # Groq API key + config (not committed)
β”‚
└── frontend-django/
    β”œβ”€β”€ manage.py
    β”œβ”€β”€ frontend_django/
    └── emails/
        β”œβ”€β”€ views.py        # Inbox, prompts, drafts, agent
        β”œβ”€β”€ urls.py
        └── templates/
            └── emails/
                β”œβ”€β”€ base.html
                β”œβ”€β”€ inbox.html
                β”œβ”€β”€ prompts.html
                β”œβ”€β”€ drafts.html
                └── agent.html

βš™οΈ Requirements

Backend (Flask)

Flask
Flask-CORS
python-dotenv
requests
groq

Frontend (Django)

Django>=5.0
requests

πŸ”§ Setup Instructions

1️⃣ Clone the repository

git clone https://github.com/USERNAME/email-agent.git
cd email-agent

2️⃣ Setup Backend

Create & activate virtual environment

cd backend-flask
python -m venv venv
venv\Scripts\activate     # Windows
# OR
source venv/bin/activate # macOS/Linux

Install dependencies

pip install -r requirements.txt

Create .env

GROQ_API_KEY=your_groq_key_here
GROQ_MODEL=llama-3.1-70b-versatile
FLASK_PORT=5000

Initialize database

python seed_prompts.py

Run Flask backend

python app.py

3️⃣ Setup Django Frontend

Create & activate virtual environment

cd ../frontend-django
python -m venv venv
venv\Scripts\activate
# OR
source venv/bin/activate

Install dependencies

pip install -r requirements.txt

Apply migrations

python manage.py migrate

Run Django server

python manage.py runserver

πŸ§ͺ Usage Workflow

1. Open the frontend

Visit:

http://127.0.0.1:8000/

2. Browse Inbox

Click on any email to view details and run analysis:

  • Run Agent (categorize + extract)
  • Open Agent Chat β†’ chat with AI

3. Generate Replies

In Agent Chat:

  • Choose prompt template
  • Add instruction (optional)
  • Run Agent
  • Save Draft

4. Review Drafts

Navigate to the Drafts page to see all AI-generated emails.


πŸ€– AI Model Integration

The backend uses:

βœ” Groq LLaMA 3.1 (Recommended)

  • llama-3.1-70b-versatile
  • llama-3.1-8b-instant (faster)

In llm.py, call_llm() safely handles:

  • Model calls
  • API errors
  • Network failures
  • Returning clean text to frontend

πŸ“Œ Roadmap

These may be added later:

  • Gmail / Outlook OAuth integration
  • Real email fetching
  • Automated email replies
  • Semantic search over inbox
  • Multi-agent workflows
  • Streaming responses
  • Dark mode UI theme

πŸ›‘ Security Notes

  • Never commit .env or API keys
  • Add these to your .gitignore:
*.env
venv/
__pycache__/
*.sqlite

🧩 License

MIT License

About

It is an AI agent that summarizes your email and drafts a reply.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages