{
  "name": "Zero-Cost Social Pipeline Error Handler (M6)",
  "nodes": [
    {
      "parameters": {},
      "id": "node-error-trigger-01",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ 'https://api.telegram.org/bot' + $env.TELEGRAM_BOT_TOKEN + '/sendMessage' }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ chat_id: Number($env.TELEGRAM_CHAT_ID) || $env.TELEGRAM_CHAT_ID, text: 'Social pipeline FAILED\\nWorkflow: ' + ($json.workflow ? $json.workflow.name : 'unknown') + '\\nNode: ' + ($json.execution ? $json.execution.lastNodeExecuted : 'unknown') + '\\nError: ' + ($json.execution && $json.execution.error ? $json.execution.error.message : 'unknown') + '\\nExecution: ' + ($json.execution ? $json.execution.url : 'unknown') }) }}",
        "options": {}
      },
      "id": "node-notify-failure-02",
      "name": "NotifyFailure",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        400,
        0
      ],
      "notes": "Sends the failure notification via the Telegram Bot API directly using the bot token from the n8n environment. chat_id comes from TELEGRAM_CHAT_ID."
    },
    {
      "parameters": {
        "jsCode": "const item = $input.first().json;\nreturn [{\n  json: {\n    ...item,\n    logged: true\n  }\n}];"
      },
      "id": "node-log-error-03",
      "name": "LogErrorToFile",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        800,
        0
      ],
      "notes": "Pass-through node: n8n's code-node sandbox disallows fs, so failure details are surfaced only in the Telegram alert (NotifyFailure)."
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "NotifyFailure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NotifyFailure": {
      "main": [
        [
          {
            "node": "LogErrorToFile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "active": false,
  "versionId": "b2c3d4e5f6071829",
  "tags": [],
  "id": 2
}