{
  "name": "Error Handler - alert the team",
  "nodes": [
    {
      "id": "e1",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "e3",
      "name": "Only alert once per 15 min",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ],
      "parameters": {
        "jsCode": "// Send at most one alert per workflow + failing node every 15 minutes\nconst memory = $getWorkflowStaticData('global');\nconst key = $json.workflow.id + ':' + ($json.execution?.lastNodeExecuted || 'trigger');\nconst now = Date.now();\nif (memory[key] && now - memory[key] < 15 * 60 * 1000) {\n  return []; // already alerted recently: stay quiet\n}\nmemory[key] = now;\nreturn $input.all();"
      }
    },
    {
      "id": "e2",
      "name": "Post alert",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        520,
        0
      ],
      "parameters": {
        "method": "POST",
        "url": "https://hooks.slack.com/services/PASTE/YOUR/WEBHOOK",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: ':rotating_light: ' + $json.workflow.name + ' failed at \"' + $json.execution.lastNodeExecuted + '\": ' + $json.execution.error.message + (\"\\n\" + ($json.execution.url || 'no execution link')) }) }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Only alert once per 15 min",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only alert once per 15 min": {
      "main": [
        [
          {
            "node": "Post alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "note": "From theautomatedshop.com. Import into n8n, paste your Slack incoming-webhook URL into Post alert, then PUBLISH this workflow (n8n 2.x will not run an unpublished error workflow)."
  }
}