n8n Webhook-Triggered AI Agent
Expose an n8n AI Agent (with memory and tools) behind a webhook that returns the answer synchronously.
Setup time1 hour (estimate)
Estimated costn8n plus LLM tokens per request.
Toolsn8n
VerificationLast verified 2026-10-14
Nodes
- Webhook (POST
/agent, Respond: Using 'Respond to Webhook' node). - AI Agent (
@n8n/n8n-nodes-langchain.agent), prompt from{{ $json.body.message }}.
Sub-node Chat Model (OpenAI, Anthropic, Ollama, ...).
Sub-node Window Buffer Memory keyed on{{ $json.body.session_id }}.
Tool sub-nodes, e.g. HTTP Request Tool, Calculator. - Respond to Webhook – JSON
{ "reply": "{{ $json.output }}" }.
Test
curl -X POST https://YOUR-N8N/webhook/agent \
-H 'Content-Type: application/json' \
-d '{"session_id":"u123","message":"What is 17% of 2,340?"}'Hardening
- Add Header Auth on the Webhook node (shared secret) before exposing it publicly.
- Set a max iterations limit in the AI Agent options.
- Use the test URL (
/webhook-test/) during development, and activate the workflow for the production URL.
Failure modes
- Unauthenticated webhooks let anyone spend your tokens; add header auth.
- Agent loops on tool errors without an iteration limit.
- Test vs production webhook URLs differ; activate the workflow before going live.
Markdown version: /blueprints/n8n-webhook-ai-agent.md
Want a deeper build of this?
Vote for an extended, fully tested version (more tools, a full workflow file). Votes decide what we build next.
Get one fully built blueprint a week
A weekly email: one blueprint with config, cost, setup time and failure modes, plus a vote on what we build next.
Related blueprints
n8n Automation Blueprints
n8n Form Lead Enrichment and CRM Sync
Capture a lead via n8n Form Trigger, research the company website with an LLM, and upsert into a sheet or CRM.
n8n Automation Blueprints
n8n Global Error Alerting Workflow
A dedicated error workflow that alerts you with the failing workflow, node, and execution link whenever any workflow fails.
n8n Automation Blueprints
n8n Inbox Triage with LLM Classification
Classify incoming email into categories with structured output, then label, route, or draft replies.