n8n AI Agents: Build Autonomous Systems with n8n and LLMs
AI agents in n8n go beyond simple trigger-action workflows. An agent receives a goal, reasons about what steps to take, uses tools to gather information and take actions, and iterates until the task is complete. n8n's AI Agent node and flexible workflow architecture make it one of the best platforms for building and deploying autonomous AI agents.
What Makes n8n Good for AI Agents
n8n has several features that make it excellent for AI agents:
AI Agent node: Native orchestration node that handles the tool-call loop automatically. Connect Claude (or other LLMs) + tools, and the node manages the agent loop.
Tool nodes: Web search, calculator, HTTP calls, database queries, code execution — all available as agent tools.
Memory nodes: Maintain conversation history across agent turns.
Loop nodes: For agentic patterns that need iteration beyond what the AI Agent node provides.
Sub-workflows: Complex agents can delegate to specialised sub-workflows, keeping the main agent lean.
Error handling: Production agents need to handle failures gracefully. n8n's error branches and retry logic are well-developed.
n8n AI Agent Node
The built-in AI Agent node (added in n8n v1.x) simplifies agent setup:
- Add "AI Agent" node to your workflow
- Connect a Language Model node (Claude via HTTP or native LLM node)
- Connect tool nodes: Calculator, Wikipedia, HTTP Request, SerpAPI
- Connect Memory node (optional): Window Buffer Memory or Postgres Memory
- Configure the agent prompt/goal
The node handles the agent loop: LLM decides to call a tool → n8n executes the tool → returns result to LLM → LLM continues reasoning.
Building a Research Agent
Use case: Given a company name, research the company and produce a detailed brief.
Tools:
- Web Search (via SerpAPI or Brave Search)
- HTTP Request (for fetching specific pages)
- Clearbit API (company data)
System prompt:
Workflow:
- Webhook: receive company name
- AI Agent node: research agent with search + HTTP tools
- Code node: parse agent output
- Airtable: save company brief
- Slack: notify requester with link
Building a Content Research Agent
Use case: Research a topic thoroughly before writing an article.
Tools:
- Web Search: find recent articles and data
- HTTP Request: fetch and read specific pages
- Wikipedia: background information
Agent prompt:
Building a Sales Research Agent
Use case: Before a sales call, research the prospect thoroughly.
Trigger: HubSpot deal moved to "Call Scheduled" Agent tools: Web search, LinkedIn (via API), Clearbit, news API
Output:
Memory Management for Agents
Long-running agents need memory:
Session memory (within one agent run): The AI Agent node maintains this automatically via conversation history.
Cross-session memory (across workflow executions): Use Postgres or Redis memory nodes. The agent can recall information from previous interactions with the same user or about the same topic.
Example: Support agent with customer history:
- Customer contacts support
- Redis memory lookup: retrieve this customer's previous conversations
- AI Agent node: agent with full history context
- After conversation: update Redis memory with new interaction
Custom Tool Nodes
Create custom tools for your agent:
Via HTTP Request as tool: Any API can be a tool. Configure HTTP Request node with your API details and connect to AI Agent.
Via Code node as tool:
Agent Safety and Control
Autonomous agents can cause unintended consequences:
Approval gates for high-impact actions: For actions that can't be undone (sending emails, deleting records, posting publicly):
- Agent generates the proposed action
- Slack: "Agent wants to send email to {{customer}}. Approve?" (Yes/No buttons)
- Wait for human response
- Execute or cancel based on approval
Scope limiting:
Iteration limits: Set maximum steps (max_iterations in AI Agent node). Prevents infinite loops.
Related articles
n8n vs Make.com vs Zapier: a 2026 honest comparison
No affiliate fluff — where each tool wins, where it breaks, and what we actually run.
Self-hosting n8n: a production-grade setup guide
Queue mode, workers, backups, and the security defaults you should never skip.
Complete n8n Guide: Everything You Need to Build Powerful Automations
The definitive n8n guide — nodes, credentials, triggers, and production-grade patterns.