n8n agentic webhook with Claude
Trigger an LLM workflow from any webhook — drop-in node config plus the prompt that actually works.
n8n + Claude is the fastest way to put an LLM behind any business event — Stripe charge, Calendly booking, GitHub PR opened, support email landed. The trick is keeping the Anthropic call deterministic enough to wire into approval chains.
The workflow
Webhook → Set (build prompt) → Anthropic (Claude) → Switch (route) → [Slack | Gmail | DB]
Anthropic node config
| Field | Value |
|---|---|
| Model | claude-opus-4-7 |
| Operation | Message |
| System | Pasted from below; mark cache_control: ephemeral if your n8n version supports it |
| Tool choice | none (we want pure JSON) |
| Max tokens | 512 |
| Temperature | 0.2 |
System prompt
You triage incoming support emails. Output JSON ONLY:
{
"category": "billing" | "bug" | "feature_request" | "refund" | "other",
"urgency": "low" | "medium" | "high",
"summary": string (max 200 chars),
"suggested_reply": string (max 600 chars, friendly tone),
"needs_human": boolean
}
Set needs_human=true for: refunds > $500, legal threats, security issues, anything outside the categories.
Switch node
Three outputs based on {{ $json.message.content[0].text }} parsed:
needs_human === true→ Slack to#support-escalationscategory === "bug"→ GitHub Issue (via the GitHub node)- otherwise → Gmail draft with
suggested_reply
Patterns that scale
- Pin a model version.
claude-opus-4-7notclaude-3-5-sonnet. Workflow drift from auto-bumped models is a real issue. - Always parse JSON in a Function node before Switch. n8n's expression engine choking on stringified JSON is a top cause of false routes.
- Add a Wait node between LLM and side-effects in approval chains. Lets a human catch a bad classification.
- Log usage to a Postgres node.
input_tokens,cache_read_input_tokens,output_tokens— track these per workflow ID; you'll find the runaway loop on day three.