{
  "name": "AI Digest \u2014 Error Handler",
  "nodes": [
    {
      "parameters": {},
      "id": "err-trigger",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        400,
        400
      ]
    },
    {
      "parameters": {
        "language": "javaScript",
        "jsCode": "const e = $json.execution || {};\nconst err = e.error || {};\nconst esc = (s) => String(s || '').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');\nconst text = `\u26a0\ufe0f <b>AI \u0414\u0430\u0439\u0434\u0436\u0435\u0441\u0442 \u0443\u043f\u0430\u043b</b>\\n` +\n  `Workflow: <code>${esc(e.workflowName || 'unknown')}</code>\\n` +\n  `Node: <code>${esc(e.lastNodeExecuted || 'unknown')}</code>\\n` +\n  `Error: <code>${esc((err.message || JSON.stringify(err)).slice(0,500))}</code>\\n` +\n  `Time: ${new Date().toISOString()}`;\nreturn [{ json: { text } }];"
      },
      "id": "err-format",
      "name": "Format Error",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        400
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $env.TG_CHAT_ID }}",
        "text": "={{ $json.text }}",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "id": "err-send",
      "name": "Telegram Error Notify",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1000,
        400
      ],
      "credentials": {}
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Format Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Error": {
      "main": [
        [
          {
            "node": "Telegram Error Notify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "timezone": "Europe/Moscow",
    "executionOrder": "v1"
  },
  "active": false,
  "versionId": "",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}