How do you set up AI agents in n8n?
Quick Answer: AI agents are built in n8n using the AI Agent node (based on LangChain), which combines an LLM, tools, and memory. Connect an LLM node (OpenAI, Anthropic, or Ollama), add tool nodes for capabilities (HTTP requests, database queries, calendar), attach memory (buffer or vector store), and trigger via chat, webhook, or schedule. The AI Agent reasons over user input and calls tools as needed.
Setting Up AI Agents in n8n
n8n added native LangChain integration in 2024, with the AI Agent node enabling function-calling agents that use tools to accomplish multi-step tasks. As of April 2026, n8n is one of the most widely used self-hosted AI agent platforms.
Core Nodes
- AI Agent: Orchestrator that plans and calls tools
- Chat Model (sub-node): OpenAI Chat Model, Anthropic, Ollama, Google Gemini
- Memory (sub-node): Window Buffer Memory, Vector Store Memory, Motorhead
- Tools (sub-nodes): HTTP Request, Calculator, Wikipedia, custom workflow tools
Step-by-Step Setup
1. Trigger
Choose a trigger for the agent:
- Chat Trigger: Built-in chat UI for testing
- Webhook: HTTP endpoint for integration
- Schedule Trigger: Run on interval
- Telegram/Slack Trigger: Accept messages from chat platforms
2. Add AI Agent Node
The AI Agent node expects:
- Input: The user message or task
- System Message: Instructions defining the agent's role
- Chat Model: Connected LLM node
- Memory: Optional conversation memory
- Tools: Array of connected tool nodes
3. Connect a Chat Model
As a sub-node, add:
- OpenAI Chat Model (gpt-4o, gpt-4o-mini, o1)
- Anthropic Chat Model (claude-3-7-sonnet, claude-4-sonnet)
- Ollama Chat Model (for local models like Llama, Mistral)
- Google Vertex Chat Model
4. Add Tools
Tools extend the agent's capabilities:
- HTTP Request Tool: Call any API
- Workflow Tool: Execute another n8n workflow as a tool
- Calculator: Math operations
- Code Tool: Execute JavaScript
- Wikipedia/SerpAPI: Web search
- Custom: Build tools from any n8n node
5. Configure Memory
- Window Buffer Memory: Keep last N messages
- Vector Store Memory: Semantic memory using embeddings (e.g., Pinecone, Qdrant)
- Motorhead: Summarization-based memory
Example: Customer Support Agent
Chat Trigger
→ AI Agent
- System: "You are a customer support agent..."
- Chat Model: OpenAI gpt-4o-mini
- Memory: Window Buffer (k=10)
- Tools:
- HTTP Request: Lookup order by ID
- Workflow Tool: Create support ticket
- SerpAPI: Search docs
Testing
Use the Chat Trigger for interactive testing:
- Open the workflow in editor
- Click the Chat Trigger node
- Open the chat window
- Send test messages and observe agent reasoning
Self-Hosted Considerations
- Local LLMs: Use Ollama for privacy-sensitive deployments
- Vector stores: Self-host Qdrant or use managed Pinecone
- Cost control: Log token usage to Airtable for monitoring
Production Tips
- Set max iterations (usually 5-10) to prevent infinite loops
- Use structured output for deterministic downstream workflows
- Monitor tool call failures and implement retries
- Version prompts in a dedicated node with environment variables
Related Questions
Related Tools
n8n
Workflow automation and AI agents for technical teams
Workflow AutomationRelevance AI
No-code AI agent builder for business tasks with multi-step workflows, knowledge base integration, and team collaboration.
AI Agent PlatformsLindy
AI employee platform that plugs into a team's tools and takes on recurring work across Slack, email, text and calendar
AI Agent PlatformsGumloop
No-code AI workflow automation with visual node-based editor
AI Agent PlatformsRelated Rankings
Best Human-in-the-Loop Automation Platforms 2026
Eight platforms are ranked here on a single mechanism: how a person enters an automated path, and what the system can prove afterward about the decision they made. Moxo scores 7.7 and ranks first; Camunda 8 scores 7.2, Microsoft Power Automate 7.1, Pega 6.9, n8n 6.7, Zapier 5.9…
Best Automation Platforms for AI Orchestration 2026
This ranking answers one question: how many real business applications can an AI agent act on out of the box? It evaluates nine platforms as of August 2026 on the reach they give an agent, not on the workflow logic they can express. That boundary is deliberate, because two…
Dive Deeper
Moxo vs Gumloop in 2026: Texting the Client, or Building the Agent
Gumloop (founded 2023) builds AI agents a company's own staff run; Moxo, whose predecessor Moxtra was co-founded in 2012, runs processes that wait on people outside the company. Gumloop wins three rounds to two: the way in, per-tool gating and a priced overage. Moxo wins on…
Moxo vs Relay.app in 2026: Where Relay's Approval Workflows Can Go Next
Relay.app, founded in 2021, shut down in September 2026 and deleted every account, workflow and run history; Moxo, whose predecessor Moxtra was co-founded in 2012, is one destination for its human-in-the-loop users. Relay.app takes two rounds, Moxo one, and vendor risk is a draw…
Moxo vs Workato in 2026: The Integration Estate, or the Approval Inside It
Workato, founded in 2013, is an enterprise integration platform whose Workflow apps add human tasks to recipes; Moxo, whose predecessor Moxtra was co-founded in 2012, ships the human step itself. Workato wins three rounds to two: connector reach, change control and the way in…