M
MJK.Supplies
Home / n8n / n8n AI Agents: Build Autonomous Systems with n8n…
n8n

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.

M
MJK Supplies · May 11, 2026 · 13 min read
ShareXinf↗
n8n AI Agents: Build Autonomous Systems with n8n and LLMs

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:

  1. Add "AI Agent" node to your workflow
  2. Connect a Language Model node (Claude via HTTP or native LLM node)
  3. Connect tool nodes: Calculator, Wikipedia, HTTP Request, SerpAPI
  4. Connect Memory node (optional): Window Buffer Memory or Postgres Memory
  5. 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:

You are a research assistant. When given a company name, research: 1. What the company does (products, services) 2. Company size, founding year, location 3. Recent news and developments (last 6 months) 4. Key leadership 5. Known customers or partners 6. Technology stack (if visible) Use the available tools to gather this information. Synthesise into a structured brief. Return a structured report with clear sections for each area above.

Workflow:

  1. Webhook: receive company name
  2. AI Agent node: research agent with search + HTTP tools
  3. Code node: parse agent output
  4. Airtable: save company brief
  5. 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:

Research the topic: "{{topic}}" Find: 1. Recent statistics and data (last 2 years) 2. Expert opinions and quotes (with sources) 3. Common questions people ask about this topic 4. Competing viewpoints or debates in this area 5. Practical examples or case studies Gather information from at least 5 different sources. Synthesise into a research brief that a writer can use to write a comprehensive article.

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:

{ "company_overview": "...", "recent_news": ["..."], "likely_pain_points": ["..."], "decision_makers": ["..."], "tech_stack": ["..."], "talking_points": ["..."], "potential_objections": ["..."] }

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:

  1. Customer contacts support
  2. Redis memory lookup: retrieve this customer's previous conversations
  3. AI Agent node: agent with full history context
  4. 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:

// Code node used as a custom agent tool // Tool: "lookup_customer_data" const customerId = $input.first().json.customer_id; // Fetch from your database const customerData = await $http.get(`https://your-api.com/customers/${customerId}`); return [{ json: { name: customerData.name, plan: customerData.plan, usage: customerData.usage_this_month, support_history: customerData.recent_tickets } }];

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):

  1. Agent generates the proposed action
  2. Slack: "Agent wants to send email to {{customer}}. Approve?" (Yes/No buttons)
  3. Wait for human response
  4. Execute or cancel based on approval

Scope limiting:

You can ONLY: - Read data (no writing to databases unless explicitly authorised) - Search the web - Generate content drafts (not publish) You CANNOT: - Send emails directly - Modify CRM records - Access financial data All restricted actions must be flagged to a human for approval.

Iteration limits: Set maximum steps (max_iterations in AI Agent node). Prevents infinite loops.

Recommended Tools

  • n8n — Agent orchestration platform
  • Claude API — Best reasoning for agent tasks
  • SerpAPI — Web search tool for agents
  • Clearbit — Company research tool for sales agents
  • Airtable — Data storage for agent outputs
  • Vapi — Voice-enabled agents
#n8n#ai-agents#llm

Related articles

MJK Supplies · Automation Services

Want this built for you?

We design and ship custom AI agents and automation systems for teams that want results, not a backlog. Book a free 30-minute consult — no commitment, no pitch deck.