AutomationFlowsGeneral › Automated Error Handling with Email Alerts & Smart Workflow Deactivation

Automated Error Handling with Email Alerts & Smart Workflow Deactivation

ByMeelioo @mookielian on n8n.io

This workflow automatically handles errors in your n8n workflows by: Detecting when an error occurs and capturing the error details Sending an email notification with the error message and affected node Allowing you to deactivate the workflow or ignore the error via email…

Event trigger★★★★☆ complexity29 nodesError TriggerEmail Sendn8n
General Trigger: Event Nodes: 29 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #9141 — we link there as the canonical source.

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 →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "599904c4-179d-49e6-8c91-71d144bcaa57",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        96,
        48
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a6cc7c05-0705-44ca-8e8e-458547c35884",
      "name": "Point Out Message & Node",
      "type": "n8n-nodes-base.set",
      "position": [
        288,
        48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c1dacaca-1235-4ed4-b1cd-2d677dc7e3ba",
              "name": "error_message",
              "type": "string",
              "value": "={{ $json.execution.error.message }}"
            },
            {
              "id": "fec582fa-e2d6-4d30-a42c-0a080904ecd7",
              "name": "node_with_error",
              "type": "string",
              "value": "={{ $json.execution.error.lastNodeExecuted }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "13dd8e72-8262-4bf5-9ce2-fd495ae23f85",
      "name": "Send Email & Wait for Response",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        496,
        48
      ],
      "parameters": {
        "message": "=An error has occurred in your workflow with this message: {{ $json.error_message }}\n\nNode: {{ $json.node_with_error }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Error in Workflow",
        "toEmail": "user@example.com",
        "fromEmail": "user@example.com",
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "approveLabel": "Deactivate Workflow",
            "disapproveLabel": "Ignore"
          }
        }
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "86662502-53c7-490e-b1df-3ba15b7ede4a",
      "name": "Deactivate Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        896,
        -48
      ],
      "parameters": {
        "operation": "deactivate",
        "workflowId": {
          "__rl": true,
          "mode": "url",
          "value": "yourworkflows.url"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2c29502d-7d5f-43f0-a25e-a039445d0e2c",
      "name": "If User Deactivates",
      "type": "n8n-nodes-base.if",
      "position": [
        688,
        48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1dcc2e15-b6e4-4037-9079-7207be03095e",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.approved }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2f9d63f8-92c5-4990-815a-03a360148d54",
      "name": "Send Deactivation Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1104,
        -48
      ],
      "parameters": {
        "html": "Workflow deactivated.",
        "options": {
          "appendAttribution": false
        },
        "subject": "Your Workflow Has Been Deactivated",
        "toEmail": "user@example.com",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "07bd009f-0c3c-4ed3-8a97-2b343a91868b",
      "name": "User Ignored",
      "type": "n8n-nodes-base.noOp",
      "position": [
        896,
        144
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "53f516d2-e1af-42e2-a56c-d9c2db6b647d",
      "name": "Inform User & Wait for Response",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        192,
        544
      ],
      "parameters": {
        "message": "=An error has occurred in your workflow with this message: {{ $json.error_message }}\n\nNode: {{ $json.node_with_error }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Error in Workflow",
        "toEmail": "user@example.com",
        "fromEmail": "user@example.com",
        "operation": "sendAndWait",
        "formFields": {
          "values": [
            {
              "fieldType": "checkbox",
              "fieldLabel": "Deactivate Workflow",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Deactivate"
                  }
                ]
              }
            },
            {
              "fieldLabel": "Reroute Error Message",
              "placeholder": "user@example.com"
            }
          ]
        },
        "responseType": "customForm"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "5228cea7-c7c1-4c2e-96d9-b0787d81ccbf",
      "name": "Error Message & Node",
      "type": "n8n-nodes-base.set",
      "position": [
        -16,
        544
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c1dacaca-1235-4ed4-b1cd-2d677dc7e3ba",
              "name": "error_message",
              "type": "string",
              "value": "={{ $json.execution.error.message }}"
            },
            {
              "id": "fec582fa-e2d6-4d30-a42c-0a080904ecd7",
              "name": "node_with_error",
              "type": "string",
              "value": "={{ $json.execution.error.lastNodeExecuted }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5d43f3b5-61ff-4b09-bdee-ee2b068f39b0",
      "name": "User Deactivates",
      "type": "n8n-nodes-base.if",
      "position": [
        384,
        544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1dcc2e15-b6e4-4037-9079-7207be03095e",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json[\"Deactivate\"] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "5ec16de8-63d9-40f7-a429-b46154f4e6a7",
      "name": "Deactivate n8n Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        592,
        448
      ],
      "parameters": {
        "operation": "deactivate",
        "workflowId": {
          "__rl": true,
          "mode": "url",
          "value": "yourworkflow.url"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d86ca663-d34a-4e62-8151-f25e4cfad234",
      "name": "Send Deactivated Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        800,
        448
      ],
      "parameters": {
        "html": "Workflow deactivated.",
        "options": {
          "appendAttribution": false
        },
        "subject": "Your Workflow Has Been Deactivated",
        "toEmail": "user@example.com",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "64e9a5c9-2a97-4f06-97f2-032eb9694d77",
      "name": "Reroute Error Message",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        592,
        656
      ],
      "parameters": {
        "message": "=An error has occurred in shared workflow with this message: {{ $('Error Message & Node').item.json.error_message }}\n------------------------\nNode: {{ $('Error Message & Node').item.json.node_with_error }}\n\nThis is a rerouted error message from previous user.",
        "options": {
          "appendAttribution": false
        },
        "subject": "Error in Shared Workflow",
        "toEmail": "={{ $('Inform User & Wait for Response').item.json[\"Reroute Error Message\"] }}",
        "fromEmail": "user@example.com",
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "approveLabel": "Deactivate",
            "disapproveLabel": "Ignore"
          }
        }
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e08065f3-eee3-48cc-919a-b5f1c1d406a8",
      "name": "Second User Deactivates",
      "type": "n8n-nodes-base.if",
      "position": [
        800,
        656
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1dcc2e15-b6e4-4037-9079-7207be03095e",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.approved }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "55cb8ece-42b1-4565-a3c9-2740f4933df3",
      "name": "Deactivate N8N Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1040,
        544
      ],
      "parameters": {
        "operation": "deactivate",
        "workflowId": {
          "__rl": true,
          "mode": "url",
          "value": "yourworkflow.url"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cdf9f7d2-77da-45df-b36e-e5d588ce8a84",
      "name": "Second User Ignored",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1040,
        752
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d05442b8-a053-4630-a90b-5daae73d89f9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -176
      ],
      "parameters": {
        "color": 5,
        "width": 1520,
        "height": 544,
        "content": "# Basic Template"
      },
      "typeVersion": 1
    },
    {
      "id": "2d56d1f4-1edd-40b9-aec6-385437f0c5f5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        384
      ],
      "parameters": {
        "color": 6,
        "width": 1520,
        "height": 528,
        "content": "# Second Template - Reroute Logic"
      },
      "typeVersion": 1
    },
    {
      "id": "0f949097-a003-4599-881e-ef798cd04055",
      "name": "Send Deactivation Message",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1232,
        544
      ],
      "parameters": {
        "html": "Workflow deactivated.",
        "options": {
          "appendAttribution": false
        },
        "subject": "Your Workflow Has Been Deactivated",
        "toEmail": "user@example.com",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9f6bbbd0-6e72-4f70-b091-ba5e819cd8af",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -176
      ],
      "parameters": {
        "color": 4,
        "width": 464,
        "height": 1696,
        "content": "# Start Using This Workflow\n\n\n\n\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f7de07d8-7f13-454d-a514-28e852b478a7",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        928
      ],
      "parameters": {
        "color": 4,
        "width": 1520,
        "height": 592,
        "content": "# CREDENTIALS"
      },
      "typeVersion": 1
    },
    {
      "id": "e8c8a135-d020-4d19-abbe-e2445cf9a344",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        1008
      ],
      "parameters": {
        "width": 480,
        "height": 480,
        "content": "## SMTP Email Setup\n\n### Gmail (Recommended)\n1. **Get App Password**: Google Account \u2192 Security \u2192 2-Step Verification \u2192 App passwords\n   - Create one named \"n8n\" and save the 16-character password\n2. **Add to n8n**: Settings \u2192 Credentials \u2192 Create New \u2192 \"SMTP\"\n   - **User**: your.email@gmail.com  \n   - **Password**: The app password (not your regular password)\n   - **Host**: smtp.gmail.com | **Port**: 587 | **Security**: STARTTLS\n3. **Apply**: Select this credential in all Email Send nodes and update the email addresses\n\n### Other Providers\n- **Outlook**: smtp-mail.outlook.com, Port 587\n- **Yahoo**: smtp.mail.yahoo.com, Port 587\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4c54d02d-128b-4769-980b-d9ea676779ab",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        1008
      ],
      "parameters": {
        "width": 480,
        "height": 480,
        "content": "## n8n API Setup\n\n1. **Create Token**: Settings \u2192 Personal API tokens \u2192 Create API token\n   - Name it \"Error Handler\" and **copy the token immediately**\n2. **Add Credential**: Settings \u2192 Credentials \u2192 Create New \u2192 \"n8n\"\n   - **API Key**: Paste your token\n   - **Base URL**: Your n8n instance URL (e.g., https://your-instance.n8n.cloud)\n3. **Update Workflow IDs**: In each \"Deactivate\" node, change \"yourworkflows.url\" to the actual workflow ID you want to monitor\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0b9b7a2a-02fb-411b-9184-f695a9c6d27c",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        1008
      ],
      "parameters": {
        "width": 464,
        "height": 480,
        "content": "## Quick Test\nSend yourself a test email using an Email Send node to verify SMTP works, then test the n8n API by listing your workflows.\n\n## Common Issues\n- **Gmail not working?** Use App Password, not regular password\n- **Can't deactivate workflows?** Check your API token has write permissions\n- **Wrong workflow being deactivated?** Verify the workflow ID in the n8n nodes\n\n## Links\n- [SMTP Setup Guide](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.emailsend/)\n- [n8n API Guide](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.n8n/)"
      },
      "typeVersion": 1
    },
    {
      "id": "3b74a6cd-f618-4e53-a310-511a1d59bc37",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -96
      ],
      "parameters": {
        "width": 432,
        "height": 288,
        "content": "## Choose Your Template\nThe workflow includes two options:\n- **Basic Template (Top)**: Simple Deactivate/Ignore choice via email\n- **Advanced Template (Bottom)**: Adds rerouting to another person + custom form\n\nPick one and delete the other nodes to keep things clean."
      },
      "typeVersion": 1
    },
    {
      "id": "924a90d1-b86e-4890-92f1-69cf9c973bbd",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        208
      ],
      "parameters": {
        "width": 432,
        "height": 272,
        "content": "## Connect to Your Target Workflow\n1. **Import this error handler** into your n8n instance\n2. **Open your main workflow** (the one that might fail)\n3. **Add Error Trigger connection**: \n   - Go to workflow settings \u2192 Error Workflow\n   - Select this error handling workflow from the dropdown\n4. **Update the workflow IDs** in the \"Deactivate\" nodes to point to your main workflow\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a958f2cf-e7d3-45da-9e34-194854215afd",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        496
      ],
      "parameters": {
        "width": 432,
        "height": 352,
        "content": "## Activate and Test\n1. **Activate your main workflow with a temporary cron trigger**\n2. **Create a test failure** in your main workflow:\n   - Add a temporary HTTP node with invalid URL like `https://fake-url-that-fails.com`\n   - Or use a Set node with invalid expression like `{{ $invalidReference }}`\n3. **Let your main workflow run automatically** - it should fail and trigger the error handler\n4. **Check your email** and test both response options\n5. **Remove the test failure** once everything works\n"
      },
      "typeVersion": 1
    },
    {
      "id": "937a74ca-c5da-4301-9423-a1d2ce714540",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        864
      ],
      "parameters": {
        "width": 432,
        "height": 320,
        "content": "## What Happens When Errors Occur\n1. Your main workflow fails \u2192 Error handler automatically runs\n2. You get an email with error details and response options\n3. **If you choose \"Deactivate\"**: Workflow stops, you get confirmation email\n4. **If you choose \"Ignore\"**: Workflow stays active (error was temporary/acceptable)\n5. **Advanced template**: You can forward the decision to someone else via email\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f47e91a4-547b-408a-ac0b-6b20807a4910",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        1200
      ],
      "parameters": {
        "width": 432,
        "height": 288,
        "content": "## Pro Tips\n- **Test with non-critical workflows first** to get familiar with the process\n- **Set up email filters** to ensure error notifications don't go to spam\n- **Use the rerouting feature** for shared workflows where multiple people should be able to handle errors\n- **Monitor your email** - some errors need immediate attention while others can wait"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Point Out Message & Node",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "User Deactivates": {
      "main": [
        [
          {
            "node": "Deactivate n8n Workflow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reroute Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deactivate Workflow": {
      "main": [
        [
          {
            "node": "Send Deactivation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If User Deactivates": {
      "main": [
        [
          {
            "node": "Deactivate Workflow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "User Ignored",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Message & Node": {
      "main": [
        [
          {
            "node": "Inform User & Wait for Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reroute Error Message": {
      "main": [
        [
          {
            "node": "Second User Deactivates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deactivate N8N Workflow": {
      "main": [
        [
          {
            "node": "Send Deactivation Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deactivate n8n Workflow": {
      "main": [
        [
          {
            "node": "Send Deactivated Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Second User Deactivates": {
      "main": [
        [
          {
            "node": "Deactivate N8N Workflow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Second User Ignored",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Point Out Message & Node": {
      "main": [
        [
          {
            "node": "Send Email & Wait for Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email & Wait for Response": {
      "main": [
        [
          {
            "node": "If User Deactivates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inform User & Wait for Response": {
      "main": [
        [
          {
            "node": "User Deactivates",
            "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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow automatically handles errors in your n8n workflows by: Detecting when an error occurs and capturing the error details Sending an email notification with the error message and affected node Allowing you to deactivate the workflow or ignore the error via email…

Source: https://n8n.io/workflows/9141/ — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Error N8N. Uses errorTrigger, n8n. Event-driven trigger; 3 nodes.

Error Trigger, n8n
General

Sometimes you want to take a different action in your error workflow based on the data that was flowing through it.

Error Trigger, n8n
General

Notify-On-Error. Uses errorTrigger, emailSend. Event-driven trigger; 5 nodes.

Error Trigger, Email Send
General

Using n8n a lot?

Execute Workflow Trigger, XML, Move Binary Data +1
General

Perfect for content publishing with organic scheduling patterns, social media automation, API systems that need to avoid rate limiting, or any automation requiring randomised timing control across mul

n8n, Read Write File, Stop And Error +1