{
  "name": "Content Pipeline Error Handler \u2014 Slack Alert",
  "nodes": [
    {
      "parameters": {},
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        240,
        304
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const e = $json;\nconst wf = e.workflow || {};\nconst err = e.execution || {};\nconst lastNode = err.lastNodeExecuted || \"unknown\";\nconst mode = err.mode || \"unknown\";\nconst errMsg = (err.error && err.error.message) ? err.error.message : \"(no message)\";\n// Point this at your own n8n instance so the alert deep-links to the failed run.\nconst N8N_BASE_URL = \"https://YOUR-INSTANCE.app.n8n.cloud\";\nconst execUrl = N8N_BASE_URL + \"/workflow/\" + wf.id + \"/executions/\" + (err.id || \"\");\nconst title = \"\ud83d\udea8 n8n error: \" + (wf.name || \"unknown\");\nconst body = [\n  \"*Workflow:* \" + (wf.name || wf.id),\n  \"*Failed node:* \" + lastNode,\n  \"*Mode:* \" + mode,\n  \"*Error:* ```\" + errMsg.substring(0, 500) + \"```\",\n  \"*Execution:* \" + execUrl\n].join(\"\\n\");\nreturn { json: { title, body, exec_url: execUrl } };"
      },
      "name": "Format Message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        464,
        304
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "REPLACE_WITH_CHANNEL_ID",
          "mode": "list",
          "cachedResultName": ""
        },
        "text": "={{ $json.title }}\n\n{{ $json.body }}\n\n<{{ $json.exec_url }}|Open execution in n8n>",
        "otherOptions": {
          "includeLinkToWorkflow": false,
          "mrkdwn": true
        }
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.4,
      "position": [
        720,
        304
      ],
      "name": "Send a message",
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Format Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Message": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}