{
  "id": "SpeedToLeadError",
  "name": "Speed to Lead: error handler",
  "nodes": [
    {
      "id": "db765286-c9d4-4615-b4ac-491281235148",
      "parameters": {},
      "name": "Something broke",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "id": "7bda3581-c26c-4b8a-b954-bf0a8928e151",
      "parameters": {
        "jsCode": "// Build the owner alert from what the Error Trigger hands us.\nconst d = $json;\nconst msg = (d.execution && d.execution.error && d.execution.error.message) || 'unknown error';\nconst parts = msg.split(' || LEAD: ');\nconst what = parts[0];\nconst lead = parts[1];\nconst text =\n  '⚠️ SPEED TO LEAD BROKE\\n' +\n  what + '\\n\\n' +\n  'Lead: ' + (lead || 'not captured (it failed before the form was read)') + '\\n\\n' +\n  'Workflow: ' + ((d.workflow && d.workflow.name) || '?') + '\\n' +\n  'Run: ' + ((d.execution && (d.execution.url || d.execution.id)) || '?');\nreturn [{ json: { text } }];"
      },
      "name": "Build the alert",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        300
      ]
    },
    {
      "id": "2bf11c08-442d-438f-95eb-bb6770684f27",
      "parameters": {
        "chatId": "__TELEGRAM_CHAT_ID__",
        "text": "={{ $json.text }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "name": "Tell the owner",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        440,
        300
      ],
      "credentials": {
        "telegramApi": {
          "id": "SpeedToLeadTeleg",
          "name": "Speed to Lead - Telegram"
        }
      }
    },
    {
      "id": "cd18d2dc-21ad-4c85-a7bd-101dbc8fd606",
      "parameters": {
        "content": "## Speed to Lead: error handler\nSet as the error workflow of **Speed to Lead**. Fires on any failed run and sends the owner which node broke, the error, and the lead itself when the main workflow attached it.",
        "height": 160,
        "width": 460
      },
      "name": "About",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        60
      ]
    }
  ],
  "connections": {
    "Something broke": {
      "main": [
        [
          {
            "node": "Build the alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build the alert": {
      "main": [
        [
          {
            "node": "Tell the owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "America/Denver"
  },
  "active": false
}
