← All work

Case study · AI systems · 01

Email Automation Agent

Reads the inbox, drafts the reply, and waits for a human to say go.

A production-shaped Gmail agent: it classifies incoming mail, drafts a reply with an LLM, and holds everything in a review queue — nothing sends until a person approves it. Built with cost tracking, retry logic, and a Streamlit review dashboard, not left as a notebook demo.

Built & tested

Stack: LangGraph · Groq · Gmail API · SQLAlchemy · Streamlit

Email Automation Agent screenshot

The pipeline, not a promise

How it works

Email agent pipeline

Step by step

Five stages, one gate

01 / 05

Ingest

New mail lands in the Gmail inbox through the Gmail API. The agent picks it up on its next run and starts a trace for that thread.

02 / 05

Classify

An LLM call over Groq reads the thread and tags intent and category, so routine mail and edge cases get handled differently downstream.

03 / 05

Draft

A second LLM call writes a reply grounded in the thread. Every call here is wrapped in retry logic with exponential backoff.

04 / 05

Approve

The draft lands in a Streamlit review queue. A person approves, edits, or rejects it — rejected drafts go back for a rewrite.

05 / 05

Send & log

Approved replies go out through the Gmail API. Every stage — classify, draft, approve, send — is logged with its cost and latency.

Why the gate matters

Production discipline matters more here than a clever demo. An agent that drafts a wrong reply and sends it anyway is worse than one that never shipped — so nothing leaves this agent without a person seeing it first.

Every LLM call carries a typed output schema, retry logic, and cost tracking. A failed or low-confidence call holds the message for review instead of silently dropping it or guessing at an answer.

The review queue isn't a bolt-on afterthought — it's the one step every message has to pass through, logged and timestamped like everything else in the run.

Built with

Tech used on this project

PythonLangGraphGroq APIGmail API PydanticSQLAlchemyStreamlitOAuth2

Want something like this in your inbox?

Open to freelance and contract work on agentic AI systems — email automation, WhatsApp and commerce agents, or something custom. If you can describe the problem, I can tell you honestly whether it's a good fit.

Project
Email Automation Agent
Status
Built & tested
Role
Design & engineering
Contact
affanned399@gmail.com