Launch-Free 3 months Builder plan-
Pixel art lobster working at a computer terminal with email — n8n ai agent email node

how to use the n8n ai agent email node (step-by-step)

Learn how to connect the n8n AI Agent node to the Send Email node, build email responders, classify inbound mail, and avoid common pitfalls.

6 min read
Ian Bussières
Ian BussièresCTO & Co-founder

Most n8n tutorials show you how to send a notification email or forward a form submission. That's fine for static workflows. But the moment you wire an AI Agent node into the mix, the rules change. Your workflow stops being a fixed pipeline and starts making decisions: which emails to reply to, what to say, who to escalate to, and when to stay quiet.

The n8n AI Agent node is what makes this possible. And the Send Email node is how the agent actually acts on those decisions. Getting them to work together isn't hard, but there are a few places where things break if you don't know what to expect.

This guide walks through the full setup, from trigger to send, with the specific field mappings and error handling that the official docs gloss over.

What the n8n AI Agent node actually does#

A regular n8n Function node runs JavaScript you write. It's predictable. You define the logic, and the node executes it the same way every time.

The AI Agent node is different. It takes an input (like an email body), sends it to a language model (OpenAI, Anthropic, DeepSeek, or others), and returns a response that depends on context. You give it a system prompt describing its role, connect it to tools it can call, and let it reason about what to do next.

For email workflows, this means the agent can read an incoming message, decide whether it's a support request or a sales inquiry, draft a reply in the right tone, and pass that reply to the Send Email node. The logic isn't hardcoded. It adapts.

The tradeoff is that you need to handle variability. The agent might format its output differently between runs, skip a field, or hallucinate a recipient address. Good n8n email workflows account for this with validation nodes between the agent and the send step.

How to connect the email node to an AI agent in n8n#

Here's the core wiring, broken into steps you can follow on your own canvas:

  1. Add a trigger node (Gmail Trigger, IMAP Email, or a Webhook node) to start the workflow when a new email arrives.
  2. Add the AI Agent node and connect it to the trigger. Set your model provider (OpenAI, Anthropic, etc.) and write a system prompt that describes the agent's job.
  3. Feed the email fields into the agent's input. Map subject, from, and text (or html) from the trigger output into the agent's prompt using n8n expressions like {{ $json.subject }}.
  4. Add a Send Email node (SMTP) or Gmail node after the agent. Map the agent's output fields to To, Subject, and Body using expressions.
  5. Configure your SMTP credentials on the Send Email node (host, port, username, password) or authenticate with OAuth for Gmail.
  6. Add a Set node between the agent and Send Email to validate that required fields (to, subject, body) exist and aren't empty.
  7. Test with a single known recipient before enabling production triggers.

That sixth step is the one most tutorials skip. Without it, you'll hit the infamous No recipients defined error the first time your agent returns an output that doesn't perfectly match the expected field names.

Reading and classifying inbound email with AI#

One of the most practical uses for the n8n AI Agent email node is sorting incoming mail by category before your team ever sees it. Instead of building regex filters or keyword rules, you hand the email to the agent and let it classify.

A typical system prompt for this looks something like:

You are an email classifier. Read the email below and respond with exactly
one of these categories: support, sales, billing, spam, other.

Do not explain your reasoning. Just output the category name.

The key detail: tell the model to output only the category. If you let it explain itself, you'll get three paragraphs of reasoning that you then have to parse. Constraining the output format makes the downstream nodes much simpler.

After classification, use an n8n Switch node to route emails to different branches. Support tickets go to your ticketing system. Sales inquiries get a drafted response. Spam gets logged and discarded.

You can also layer in Retrieval-Augmented Generation (RAG) by connecting a vector store tool to the agent. This lets the agent pull context from your knowledge base, past tickets, or product docs before composing a reply. The quality improvement is significant: instead of generic responses, the agent writes replies grounded in your actual documentation.

Sending AI-generated replies without getting flagged#

Here's where things get practical. Your agent drafted a response. Now you need to actually send it without landing in spam or accidentally emailing the wrong person.

Validate before sending. Add a Function node between the agent and the Send Email node that checks:

const output = $input.first().json;

if (!output.to || !output.to.includes('@')) {
  throw new Error('Invalid or missing recipient address');
}

if (!output.body || output.body.length < 10) {
  throw new Error('Email body is empty or too short');
}

return [{ json: output }];
**Use SMTP over Gmail when possible.** The Gmail node is convenient, but Google enforces strict sending limits (500 emails per day for workspace accounts, less for free accounts). If your agent handles volume, dedicated SMTP infrastructure will save you from hitting walls at the worst time. You can configure the Send Email node with any SMTP provider.

**Add human-in-the-loop for high-stakes sends.** n8n has a built-in Wait node. Place it before the Send Email step, send the draft to Slack or a review dashboard, and pause the workflow until a human approves. This is especially worth doing during the first week of any new agent workflow, while you're still tuning the system prompt.

Passing dynamic data between nodes#

One question that comes up constantly: how do I get values from the AI agent's output into the Send Email node's fields?

In n8n, you reference upstream node output with expressions. If your AI Agent node is named "AI Agent" and its output JSON has a to field, you'd set the Send Email node's recipient to:

{{ $('AI Agent').first().json.to }}

The same pattern works for subject, body, and any other field. The trick is knowing exactly what your agent outputs. Add a Debug node right after the AI Agent during development. It'll show you the raw JSON structure so you can write accurate expressions instead of guessing.

If your agent returns the entire reply as a single text block (common with simpler prompts), you can still use it. Just map the full output to the email body and hardcode the subject line and recipient from the original trigger data.

Scaling past Gmail limits#

Gmail caps sending at 500 messages per day on Google Workspace and even less on free accounts. For personal projects, that's fine. For an AI agent handling customer inquiries or processing inbound leads across multiple campaigns, you'll burn through that quota by lunch.

Your options: use dedicated SMTP infrastructure, rotate across multiple sending accounts, or move to an email service with higher limits. The Send Email node in n8n works with any SMTP server, so switching providers doesn't require rebuilding your workflow. You just update the credentials.

If you're building agents that need their own isolated email identities (separate addresses, separate sending reputations), that's where purpose-built agent email infrastructure like LobsterMail comes in. Each agent gets its own inbox and sending identity without sharing quotas or credentials with your personal accounts.

Tracking and closing the loop#

One gap in most n8n email agent setups: there's no feedback loop. The agent sends an email and has no idea whether it was opened, replied to, or bounced.

For basic tracking, you can poll the inbox for replies using a scheduled trigger and match them against sent messages by thread ID or subject line. For bounce handling, configure your SMTP provider to forward bounce notifications to an inbox your workflow monitors.

The more sophisticated version connects your agent's send history to a simple database (Postgres, Airtable, or even a Google Sheet) and updates the record when a reply arrives. This gives the agent context for follow-up decisions: did the customer respond? Should we send a reminder? Has this thread gone cold?

Building this loop takes an extra hour of setup. It makes the difference between an agent that sends emails into the void and one that actually holds a conversation.


Frequently asked questions

What does the n8n Send Email node do, and when should I use it over the Gmail node?

The Send Email node sends messages via any SMTP server. Use it when you need higher sending limits, a non-Google provider, or more control over headers and authentication. The Gmail node is simpler for low-volume sends from a Google account.

How do I map AI Agent output fields to the Send Email node inputs?

Use n8n expressions. If your AI Agent node outputs a JSON object with to, subject, and body fields, reference them as {{ $('AI Agent').first().json.to }} in the corresponding Send Email fields.

Why does the Send Email node throw a 'No recipients defined' error?

This happens when the To field is empty or the expression resolving it returns undefined. Add a validation node between the AI Agent and Send Email to confirm the to field exists and contains a valid email address before the workflow reaches the send step.

Can the n8n AI Agent node both read and send emails in the same workflow?

Yes. Use a trigger (Gmail Trigger or IMAP) to capture inbound mail, pass it to the AI Agent for processing, then route the agent's output to a Send Email node. It's a single linear workflow with three core nodes.

Which AI models work best with the n8n AI Agent email node?

OpenAI's GPT-4o and Anthropic's Claude are the most reliable for email classification and response drafting. DeepSeek works well for simpler tasks. The choice depends on your latency requirements and budget.

How do I add a human-approval step before my n8n AI agent sends an email?

Insert a Wait node before the Send Email step. Send the draft to Slack or email for review, and configure the Wait node to resume only when an approval webhook fires. n8n's built-in wait/resume mechanism handles this natively.

What SMTP credentials do I need to configure the Send Email node?

You need the SMTP host (e.g., smtp.yourprovider.com), port (typically 587 for TLS), username, and password. Some providers also require an app-specific password if two-factor authentication is enabled.

How do I prevent my n8n AI agent from sending duplicate emails in a loop?

Track processed message IDs in a database or a Set node that deduplicates against previous runs. You can also use n8n's built-in "Read/Write File" or "Postgres" nodes to maintain a log of already-handled email IDs.

Can I use RAG in an n8n email workflow?

Yes. Connect a vector store tool (Pinecone, Qdrant, or Supabase) to the AI Agent node. The agent queries it during reasoning to pull relevant context from your docs before drafting a reply.

How do I classify incoming emails by category using n8n AI?

Feed the email body into an AI Agent node with a system prompt that instructs it to output a single category label (support, sales, spam, etc.). Then use a Switch node to route based on the agent's output.

What's the best way to strip HTML from email bodies before sending them to an AI model?

Use a Function node with a simple regex like html.replace(/<[^>]*>/g, '') or install the html-to-text npm package in your n8n instance for cleaner conversion that preserves formatting cues.

How do I scale an n8n AI email agent past Gmail sending limits?

Switch from the Gmail node to the Send Email node with dedicated SMTP credentials from a provider with higher quotas. You can also rotate across multiple sending accounts using a Function node that selects credentials round-robin.

Should I use polling or a webhook to trigger my n8n email workflow?

Polling (Gmail Trigger, IMAP) checks for new mail on a schedule and is simpler to set up. Webhooks give you near-instant delivery but require your email provider to support push notifications. For most use cases, polling every 1-2 minutes is sufficient.

How do I track whether emails sent by my n8n AI agent were opened or replied to?

For reply tracking, poll the sending inbox for new messages and match by thread ID. Open tracking requires embedding a tracking pixel, which most SMTP providers support. Store send records in a database so the agent can reference them in follow-up decisions.

Related posts