{
  "name": "Workflow Error Log Alerter to Slack",
  "nodes": [
    {
      "parameters": {},
      "id": "elal0001-0001-4000-8000-000000000001",
      "name": "On Workflow Error",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "e1", "name": "workflow_name", "value": "={{ $json.workflow.name }}", "type": "string" },
            { "id": "e2", "name": "workflow_id", "value": "={{ $json.workflow.id }}", "type": "string" },
            { "id": "e3", "name": "error_message", "value": "={{ $json.execution.error.message }}", "type": "string" },
            { "id": "e4", "name": "error_node", "value": "={{ $json.execution.error.node.name }}", "type": "string" },
            { "id": "e5", "name": "execution_id", "value": "={{ $json.execution.id }}", "type": "string" },
            { "id": "e6", "name": "failed_at", "value": "={{ $now.toISO() }}", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "elal0001-0002-4000-8000-000000000002",
      "name": "Extract Error Details",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [460, 300]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.error_message }}",
              "rightValue": "",
              "operator": { "type": "string", "operation": "notEmpty" }
            }
          ]
        }
      },
      "id": "elal0001-0003-4000-8000-000000000003",
      "name": "Has Error Message?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [680, 300]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": { "__rl": true, "mode": "id", "value": "={{ $env.SLACK_ERRORS_CHANNEL }}" },
        "text": ":x: *Workflow Execution Failed*\n*Workflow:* {{ $json.workflow_name }} (`{{ $json.workflow_id }}`)\n*Failed Node:* {{ $json.error_node }}\n*Error:* {{ $json.error_message }}\n*Execution ID:* {{ $json.execution_id }}\n*Time:* {{ $json.failed_at }}",
        "otherOptions": {}
      },
      "id": "elal0001-0004-4000-8000-000000000004",
      "name": "Post Error to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [900, 220]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": { "__rl": true, "mode": "id", "value": "={{ $env.SLACK_ERRORS_CHANNEL }}" },
        "text": ":warning: *Workflow Failed (no error message)*\n*Workflow:* {{ $json.workflow_name }}\n*Execution ID:* {{ $json.execution_id }}\n*Time:* {{ $json.failed_at }}",
        "otherOptions": {}
      },
      "id": "elal0001-0005-4000-8000-000000000005",
      "name": "Post Generic Error to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [900, 400]
    }
  ],
  "connections": {
    "On Workflow Error": {
      "main": [[{ "node": "Extract Error Details", "type": "main", "index": 0 }]]
    },
    "Extract Error Details": {
      "main": [[{ "node": "Has Error Message?", "type": "main", "index": 0 }]]
    },
    "Has Error Message?": {
      "main": [
        [{ "node": "Post Error to Slack", "type": "main", "index": 0 }],
        [{ "node": "Post Generic Error to Slack", "type": "main", "index": 0 }]
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
