How to Build an AI Agent with n8n: A Practical Business Guide

TL;DR

n8n's AI Agent node lets you build AI-powered workflows that can browse the web, query databases, and call APIs, all without writing code. Useful for classifying support tickets, enriching leads, and summarizing documents. Costs $3 to 20/month in API fees on top of your n8n server.

AI agents are the most talked-about feature in automation right now. Every platform is rushing to add them. But most of the content out there is either marketing fluff or deeply technical tutorials for developers.

This post is neither. I build AI-powered workflows for small businesses, and I want to show you what n8n’s AI agent actually looks like in practice: what it does well, what it costs, and where it falls short.

70+ AI nodes in n8n
6,100+ Community AI templates
~$0.05 Per agent run (GPT-4o)
What is an AI agent

First, the simple version

An AI agent is a workflow where the AI model decides what to do next, not you. Instead of “always do step 1, then step 2, then step 3,” you give the agent a goal and a set of tools, and it figures out the steps on its own.

In n8n, this works through the AI Agent node. You connect it to a language model (GPT-4o, Claude, Gemini, your choice) and attach tools: database lookups, API calls, web search, code execution, whatever the job needs. The agent receives an input, reasons about which tool to use, runs it, evaluates the result, and repeats until it has an answer.

Here’s what a minimal AI agent workflow looks like:

Chat Trigger AI Agent Response

Under the AI Agent node, you attach sub-nodes:

Chat Model (GPT-4o, Claude, etc.) + Tools (APIs, search, code) + Memory (optional)

That’s it. Four nodes for a working AI agent. The complexity comes from what tools you give it and how you instruct it.

What can you actually build

Real use cases, not hypotheticals

Here are the AI agent use cases I’ve either built for clients or seen work well in production:

Customer support triage. An agent reads incoming emails or chat messages, classifies them by urgency and topic, looks up the customer’s order history, and either drafts a response or routes to the right person. Community reports show about 60% of routine inquiries handled without human intervention.

Lead scoring and enrichment. The agent takes a new lead from your CRM, searches the company website, checks LinkedIn or public databases, scores the lead against your ideal customer profile, and drafts a personalized outreach email. All triggered automatically when a new contact enters HubSpot or Pipedrive.

Document processing. Extract structured data from invoices, receipts, or contracts. n8n’s Information Extractor node can pull specific fields (amounts, dates, line items, vendor names) and push them into your accounting system or spreadsheet.

Knowledge base chatbot. This is the most popular template in n8n’s library. You load your company documents into a vector database, and the agent answers questions using only your data. It’s called RAG (retrieval-augmented generation). The agent retrieves relevant context from your docs before generating an answer, which dramatically reduces hallucination.

Email auto-response. The agent reads incoming emails, categorizes them, drafts responses using your company’s tone and policies, and queues them for human review, or sends them directly for low-risk categories like order confirmations.

The sweet spot. n8n AI agents work best when AI is one step in a larger automation, not the entire workflow. An agent that classifies an email, then triggers traditional n8n nodes to update a CRM, send a Slack message, and log the result is far more reliable than an agent that tries to do everything itself.

How to set one up

Building your first agent in n8n

Here’s a practical walkthrough. I’ll use the example of an email triage agent that reads incoming support emails and routes them.

Step 1: The trigger

Add a Chat Trigger node for testing (it opens a chat window in n8n). For production, you’d replace this with a Gmail trigger, a webhook, or whatever receives your incoming messages.

Step 2: The AI Agent node

Connect the trigger to an AI Agent node. Configure the system message. This is where you tell the agent who it is and what to do:

“You are a support email router for an e-commerce company. Read the incoming message and classify it as: order_issue, refund_request, product_question, or other. Look up the customer’s recent orders. If it’s a simple order status question, draft a response. For everything else, route to the support team with a summary.”

Set Max Iterations to 5 to 10. This prevents the agent from going in circles and burning tokens.

Step 3: Attach a language model

Click the AI Agent’s model connector and add an OpenAI Chat Model (or Anthropic, Google, etc.). Enter your API key, pick a model. For email triage, GPT-4o mini or Gemini 2.5 Flash is plenty. No need for the expensive models on a classification task.

Step 4: Attach tools

This is where it gets interesting. Add tools the agent can use:

  • HTTP Request Tool, configured to query your order database or CRM API
  • Custom Code Tool, for any logic you need (formatting, validation, date math)
  • Think Tool, gives the agent internal monologue space to reason through ambiguous cases before acting

Write clear descriptions for each tool. The agent reads these descriptions to decide which tool to use:

“Query the order database by customer email. Returns a list of recent orders with status, date, and tracking number.”

Bad tool descriptions are the #1 cause of agents picking the wrong action.

Step 5: Test and iterate

Activate the workflow, open the chat, and send test emails. Watch the execution log. n8n shows you exactly which tools the agent selected, what inputs it sent, and what results it got back. This visibility is one of n8n’s real strengths over pure-code agent frameworks.

Iterate on your system prompt and tool descriptions until the agent routes correctly. In my experience, getting from “mostly works” to “reliably works” takes a few hours of prompt refinement and edge case testing.

The AI toolbox

What n8n gives you beyond agents

The AI Agent node is the star feature, but n8n ships with about 70 AI-related nodes. Here’s what else is available:

CategoryWhat it doesKey nodes
ChainsSimple prompt → response patternsBasic LLM Chain, Q&A Chain, Summarization Chain
ExtractionPull structured data from textInformation Extractor, Text Classifier, Sentiment Analysis
RAG pipelineGround AI responses in your dataDocument Loaders, Text Splitters, Vector Stores, Retrievers
MemoryPersist conversation historyWindow Buffer, Postgres, Redis, MongoDB, Zep
ToolsGive agents abilitiesHTTP Request, Code, Calculator, Wikipedia, SerpAPI, MCP Client
EmbeddingsConvert text to vectors for searchOpenAI, Cohere, Google, Ollama, HuggingFace
Vector storesStore and query embeddingsPinecone, Qdrant, Supabase, PGVector, Chroma, Milvus

The RAG pipeline is worth calling out separately. You can build a complete knowledge base chatbot entirely in n8n: load PDFs or web pages, split text into chunks, generate embeddings, store them in a vector database, then query that database from your AI agent. No code required. Every step is a visual node.

n8n also supports MCP (Model Context Protocol), which means your n8n workflows can both provide and consume tools from external AI agents. Your n8n instance can act as a tool server for Claude Desktop or Cursor, or your n8n agent can connect to any MCP server for additional capabilities. This is a meaningful differentiator. Make doesn’t have this.

Which model to use

Choosing an LLM (and what it costs)

n8n supports 12+ LLM providers. Here’s what actually matters for business use:

ModelInput costOutput costBest forSpeed
GPT-4o$2.50/1M tokens$10.00/1MComplex reasoning, multi-step agentsFast
GPT-4o mini$0.15/1M$0.60/1MClassification, extraction, simple routingVery fast
Claude Sonnet 4.6$3.00/1M$15.00/1MInstruction-following, nuanced writingFast
Claude Haiku 4.5$1.00/1M$5.00/1MFast tasks, cost-sensitive agentsVery fast
Gemini 2.5 Flash$0.30/1M$2.50/1MBudget agents, high-volume processingFast
Gemini 2.5 Pro$1.25/1M$10.00/1MGoogle's best, strong reasoningModerate
Ollama (local)FreeFreeData-sensitive, high-volume simple tasksDepends on hardware

Real cost in practice: A support triage agent that processes one email (classifying it, looking up an order, and drafting a response) uses roughly 2,000 to 4,000 tokens. At GPT-4o rates, that’s about $0.02 to 0.05 per email. With GPT-4o mini, it’s under $0.001.

If you process 1,000 emails/month with GPT-4o, your AI cost is about $20 to 50/month. With GPT-4o mini for classification and GPT-4o only for response drafting, you can cut that to $5 to 10.

The routing trick. The most cost-effective pattern is a two-model setup: a cheap model (GPT-4o mini, Gemini Flash) classifies and routes incoming requests, then a capable model (GPT-4o, Claude Sonnet) only handles the complex cases. Most of my client workflows use this pattern. It cuts LLM costs by 60 to 80% with no quality loss on the tasks that matter.

Self-hosted models with Ollama

You can run open-source LLMs locally through Ollama and connect them to n8n. The cost is zero. You’re just paying for the server.

The honest assessment: local 7B to 13B parameter models work fine for simple classification and extraction. They’re noticeably worse than GPT-4o or Claude for complex multi-step reasoning. If your data absolutely cannot leave your infrastructure (healthcare, legal, defense), Ollama is the path. For everyone else, the frontier API models give better results for pennies per request.

Where agents fall short

The honest limitations

Most “how to build an AI agent” articles stop before this section. I won’t.

Agents are stateless between runs. When a workflow execution ends, all memory is gone. Persistent conversation memory requires an external database (Postgres, Redis). Setting this up correctly adds real complexity.

Hallucination is a real problem. Even with RAG, agents sometimes make things up, especially after extended conversations. I’ve seen agents invent order numbers, fabricate delivery dates, and confidently cite nonexistent policies. Every production agent needs output validation.

Tool selection isn’t perfect. The agent reads your tool descriptions and picks which one to use. Sometimes it picks wrong, especially with vaguely worded descriptions or overlapping tools. Clear, specific descriptions are essential. Treat them like documentation, not afterthoughts.

Costs can surprise you. An agent stuck in a reasoning loop burns through tokens fast. Always set Max Iterations. A runaway agent with GPT-4o and no iteration cap can spend dollars per request instead of cents.

Complex multi-agent patterns are fragile. You can nest agents (have a supervisor agent route to specialist agents) but in practice this multiplies failure points. I only use multi-agent setups when the use case clearly demands it.

100K+ rows will crash things. n8n isn’t a data processing platform. If your agent needs to analyze large datasets, pre-process and summarize them first.

n8n vs other options

Why build agents in n8n instead of code?

If you’re a developer, you might wonder why you wouldn’t just use LangChain or the OpenAI Assistants API directly.

Aspectn8nLangChain / codeOpenAI Assistants
Setup timeMinutesHours to daysHours
LLM flexibility12+ providers, swap freelyAny (you code it)OpenAI only
Visual debuggingSee every step, tool call, reasoningCode loggingAPI logs only
Trigger options400+ app triggers built-inYou build themYou build them
Non-AI stepsNative (email, CRM, Slack, databases)You code integrationsYou code integrations
Self-hostingYes, freeYou manage infraCloud only
Max flexibilityHigh, with code nodes when neededMaximumLimited

n8n gives you about 80% of LangChain’s capability at 20% of the effort. The real advantage isn’t the AI part. It’s that n8n connects AI to everything else. An agent that classifies an email, updates Pipedrive, sends a Slack message, and logs to Google Sheets takes four visual nodes in n8n. In pure code, that’s dozens of API integrations to build and maintain.

Use pure code when you need fine-grained control over agent behavior that n8n’s visual builder can’t express: custom sampling strategies, exotic memory architectures, or tight integration with ML pipelines. For business automation with AI, n8n is the faster path.

Getting started

What I recommend for a first AI project

If you’re a small business exploring AI agents, don’t start with a complex multi-agent system. Start with something small and measurable:

  1. Pick one repetitive task that involves reading text and making a decision. Email classification is a great first candidate.
  2. Use n8n Cloud Starter (€20/month) or self-host on a €5 Hetzner VPS.
  3. Start with GPT-4o mini or Gemini 2.5 Flash. You can always upgrade the model later. n8n makes this a one-click swap.
  4. Keep the agent simple. One model, two or three tools, a clear system prompt. Get this working reliably before adding complexity.
  5. Measure the result. How much time does this save per week? How accurate is it? What’s the monthly API cost?

The businesses that get the most value from AI agents aren’t the ones with the most sophisticated setups. They’re the ones that picked a clear, bounded problem and automated it well.

If you’re not sure where to start, or whether an AI agent even makes sense for your situation, send me an email. I’ll walk you through the options honestly. First conversation is always free.


minh@mpstudio.dev

I usually reply within a day.