HOW-TO

How to alert on failed n8n workflow executions

Published · Updated

Code

Import this JSON into n8n (Workflows > Import from File). Replace YOUR_ALERT_WEBHOOK with the incoming webhook path of your chat or alerting tool.

json
{
  "name": "Alert on failed executions",
  "nodes": [
    {
      "parameters": {},
      "id": "a1111111-1111-4111-8111-111111111111",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b2222222-2222-4222-8222-222222222222",
              "name": "text",
              "value": "=Workflow {{ $json.workflow.name }} failed at node {{ $json.execution.lastNodeExecuted }}: {{ $json.execution.error.message }} ({{ $json.execution.url }})",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "c3333333-3333-4333-8333-333333333333",
      "name": "Build Alert",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [220, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://example.com/YOUR_ALERT_WEBHOOK",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: $json.text }) }}",
        "options": {}
      },
      "id": "d4444444-4444-4444-8444-444444444444",
      "name": "Send Alert",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [440, 0]
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [[{ "node": "Build Alert", "type": "main", "index": 0 }]]
    },
    "Build Alert": {
      "main": [[{ "node": "Send Alert", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" }
}

Why it happens

When a node fails, n8n stops the execution and marks it as failed. It does not notify anyone by default, so the failure is only visible in the Executions list. An Error Trigger workflow is the hook n8n calls after a failed execution. It receives the workflow name, the failing node, the error message and a link to the execution.

Steps

  1. Import the JSON above and save it. It does not need to be activated.
  2. Open the Send Alert node and replace the placeholder URL with your own alert webhook.
  3. Open each workflow you want to watch. Go to Settings > Error Workflow and choose "Alert on failed executions".
  4. Let a watched workflow fail in a production run (schedule or webhook). The alert workflow starts with the error details.
  5. Alternative, inside one workflow: set the risky node's On Error option to Continue (older versions: Continue On Fail). Add an IF node after it that checks whether {{ $json.error }} exists. Send the alert from the true branch.

Pitfalls

  • The Error Workflow does not run for manual test executions. It only runs for automatic runs started by a trigger.
  • If the watched workflow fails in its own trigger node, the data arrives under trigger instead of execution. execution.url may then be empty, so adjust the expressions for that case.
  • With Continue on error, the execution counts as successful. The Error Workflow will not fire, so the IF branch is your only alert.
  • Keep webhook URLs with tokens in n8n credentials or environment variables. Do not share exported workflows that contain them.

Seen on: Own project ·

Related service: n8n, Make and Zapier workflow automation