OperatorStack

"How to Build an AI Agent With n8n in 2026 (Step by Step)"

Our pick
We tested n8n hands-on. Start free or get a discount via our link.
Try n8n →

You can ship a useful AI agent in n8n without writing a full app. This guide builds a support-triage agent that reads an incoming message, classifies it, searches a knowledge base and drafts a reply — all on your hardware.

Steps#

1. Create a workflow and add a Chat Trigger#

Start a new workflow, add the ‘Chat Trigger’ node so the agent exposes a chat widget or webhook you can test from the editor.

2. Add the AI Agent node#

Drop the ‘AI Agent’ node. Point its Chat Model at an OpenAI-compatible credential (any LLM with an API works). Enable ‘memory’ so it recalls the conversation.

3. Give it a tool#

Add a ‘Tool’ node — for example an HTTP Request to your docs search, or a Vector Store node for RAG. The agent decides when to call it.

4. Set system instructions#

In the agent options, write a clear system prompt: role, tone, what it may and may not do, and when to escalate to a human.

5. Test and wire a real trigger#

Chat with it in the editor. When happy, replace the Chat Trigger with a real one (Gmail, Slack, or webhook) so live messages flow in.

6. Self-host and schedule#

Run n8n on a small VPS, set error workflows, and use the ‘Execute Workflow’ trigger to run it on a cron if needed.

Tips#

  • Keep the system prompt short and explicit about boundaries
  • Log every agent run so you can audit mistakes
  • Start read-only until you trust the tool calls
  • Cap token spend per run to avoid surprise bills

FAQ#

Q: Do I need to code?

No for basic agents; the Function node is optional for custom logic.

Q: Can it use my private docs?

Yes — connect a vector store or an internal search API as a tool.

Q: Is this free?

Self-hosting n8n is free; you pay only the LLM API and server cost.

OperatorStack is reader-supported. When you buy through links on our site, we may earn an affiliate commission — at no extra cost to you. We only recommend tools we've actually tested.