A full-stack Email Assistant using Flask, Django, and Groq LLaMA 3.1.
The system can:
- Categorize emails
- Extract actionable tasks
- Generate draft replies with AI
- Allow user instructions for personalized responses
- Save AI-generated drafts
- Manage customizable prompt templates
- Browse inbox and run agent actions interactively
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
Provides a clean UI for:
- Viewing inbox emails
- Running the AI processing agent
- Editing prompt templates
- Saving and reviewing generated drafts
Handles:
- Prompt storage (SQLite)
- Local inbox (mock data)
- AI model calls via Groq
- Draft storage
- Email processing pipeline (categorize + action extraction)
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
Flask
Flask-CORS
python-dotenv
requests
groq
Django>=5.0
requests
git clone https://github.com/USERNAME/email-agent.git
cd email-agentcd backend-flask
python -m venv venv
venv\Scripts\activate # Windows
# OR
source venv/bin/activate # macOS/Linuxpip install -r requirements.txtGROQ_API_KEY=your_groq_key_here
GROQ_MODEL=llama-3.1-70b-versatile
FLASK_PORT=5000python seed_prompts.pypython app.pycd ../frontend-django
python -m venv venv
venv\Scripts\activate
# OR
source venv/bin/activatepip install -r requirements.txtpython manage.py migratepython manage.py runserverVisit:
http://127.0.0.1:8000/
Click on any email to view details and run analysis:
- Run Agent (categorize + extract)
- Open Agent Chat β chat with AI
In Agent Chat:
- Choose prompt template
- Add instruction (optional)
- Run Agent
- Save Draft
Navigate to the Drafts page to see all AI-generated emails.
The backend uses:
llama-3.1-70b-versatilellama-3.1-8b-instant(faster)
In llm.py, call_llm() safely handles:
- Model calls
- API errors
- Network failures
- Returning clean text to frontend
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
- Never commit
.envor API keys - Add these to your
.gitignore:
*.env
venv/
__pycache__/
*.sqlite
MIT License