A production-ready, multi-agent automation system that reads, categorizes, summarizes, and drafts replies for high-volume email inboxes, built with n8n, OpenAI, and custom logic.
The core architecture treats the email inbox as a real-time data stream. Using the Gmail API via n8n, new emails trigger the workflow instantaneously. A dedicated webhook server handles the initial ingestion to ensure reliability.
Each agent is implemented as a discrete n8n workflow node or sub-flow. This modular design allows for independent testing, updating, and scaling. For instance, the Classifier Agent's logic can be swapped without affecting the Drafting Agent.
Context management was a critical challenge. The system maintains a lightweight vector database (using Pinecone) of recent project keywords and contact histories. When the Drafting Agent is invoked, it performs a similarity search to fetch the most relevant context before generating a reply, ensuring drafts are informed and specific.
A central 'Orchestrator' workflow in n8n manages the hand-off between agents. Based on the classification score and category, it routes the email to the appropriate subsequent agents. For a 'Query' email, it chains the Summarizer and then the Drafting Agent. For a 'Meeting' email, it triggers the Follow-up Agent.
The human-in-the-loop layer is built into the interface. All agent outputsâsummaries, categories, and draftsâare posted to a dedicated Slack channel using a webhook. Buttons in the Slack message allow for quick 'Approve & Send', 'Edit', or 'Archive' actions, keeping final control with the user.
Error handling and logging are comprehensive. Each agent step logs its input, the LLM prompt used, and the output to a structured logging service. If an agent fails (e.g., an API timeout), the workflow pauses and sends an alert, preventing incorrect automated actions.

Loading comments...