{
  "name": "WhatSync: alert when a workflow fails",
  "nodes": [
    {
      "parameters": {},
      "name": "A workflow failed",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "d25f8130-29aa-459c-ad98-7520777cbbfd"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "06e34b19-3946-43cf-a332-851557025a81",
              "name": "alertUrl",
              "value": "https://hooks.slack.com/services/REPLACE/WITH/YOURS",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ],
      "id": "f1bbf9a5-9604-47f6-a0a8-a404e30421bb"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Settings').first().json.alertUrl }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: 'n8n workflow \"' + $json.workflow.name + '\" failed' + ($json.execution && $json.execution.lastNodeExecuted ? ' at \"' + $json.execution.lastNodeExecuted + '\"' : '') + ': ' + (($json.execution && $json.execution.error && $json.execution.error.message) || ($json.trigger && $json.trigger.error && $json.trigger.error.message) || 'unknown error') + ($json.execution && $json.execution.url ? '\\n' + $json.execution.url : '') }) }}",
        "options": {
          "timeout": 15000
        }
      },
      "name": "Alert: workflow failed",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ],
      "id": "8e71d35d-3a3a-4c2b-a19a-a7d84a9dca5a",
      "notes": "Works as is with a Slack incoming webhook. Swap this node for Email, Telegram or anything else that reaches a person."
    },
    {
      "parameters": {
        "content": "## Alert when a workflow fails\nPublish this, then choose it as the **Error workflow** in the settings of every WhatSync workflow (the three dots, Settings). A person hears about a broken step, a wrong signing secret or an expired API key the moment it happens.\n\nGuide: https://whatsync.app/docs/guides/running-unattended#n8n-errors",
        "height": 190,
        "width": 520,
        "color": 4
      },
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -260
      ],
      "id": "b72f7294-e21f-475d-aecc-826446d7a624"
    }
  ],
  "connections": {
    "A workflow failed": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Alert: workflow failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
