n8n Workflow Auto Error Analysis & AI Fix Suggestions
Capture failures with Error Trigger → fetch workflow structure via n8n API → send to AI Agent through OpenRouter for root-cause analysis and fix steps → convert to HTML email and send via Gmail
- Who
- Operators or developers using n8n who need to monitor production workflow failures
- You get
- Automatically receive an email with AI root-cause analysis and step-by-step fix suggestions whenever a monitored n8n workflow fails during a production execution
Constraints
Prerequisites: an accessible n8n instance; N8N_EDITOR_BASE_URL environment variable configured; n8n API Key (generated under Settings > API); OpenRouter account and API Key; Google Gmail account (OAuth2 authorization). Cost: OpenRouter pay-per-call; Gmail API has a free tier. Limitations: Error Trigger only fires on automatic/production executions; manual "Execute workflow" clicks do not trigger it. Target workflows must be active.
What they did
Author informed-simplicity published a monitoring template on the n8n marketplace. The template leverages n8n's Error Trigger mechanism: when another workflow fails during a production execution, it automatically fetches the failed workflow's full JSON structure via the n8n API, sends the error details and workflow structure through OpenRouter to an AI Agent (defaulting to Gemini 2.5 Pro) for root-cause analysis and fix suggestions, then converts the result to HTML and emails it via Gmail to a specified recipient.
How it went
The author claims (author_report) that the template saves time digging through logs, helps resolve issues faster, and ensures critical automations run smoothly. The template has 1,904 views on n8n.io.
Worth knowing
1) Error Trigger only fires on production (automatic) executions; manual "Execute workflow" clicks do not trigger it. 2) Target workflows must be active to trigger the error workflow. 3) Common issues: 401 (missing or incorrect n8n API Key), N8N_EDITOR_BASE_URL not set causing undefined URLs, invalid OpenRouter API Key, expired Gmail OAuth2 requiring re-authorization. 4) This site has not imported or run the template (reproduction=not_tested); effects are author-reported. 5) Execution links in emails depend on N8N_EDITOR_BASE_URL; additional verification is needed if using subpaths or reverse proxies.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- Get Workflow JSON node: connect HTTP Header Auth credentials.
- Send Debugging Email node: connect Gmail OAuth2 credentials.
- Gemini 2.5 Pro node: connect openRouterApi credentials.
Configuration to replace
- Source template is n8n public workflow #9375 (~12 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-24
Steps
Prepare environment and credentials
Complete the following prerequisites in your n8n instance: 1) Go to Settings > API and generate an API Key; 2) Ensure the instance has the N8N_EDITOR_BASE_URL environment variable set to your editor root URL (e.g., https://your-n8n.example.com); 3) Sign up for OpenRouter and obtain an API Key; 4) Prepare a Gmail account for OAuth2 authorization to send emails; 5) Confirm the recipient email address.
Import template and confirm Error Trigger
Import this template from the n8n template marketplace. The first node is Error Trigger, the entry point that automatically activates when another workflow in your instance fails during a production execution. No additional parameters are required for this node.
Configure Get Workflow JSON node
Open the "Get Workflow JSON" node (HTTP Request type). The URL is pre-filled with the expression: ={{`${$env.N8N_EDITOR_BASE_URL}/api/v1/workflows/${$json.workflow.id}`}}. In Credentials, select or create a "Generic Credential" of type httpHeaderAuth, set Header Name to X-N8N-API-KEY, and Value to your n8n API Key. Keep Response Format as JSON.
Setup guidance · Source text。Headers configuration of the Get Workflow JSON node; Generic Credential httpHeaderAuth
**Name:** `X-N8N-API-KEY` **Value:** API-KEY
Configure Debugger Agent and AI model
Open the "Debugger Agent" node (AI Agent type) with promptType set to define. In the Model connection, select "Gemini 2.5 Pro" (OpenRouter Chat Model) and configure the openRouterApi credential in that model node. Then enter the following prompts:
Execution prompt · Source text。Debugger Agent node Text (user prompt) field
=A workflow has failed. Here is the data: ## Error Details - **Workflow Name:** {{ $json.name }} - **Failed Node Name:** {{ $('Error Trigger').item.json.execution.error.node.name }} - **Failed Node Type:** {{ $('Error Trigger').item.json.execution.error.node.type }} - **Error Message:** {{ $('Error Trigger').item.json.execution.error.message }} ## Full Workflow Structure (JSON) {{ JSON.stringify($('Get Workflow JSON').item.json) }} --- Based on all the information above, please provide the following in markdown format: ### Root Cause Analysis: A brief explanation of what likely caused this specific error in the context of the workflow. Analyze the failed node and the nodes that feed data into it. ### Suggested Fix: Provide clear, step-by-step instructions on how to fix the issue in the n8n editor. Be specific. For example, if it's a rate limit, suggest adding a "Wait" node. If it's a data mapping error, explain which expression is likely wrong.Execution prompt · Source text。Debugger Agent node System Message field
=You are an expert n8n automation developer and debugger. Your task is to analyze a workflow error and provide a clear, actionable diagnosis and solution. Do not be conversational; provide the analysis directly in markdown.
Configure email formatting and delivery
Open the "Convert Markdown To HTML" node, keep mode as markdownToHtml, set markdown to ={{ $json.output }}, and destinationKey to responseHtml. Then open the "Send Debugging Email" node (Gmail type): set sendTo to your recipient email; use the expression =N8N Automation Error (Workflow: {{ $('Get Workflow JSON').item.json.name }}) for subject; keep the template HTML expression for message, which includes a direct link to the failed execution, the affected node name and type, the error message, and the AI analysis result {{ $json.responseHtml }}. Configure gmailOAuth2 in Credentials.
Link target workflows and activate
For each workflow you want to monitor: 1) Open the target workflow; 2) Click the "⋯" menu in the top right and select Settings; 3) In the Error Workflow dropdown, select this "AI-Powered Workflow Debugger & Notifier" workflow; 4) Click Save; 5) Ensure the target workflow is Active. Note: Error Trigger only fires on automatic executions (e.g., webhook or schedule), not on manual tests.
Prompt you can copy
Setup guidance · Editorial suggestion。Hand to setup assistant; confirm inputs and permissions first, then verify nodes and credentials step by step
This block is the prompt. Ads are never placed here.
You are a setup assistant for an n8n automated debugging workflow. The user will import a template that automatically analyzes n8n workflow production failures using AI and sends an email report. Assist the user in this order: 1) Confirm readiness of n8n instance, N8N_EDITOR_BASE_URL, API Key, OpenRouter Key, and Gmail OAuth2; 2) Guide template import and verify the node chain: Error Trigger → Get Workflow JSON → Debugger Agent → Convert Markdown To HTML → Send Debugging Email; 3) Help fill in the Debugger Agent prompts and model credentials; 4) Instruct binding this debugger workflow in each target workflow's Settings > Error Workflow, then activate. Do not generate or send credentials on behalf of the user.
Confirm the 5 prerequisites first, then verify the 6 configuration steps one by one, and finally test whether a target workflow's automatic execution triggers the email.
Source
AI-powered workflow error analysis & fix suggestions with Gemini 2.5 Pro · informed-simplicity · n8n.io · 2025-10-08
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.