Taming Inbox Chaos with Event-Driven AI Agents
Knowledge workers spend over 2 hours daily dealing with email overload. Traditional email filters rely on rigid keyword regexes that lack semantic context, resulting in missed critical inquiries, repetitive manual drafting, and high operational fatigue.
MailMind is an event-driven email processing and Human-in-the-Loop (HITL) orchestration system built on LangGraph, FastAPI, Resend Inbound Webhooks, FAISS, and Next.js 16. It automatically ingests incoming emails, classifies intent, matches natural-language business rules, generates RAG-grounded responses, and pauses for human approval on high-stakes decisions.
End-to-End System Architecture
Click to ZoomMailMind Architecture Diagram
Event-Driven & Webhook-First: Unlike legacy email tools that poll IMAP servers every few minutes, MailMind reacts instantly to incoming
email.receivedevents dispatched via Resend Inbound webhooks.
Technical Deep-Dive into Core Systems
1. Resend Inbound Webhooks & Svix Security
Every incoming email triggers an HTTP POST request to /api/webhook. MailMind verifies the Svix cryptographic signature to prevent webhook spoofing before fetching the complete body and attachments via the Resend Receiving API.
2. Pydantic Structured Intent Routing
Using ChatGroq with tool-calling enforcement, MailMind classifies emails into 6 distinct categories and extracts structured JSON metadata:
- Categories:
Invoice,Support Query,Meeting Request,Spam,Urgent Alert,General - Extracted Attributes: Sender identity, monetary values, dates, urgency rating (scale 1-10), and key action items.
3. Stateful Graph Checkpointing & Resilient HITL Queue
Built on LangGraph StateGraph with a PostgreSQL Checkpointer:
- When an email triggers high-urgency conditions (Urgency Score >= 8 or monetary value > $500), the graph executes a native
interrupt()call. - The execution state is frozen and saved to PostgreSQL.
- The Next.js dashboard receives a real-time SSE notification displaying the email context, extracted metadata, proposed action, and draft reply.
- Once the human operator clicks Approve or Modify, the graph resumes execution from the exact checkpoint and dispatches the email response via Resend SDK.
Key Platform Innovations
- RAG-Grounded Auto-Replies: FAISS vector search queries per-user knowledge bases to ground responses in verified company documentation.
- Plain-English Rule Editor: Natural-language business rules (e.g., "If invoice amount exceeds $1000, forward to finance team") dynamically stored as JSON schemas and evaluated at runtime.
- Real-time SSE Dashboard: Live Server-Sent Events stream node transitions, confidence ratings, and state changes to the frontend in real time.