This workflow corresponds to n8n.io template #9375 — we link there as the canonical source.
This workflow follows the Agent → Error Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "58ba08d1-782a-40ae-b332-39487660a563",
"name": "Error Trigger",
"type": "n8n-nodes-base.errorTrigger",
"position": [
0,
0
],
"parameters": {},
"typeVersion": 1
},
{
"id": "60b131bb-608d-4298-b4e6-b6a6bd505bd2",
"name": "Get Workflow JSON",
"type": "n8n-nodes-base.httpRequest",
"position": [
208,
0
],
"parameters": {
"url": "={{`${$env.N8N_EDITOR_BASE_URL}/api/v1/workflows/${$json.workflow.id}`}}",
"options": {
"response": {
"response": {
"responseFormat": "json"
}
}
},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "5113ff05-a43f-412b-be2f-f6464b13af23",
"name": "Debugger Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
416,
0
],
"parameters": {
"text": "=A workflow has failed. Here is the data:\n\n## Error Details\n- **Workflow Name:** {{ $json.name }}\n- **Failed Node Name:** {{ $('Error Trigger').item.json.execution.error.node.name }}\n- **Failed Node Type:** {{ $('Error Trigger').item.json.execution.error.node.type }}\n- **Error Message:** {{ $('Error Trigger').item.json.execution.error.message }}\n\n## Full Workflow Structure (JSON)\n\n{{ JSON.stringify($('Get Workflow JSON').item.json) }}\n\n---\n\nBased on all the information above, please provide the following in markdown format:\n\n### Root Cause Analysis:\nA 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.\n\n### Suggested Fix:\nProvide 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.\n",
"options": {
"systemMessage": "=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."
},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"id": "a702d4eb-ede5-4ec1-bf8b-3b5fdd7f8417",
"name": "Convert Markdown To HTML",
"type": "n8n-nodes-base.markdown",
"position": [
768,
0
],
"parameters": {
"mode": "markdownToHtml",
"options": {},
"markdown": "={{ $json.output }}",
"destinationKey": "responseHtml"
},
"typeVersion": 1
},
{
"id": "6d8c5c9a-9a34-4e2e-8f19-3448dfedcea1",
"name": "Send Debugging Email",
"type": "n8n-nodes-base.gmail",
"position": [
976,
0
],
"parameters": {
"sendTo": "EMAIL-GOES-HERE",
"message": "=<p>Hello, there has been an error in a workflow. Please check below for details:</p>\n\n<ul>\n <li><strong>Direct Link To Affected Execution:</strong> <a href=\"{{ `${$env.N8N_EDITOR_BASE_URL}/workflow/${$('Error Trigger').item.json.workflow.id}/executions/${$('Error Trigger').item.json.execution.id}` }}\">{{ `${$env.N8N_EDITOR_BASE_URL}/workflow/${$('Error Trigger').item.json.workflow.id}/executions/${$('Error Trigger').item.json.execution.id}` }}</a></li>\n <br>\n <li><strong>Name Of Affected Node:</strong> {{ $('Error Trigger').item.json.execution.error.node.name }} </li>\n <br>\n <li><strong>Type Of Affected Node:</strong> {{ $('Error Trigger').item.json.execution.error.node.type }}</li>\n <br>\n <li><strong>Error Message:</strong> {{ $('Error Trigger').item.json.execution.error.message }}</li>\n</ul>\n\n<hr>\n\n<h2>\ud83e\udd16 AI Debugging Assistant Analysis:</h2>\n\n{{ $json.responseHtml }}",
"options": {},
"subject": "=N8N Automation Error (Workflow: {{ $('Get Workflow JSON').item.json.name }})"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "c5164ca2-2945-47d3-a861-7cec54f6d317",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-96,
-384
],
"parameters": {
"color": 3,
"width": 448,
"height": 336,
"content": "### Stage 1: Capture Error & Fetch Context\n\n- **Error Trigger:** This is the entry point. It activates whenever another workflow in your n8n instance fails.\n- **Get Workflow JSON:** As soon as an error is detected, this node uses the n8n API to fetch the complete JSON structure of the failed workflow. This gives the AI the full context of how the nodes are connected and configured.\n\n*Setup Note: You must create an n8n API key in `Settings > API` and create a new header auth credential under \"Generic Credential\". \n\n**Name:** `X-N8N-API-KEY`\n**Value:** API-KEY"
},
"typeVersion": 1
},
{
"id": "1e0ca912-cb86-4d33-a023-08c9d7f886fb",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
352
],
"parameters": {
"width": 512,
"height": 256,
"content": "### Stage 2: AI Root Cause Analysis\n\n- **Debugger Agent:** This is the brain of the operation. It takes the error details (like the error message and the failed node's name) and the full workflow JSON and sends it to a powerful language model.\n- **System Prompt:** The agent is given a specific instruction: \"You are an expert n8n automation developer and debugger.\" This focuses the AI on providing a technical, actionable analysis.\n- **AI Model:** This template uses an OpenRouter Chat Model, giving you the flexibility to choose from various models like Gemini, GPT-4, etc., to perform the analysis."
},
"typeVersion": 1
},
{
"id": "a35e220b-9226-48de-9067-87d00b3b7074",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
-352
],
"parameters": {
"color": 4,
"width": 384,
"height": 272,
"content": "### Stage 3: Format and Notify\n\n- **Convert Markdown to HTML:** The AI provides its analysis in Markdown format for readability. This node converts that Markdown into HTML so it can be beautifully rendered in an email.\n- **Send Debugging Email:** The final, formatted report\u2014containing the AI's analysis, the original error message, and a direct link to the failed execution\u2014is sent to your specified email address via Gmail."
},
"typeVersion": 1
},
{
"id": "582caabd-865d-4306-9f45-bac571ef1df0",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1312,
-208
],
"parameters": {
"color": 5,
"width": 704,
"height": 784,
"content": "## Common Errors & Resolutions\n\nHere are some common issues you might encounter when setting up or running this workflow and how to resolve them.\n\n| Error Message Snippet | Likely Cause | Resolution |\n| :--- | :--- | :--- |\n| `401 Unauthorized` or `Authentication failed` on **\"Get Workflow JSON\"** node | The n8n API key is either missing, incorrect, or expired. | 1. Go to **Settings > API** in your n8n instance. <br> 2. Create a new API key if you don't have one. <br> 3. Copy the key. <br> 4. In the **\"Get Workflow JSON\"** node, go to the **\"Headers\"** tab and paste the key into the `Value` field for `X-N8N-API-KEY`. |\n| `Cannot read properties of undefined (reading 'workflow')` or URL is `undefined/api/...` | The `N8N_EDITOR_BASE_URL` environment variable is not set in your n8n instance. This is required for building the correct API and execution URLs. | 1. You need to set this environment variable for your n8n instance. The value should be your n8n editor's root URL (e.g., `https://my-n8n.example.com`). <br> 2. The method varies depending on how you host n8n (Docker, n8n Cloud, etc.). Refer to the official n8n documentation for setting environment variables. |\n| `401` or `Invalid API Key` on **\"OpenRouter Chat Model\"** node | Your OpenRouter API key is incorrect or has not been configured in the credentials. | 1. Go to your OpenRouter account and get your API key. <br> 2. In the n8n workflow, open the **\"OpenRouter Chat Model\"** node. <br> 3. In the **\"Credentials\"** field, select your configured OpenRouter account or create a new one by pasting in your API key. |\n| `Request failed with status code 403` or `invalid_grant` on **\"Send Debugging Email\"** node | The Gmail API (OAuth2) credentials are not set up correctly, or the authentication token has expired and needs to be reauthorized. | 1. Open the **\"Send Debugging Email\"** node. <br> 2. In the **\"Credentials\"** field, reconnect your Gmail account. You may need to go through the Google authentication flow again. <br> 3. Ensure the correct Google account is selected. |"
},
"typeVersion": 1
},
{
"id": "e62ff584-f0a0-451f-b547-845abc8fc755",
"name": "Gemini 2.5 Pro",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
"position": [
288,
208
],
"parameters": {
"model": "google/gemini-2.5-pro",
"options": {}
},
"credentials": {
"openRouterApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "2294e2f4-cf86-4a75-a474-8aefe88c6294",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1552,
-384
],
"parameters": {
"color": 7,
"width": 1328,
"height": 896,
"content": "# Watch Video Walkthrough On YouTube\n\n@[youtube](80m0ebb2_1Q)"
},
"typeVersion": 1
},
{
"id": "829f5375-f6d3-4dca-bb71-973f42bffe94",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
288,
-944
],
"parameters": {
"color": 5,
"width": 784,
"height": 256,
"content": "## Overview\n\nStop digging through execution logs to find out why a workflow failed. This template provides a \"set-it-and-forget-it\" monitoring system that uses AI to automatically debug your n8n workflows.\n\nInstead of just getting a simple error message, you'll receive a detailed email notification with a **root cause analysis** and a **step-by-step suggested fix** from a Gemini-powered AI agent. This saves you valuable time, helps you resolve issues faster, and ensures your critical automations are always running smoothly."
},
"typeVersion": 1
}
],
"connections": {
"Error Trigger": {
"main": [
[
{
"node": "Get Workflow JSON",
"type": "main",
"index": 0
}
]
]
},
"Debugger Agent": {
"main": [
[
{
"node": "Convert Markdown To HTML",
"type": "main",
"index": 0
}
]
]
},
"Gemini 2.5 Pro": {
"ai_languageModel": [
[
{
"node": "Debugger Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Get Workflow JSON": {
"main": [
[
{
"node": "Debugger Agent",
"type": "main",
"index": 0
}
]
]
},
"Convert Markdown To HTML": {
"main": [
[
{
"node": "Send Debugging Email",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2httpHeaderAuthopenRouterApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Stop digging through execution logs to find out why a workflow failed. This template provides a "set-it-and-forget-it" monitoring system that uses AI to automatically debug your n8n workflows.
Source: https://n8n.io/workflows/9375/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Who is this for? Agencies, consultants, and service providers who conduct discovery calls and need to quickly turn conversations into professional proposals.
This workflow is designed for e-commerce, marketing teams, or creators who want to automate the production of high-quality, AI-generated product visuals and ad creatives.
This workflow implements an AI-powered WhatsApp booking assistant for a hair salon. The system allows customers to book, reschedule, or cancel appointments automatically via text or voice messages on
This workflow contains community nodes that are only compatible with the self-hosted version of n8n.
The Shopify AI Product Description Factory is a production-grade n8n workflow that converts product images and metadata into refined, SEO-aware descriptions—fully automated and region-agnostic. It ble