{
  "name": "Nodbot - n8n Error Workflow Telegram alert",
  "nodes": [
    {
      "parameters": {},
      "id": "629c8872-511b-445e-9256-f3e2e2da069f",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const e = $json;\nconst workflow = e.workflow?.name ?? 'Unknown workflow';\nconst executionId = e.execution?.id ?? 'unknown';\nconst node = e.node?.name ?? e.lastNodeExecuted ?? 'unknown node';\nconst message = String(e.error?.message ?? 'Unknown error');\n\nlet severity = 'warning';\nif (/401|403|auth|credential/i.test(message)) severity = 'critical';\nif (/payment|invoice|production|crm/i.test(workflow + ' ' + message)) severity = 'critical';\nif (/429|timeout|ETIMEDOUT|ECONNRESET/i.test(message)) severity = 'warning';\n\nconst dedupeKey = `n8n-error:${workflow}:${node}:${message.replace(/\\d+/g, '#').slice(0, 120)}`;\nconst runbookUrl = `https://nodbot.ru/runbooks/n8n-error-workflow/#${encodeURIComponent(workflow.toLowerCase().replace(/\\s+/g, '-'))}`;\nconst text = [\n  `🚨 n8n ${severity.toUpperCase()}`,\n  `Workflow: ${workflow}`,\n  `Node: ${node}`,\n  `Execution: ${executionId}`,\n  `Error: ${message.slice(0, 500)}`,\n  `Runbook: ${runbookUrl}`\n].join('\n');\n\nreturn [{ json: { severity, dedupe_key: dedupeKey, telegram_text: text, execution_url: e.execution?.url, runbook_url: runbookUrl } }];"
      },
      "id": "c0def7ea-708f-4867-a9a6-95c70c0534b5",
      "name": "Classify severity Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {},
      "id": "edb4836b-b827-408a-89de-89e7b4e92be0",
      "name": "Check dedupe Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {},
      "id": "d1745927-c98b-4ae2-937a-66aff922fa39",
      "name": "Send Telegram alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "fd662774-9d1a-4ce4-89bd-3f3b9d32bb33",
      "name": "Create incident comment",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Classify severity Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify severity Code": {
      "main": [
        [
          {
            "node": "Check dedupe Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check dedupe Postgres": {
      "main": [
        [
          {
            "node": "Send Telegram alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Telegram alert": {
      "main": [
        [
          {
            "node": "Create incident comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "nodbot",
    "production",
    "template"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "d0c904d5-3234-4c09-bf27-28442dfa12b9",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}