Error Handling & Idempotency in n8n
Real automations fail: APIs time out, models return malformed JSON, webhooks fire twice.
The prompt
Return ONLY valid JSON: {"category": string, "reply": string, "confidence": number 0-1}. If you cannot classify confidently, set category to "unknown" and confidence below 0.5. Never add text outside the JSON.
Input: {{$json.body}}What to replace
Swap these placeholders for your own details before running the prompt:
{{$json.body}}your own value
Pro tip: Route confidence < 0.7 to a human-review branch. The 10% of cases you don't automate protect the reputation of the 90% you do.
How to use this prompt
- Copy the prompt using the button above.
- Replace {{$json.body}} with your own details — the more specific you are, the better the output.
- Paste it into ChatGPT (inside n8n) and run it.
- If the answer feels generic, add constraints: audience, length, tone, and what to avoid. That single change fixes most weak output.
Learn the technique
Error Handling & Idempotency in n8n
Module 3 — Advanced: Reliable Production Workflows · AI Automation with n8n
Related prompts
Connecting an LLM to n8n
n8n connects to AI models either through dedicated nodes (OpenAI, Anthropic community nodes) or a generic HTTP Request node calling any model's API.
ChatGPT (inside n8n)Auto Content Repurposing Pipeline
Trigger: new blog post published (RSS or webhook) -> AI node: generate a Twitter/X thread, LinkedIn post, and email blurb from the article -> Route each to the right channel.
Claude (inside n8n)AI Email Triage & Auto-Responder
Trigger: new email in inbox -> AI node classifies intent (support, sales, spam, urgent) -> conditional branches route to auto-reply, Slack alert, or human queue..
Claude (inside n8n)Human-in-the-Loop Approval Gates
The highest-trust automations pause for approval at the moments that matter: before sending externally, before spending money, before deleting anything.
Any modelProject: Your First Production n8n Workflow
Deliverable: one n8n workflow, running on a schedule or trigger, that saves you real time every week. Steps: 1.
n8n + ChatGPTWeekly Automation Digest
Automated weekly team update via n8n + Slack
Topics
Related across the site
AI Automation with n8n
Connect AI models to real workflows using n8n — the open-source automation tool. Learn the HTTP Request and AI Agent nodes, and build automations that run on a schedule or trigger.
Human in the loop
Human in the loop means inserting a person at decision points in an automated workflow — typically to approve consequential actions or review low-confidence outputs before they take effect.
n8n and AI: Build Your First Real Automation
A practical walkthrough of wiring an AI model into an n8n workflow — the node structure, the prompt that makes it reliable, and three automations worth building first.
Loop Budgets and Failure Handling
Production loops need budgets (max iterations, max cost, max time) and explicit failure paths: what happens when the Reviewer fails a result three times? Options: escalate to a human, fall back to a simpler method, or return a partial result flagged as unverified.
AI Email Triage & Auto-Responder
Trigger: new email in inbox -> AI node classifies intent (support, sales, spam, urgent) -> conditional branches route to auto-reply, Slack alert, or human queue..
Auto Content Repurposing Pipeline
Trigger: new blog post published (RSS or webhook) -> AI node: generate a Twitter/X thread, LinkedIn post, and email blurb from the article -> Route each to the right channel.