n8n Workflows
- 1 – Daily new Contact Report from Airtable (JSON Direct Link)
- 2 – AI Company Research (JSON Direct Link)
- 3 – Chat with Airtable with AI (JSON Direct Link)
- 4 – Simple Airtable MCP Server (JSON Direct Link)
Video
Video Summary
In this tutorial, we’ll show you how to build a simple but powerful AI agent using n8n that manages your emails. This email agent can save you hours of time each week, and you can build it in just about 10 minutes.
Demonstration: How the AI Agent Works
Let’s see the agent in action. First, a new email arrives asking for a price quote on some products. This email automatically kickstarts our AI agent workflow in n8n, which processes the email content.

Once the workflow is complete, two things happen in Gmail. First, the AI adds a relevant label to the email, in this case, “Quotation Requests.” Second, it drafts a complete, detailed response based on the request. It calculates the pricing from a knowledge base, checks for special conditions like free delivery, and even suggests potential volume discounts. All you need to do is review the draft and click send.

Step 1: Preparing Your Workspace
Before building the workflow, you need a couple of things ready. First, have a test email in your Gmail inbox to work with. Second, ensure you have created the necessary labels in Gmail that you want the AI to choose from, such as “Quotation Requests,” “Customer Complaints,” or “Urgent Emails.”
Step 2: Building the n8n Workflow
Setting Up the Gmail Trigger
In a new n8n workflow, the first step is to add a trigger. Search for the Gmail node and select the On message received trigger. This will start the workflow whenever a new email arrives. You’ll need to connect your Gmail account. A crucial setting is to turn off the Simplify option. This ensures you get the full text of the email, which the AI will need for processing.
Creating a Knowledge Base
For the AI agent to provide accurate and helpful responses, it needs context about your business. This is where a knowledge base comes in. You can create a document that includes a Response Style Guide, Company Information, Products & Pricing, and a list of Common Questions & Answers.

To use this in n8n, we’ll create a Data Table. This feature lets you store information directly within n8n. Create a new data table, add a column for your knowledge base, and paste all the information into a single row. This keeps everything organized and easily accessible for the workflow.
Fetching the Necessary Data
Now, we need to pull this data into our workflow. Add a Data table node and use the Get row(s) operation to fetch the knowledge base content we just created. Limit it to 1 since we only have one row.
Next, we need to provide the AI with a list of available labels. Add another Gmail node and use the Get many labels action. Enable the Return All option to fetch every label in your account.
Because the “Get many labels” node outputs multiple items, we need to combine them into a single list. Add an Aggregate node to compile all label data into one item. This is necessary so the AI Agent node, which runs only once, has access to all the labels.
Step 3: Configuring the AI Agent
This is the core of our automation. Add an AI Agent node. The main configuration happens in the prompt.
Crafting the Prompt
The prompt instructs the AI on its role and tasks. You will provide it with dynamic information from the previous nodes:
The Role: Define the AI’s persona (e.g., “You are an email assistant for Dunder Mifflin…”).
The Tasks: Clearly list what the AI needs to do, such as categorizing the email and drafting a response.
The Knowledge Base: Pass the full knowledge base from the Data Table node.
Label Names and IDs: Pass the aggregated list of labels.
* The Email to Process: Pass the text, subject, ID, and thread ID from the initial Gmail Trigger node.

Connecting the Model and Tools
Connect a Chat Model to the AI Agent, such as the OpenAI Chat Model node. Then, add the Tools the agent can use to execute its plan.
1. Create a draft in Gmail: Use the Gmail tool. Set the Subject and Message fields to be “Defined automatically by the model.” For the To Email and Thread ID, pull the data directly from the Gmail Trigger. This tells the AI it needs to generate the content, but we’ll handle where it goes.
2. Add label to message in Gmail: Use another Gmail tool. The Message ID comes from the trigger, and the Label Names or IDs will be defined by the model based on its categorization.
3. Send a text message in Telegram: This is for notifications. Set up a Telegram tool to send a message. The Text will be defined by the model, which we’ve instructed in the prompt to create a link to the new draft.

Final Test
With everything connected, you can run the workflow. The AI agent will process the email, create the draft, apply the correct label, and send a notification to your Telegram with a direct link to the draft for review.