How to build an Email AI Agent with n8n - Step by Step

:hammer_and_wrench: Video notes & templates (free): Lead Form
:robot: Try n8n for free: AI Workflow Automation Platform & Tools - n8n

Build an AI email agent in n8n that automatically categorizes incoming emails, adds Gmail labels, and drafts personalized responses.

This tutorial demonstrates how to create an AI-powered email management system using n8n workflows. The agent automatically processes incoming emails, categorizes them with appropriate labels, and generates draft responses based on your business information, eliminating hours of manual email handling.

The workflow begins with the Gmail Trigger node, which monitors your inbox for new messages. By disabling the “Simplify” option, you ensure the AI receives the complete email text for accurate processing. When an email arrives, the trigger initiates the entire automation sequence.

A crucial component is the knowledge base, which provides the AI with context about your business, products, pricing, and policies. Using n8n’s built-in Data Tables feature, you can store all this information directly within the platform and retrieve it dynamically during workflow execution. This ensures the AI generates accurate, contextually appropriate responses.

The workflow also fetches all available Gmail labels using the Gmail “Get Many” action and combines them with an Aggregate node. This provides the AI with a complete list of categorization options, allowing it to intelligently assign the most appropriate label to each incoming email.

At the core of the automation is the AI Agent node, configured with a detailed prompt that defines its role as an email assistant. Connected to an OpenAI Chat Model and equipped with three tools—Telegram for notifications, and two Gmail tools for adding labels and creating drafts—the agent autonomously processes emails, categorizes them, and generates professional responses. Dynamic fields are set to be determined by the model, while static fields pull data from the trigger node using expressions.

Once configured and tested, the workflow runs automatically whenever new emails arrive. The AI processes each message, applies the appropriate label, drafts a response based on your knowledge base, and sends you a Telegram notification with a direct link to review the draft. This complete automation transforms email management from a time-consuming task into an efficient, AI-assisted process.

:date: Book a Free Consultation: Book a Call - SmoothWork
:e_mail: [email protected]