This n8n webhook tutorial shows you how to trigger a Claude AI workflow from anything that can send an HTTP request: a contact form, a payment, a CRM update, or your own app. It covers the setup, but also the parts most tutorials skip: test vs production URLs, self-hosting gotchas, security, and how to avoid processing the same event twice.
Updated September 2026 for n8n 2.x and Claude Sonnet 5.
Webhooks vs Polling in 30 Seconds
A polling trigger asks a service “anything new?” on a schedule. A Gmail trigger checking every 15 minutes asks 96 times a day, even when nothing happened. A webhook flips that around: the external service pushes data to n8n the moment something happens.
Use polling when the service has no webhook support (many inboxes, RSS). Use webhooks for form submissions, payments, CRM events, and any integration where you control the sender.
Before you build a raw webhook, check for a dedicated trigger node. n8n has native trigger nodes for services like Stripe and Typeform that register the webhook for you and handle each service’s quirks. Use the generic Webhook node when no dedicated trigger exists or when the sender is your own code.
Step 1: Add and Configure the Webhook Node
Create a new workflow and add a Webhook node as the trigger. The settings that matter:
- HTTP Method: POST for almost every integration.
- Path: something readable like
contact-formornew-order. n8n generates a random one by default; a readable path makes debugging easier. - Authentication: leave it off while testing, turn it on before production (see the security section below).
- Respond: controls when n8n answers the sender (explained next).
Choosing the right response mode
- Immediately: n8n replies right away and keeps working in the background. Use this for forms, payment providers, and anything that just needs to know the event arrived. Senders like payment platforms expect a fast success response and may retry if they don’t get one.
- When Last Node Finishes: the caller waits for the whole workflow and receives the last node’s output. Fine for short workflows called from your own app.
- Using ‘Respond to Webhook’ Node: you decide exactly what to send back and when. This is the pattern for “send a question, get Claude’s answer back” APIs.
Step 2: Understand Test URL vs Production URL
This is the single most common reason a webhook “doesn’t work”. Every Webhook node has two URLs:
Test: https://your-n8n-domain.com/webhook-test/contact-form
Production: https://your-n8n-domain.com/webhook/contact-form
- The test URL only responds while you have clicked Listen for test event in the editor, and it shows the incoming data in the node so you can build the rest of the workflow.
- The production URL only responds once the workflow is live. In n8n 2.x, saving is not enough: you have to publish the workflow, and every later change must be published again before production picks it up.
If you paste the test URL into a form plugin and then close the editor, the form will silently fail. Always switch the sender to the production URL before going live.
Step 3: Send a Test Request and Read the Payload
Click Listen for test event, then fire a request from your terminal:
curl -X POST https://your-n8n-domain.com/webhook-test/contact-form \
-H "Content-Type: application/json" \
-d '{"customer_name":"Ana","email":"ana@example.com","message":"I was charged twice this month"}'
The Webhook node splits the request into parts. For a JSON POST, your fields live under body:
{{ $json.body.customer_name }} // JSON or form fields
{{ $json.query.source }} // ?source=landing in the URL
{{ $json.headers["user-agent"] }} // request headers
Pin the test data in the node so you can keep building without re-sending the request every time.
Step 4: Connect Claude
After the Webhook, add a Basic LLM Chain (for a single prompt) or an AI Agent (if Claude needs tools). Then attach an Anthropic Chat Model sub-node to it and select your model. Claude Sonnet 5 is a sensible default for this kind of task. The chat model is not a step in the main flow; it plugs into the chain or agent.
A support-triage prompt using the payload above:
You are a support triage assistant.
Classify the request and draft a short reply.
Customer: {{ $json.body.customer_name }}
Message: {{ $json.body.message }}
Return JSON with: category (billing | technical | general),
urgency (low | medium | high), reply (max 80 words).
Enable Require Specific Output Format on the chain and attach a Structured Output Parser with that schema. Now an IF or Switch node can route on category and urgency reliably instead of parsing free text.
If you are deciding between Claude and OpenAI for this step, see our Claude vs OpenAI in n8n comparison, including how to add a fallback model so a provider outage doesn’t break the webhook.
Step 5: Secure the Webhook
Anyone who finds an open webhook URL can trigger your workflow and burn API credits. Before going live:
- In the Webhook node, set Authentication to Header Auth and create a credential with a header name (for example
X-Webhook-Secret) and a long random value. - Configure the sender to include that header on every request.
- Requests without the correct header are rejected before any node runs, so Claude is never called.
If the sender can’t add custom headers (some form plugins can’t), use a hard-to-guess path and validate a shared secret field in the body with an IF node as the first step. Services that sign their requests, like payment providers, are best handled with their dedicated trigger node.
Step 6: Don’t Process the Same Event Twice
Senders retry when they don’t get a timely response, and users double-click submit buttons. If each run sends an email or creates a CRM record, duplicates hurt. Add a Remove Duplicates node right after the Webhook, configured to drop items already seen in previous executions, keyed on a unique value such as the event ID or email plus timestamp.
Self-Hosting Gotchas (Lessons from Our Own Setup)
We run n8n self-hosted in Docker behind a reverse proxy. These are the issues that actually cost us time:
- Webhook URLs showing
localhost:5678. Behind a proxy, n8n doesn’t know its public address. Set theWEBHOOK_URLenvironment variable to your public domain (for examplehttps://n8n.yourdomain.com/) and restart. Re-check it after any image or deployment change. - Changes that “don’t apply”. In n8n 2.x, editing and saving a published workflow does not change what production runs until you publish again. This caught us more than once.
- Wrong timestamps. Set
GENERIC_TIMEZONEso dates in your payloads, logs, and Claude prompts match your business hours. - Testing without a public domain. For local development, a tunnel such as ngrok exposes your instance temporarily. n8n Cloud users already have public URLs.
4 Business Workflows You Can Build on This Pattern
1. Lead scoring from contact forms. Webhook → HTTP Request (company enrichment) → LLM Chain with Claude (score 1–10 plus reason, structured output) → IF (hot vs nurture) → CRM update.
2. Support ticket triage. Webhook → Remove Duplicates → LLM Chain with Claude (category, urgency, draft reply) → Switch (by category) → email or Slack to the right team.
3. Payment → onboarding. Payment trigger node → Claude (personalized welcome based on the product bought) → email → CRM contact → team notification. Use the Immediately response mode or the dedicated trigger so the payment provider isn’t kept waiting.
4. Monitoring alert → AI summary. Webhook from your monitoring tool → Claude (summarize the alert and suggest first checks) → Slack. Your team gets a readable summary instead of a raw error dump. Treat Claude’s suggestions as a starting point, not an automatic fix.
Troubleshooting Checklist
- 404 on the webhook: you’re calling the production URL on an unpublished workflow, or the test URL without listening.
- 403: the auth header is missing or doesn’t match the credential.
- Fields are empty in the prompt: you referenced
$json.messageinstead of$json.body.message. - Sender reports a timeout: switch the response mode to Immediately.
- Duplicate emails or records: add Remove Duplicates keyed on a unique event value.
New to calling Claude directly? Our Claude API tutorial covers keys, pricing, and your first request.
Last updated: September 2026.