{
  "name": "Telegram Lead Intake \u2014 Error Monitor",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        -912,
        -544
      ],
      "id": "86bbc037-2f2d-4548-8896-9b5cda0a5c23",
      "name": "Error Trigger"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "bc0bd931-b569-4494-9227-27b7c0f36eb5",
              "name": "created_at",
              "value": "={{ $now.format('yyyy-MM-dd HH:mm:ss') }}",
              "type": "string"
            },
            {
              "id": "1a5c5a48-e9ed-47ab-bc2b-e1a2e94d0dae",
              "name": "workflow_name",
              "value": "={{ $json.workflow?.name || '' }}",
              "type": "string"
            },
            {
              "id": "b7aacfa9-94af-4ae1-b201-4914808d88d4",
              "name": "workflow_id",
              "value": "={{ String($json.workflow?.id || '') }}",
              "type": "string"
            },
            {
              "id": "c58c7711-8504-4407-b119-88def982335e",
              "name": "execution_id",
              "value": "={{ String($json.execution?.id || '') }}",
              "type": "string"
            },
            {
              "id": "34a6d52f-f424-41ba-99cc-6d2ffb3963a5",
              "name": "error_node",
              "value": "={{ String($json.execution?.lastNodeExecuted || '') }}",
              "type": "string"
            },
            {
              "id": "69a60178-2e52-401b-9e69-9f2557db0cb7",
              "name": "error_message",
              "value": "={{ String($json.execution?.error?.message || '').slice(0, 2000) }}",
              "type": "string"
            },
            {
              "id": "5848b9c6-4e7a-4b9a-a054-ba7fe7875d5c",
              "name": "error_stack",
              "value": "={{ String($json.execution?.error?.stack || '').slice(0, 45000) }}",
              "type": "string"
            },
            {
              "id": "253cc8bf-fb5c-4547-91ce-e51c748c411e",
              "name": "last_node_executed",
              "value": "={{ String($json.execution?.lastNodeExecuted || '') }}",
              "type": "string"
            },
            {
              "id": "0fb5c4fe-a844-44d4-a9df-a47ba649ba19",
              "name": "mode",
              "value": "={{ String($json.execution?.mode || '') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -688,
        -544
      ],
      "id": "b1788483-3348-4852-901a-ae759b380699",
      "name": "Normalize Error"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "REPLACE_WITH_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "workflow_errors",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "created_at": "={{$('Normalize Error').item.json.created_at }}",
            "workflow_name": "={{ $('Normalize Error').item.json.workflow_name }}",
            "workflow_id": "={{ $('Normalize Error').item.json.workflow_id }}",
            "execution_id": "={{ $('Normalize Error').item.json.execution_id }}",
            "error_node": "={{ $('Normalize Error').item.json.error_node }}",
            "error_message": "={{ $('Normalize Error').item.json.error_message }}",
            "error_stack": "={{ $('Normalize Error').item.json.error_stack }}",
            "last_node_executed": "={{ $('Normalize Error').item.json.last_node_executed }}",
            "mode": "={{ $('Normalize Error').item.json.mode }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "workflow_name",
              "displayName": "workflow_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "workflow_id",
              "displayName": "workflow_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "execution_id",
              "displayName": "execution_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "error_node",
              "displayName": "error_node",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "error_message",
              "displayName": "error_message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "error_stack",
              "displayName": "error_stack",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "last_node_executed",
              "displayName": "last_node_executed",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "mode",
              "displayName": "mode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -240,
        -544
      ],
      "id": "95604f84-25ca-46fc-9844-0de257a1f2e2",
      "name": "Append Error Log",
      "retryOnFail": true,
      "maxTries": 2,
      "waitBetweenTries": 1000,
      "continueOnFail": true
    },
    {
      "parameters": {
        "chatId": "REPLACE_WITH_ADMIN_CHAT_ID",
        "text": "={{\n'n8n workflow error\\n'\n+ 'Workflow: ' + String($('Normalize Error').item.json.workflow_name || '') + '\\n'\n+ 'Execution: ' + String($('Normalize Error').item.json.execution_id || '') + '\\n'\n+ 'Node: ' + String($('Normalize Error').item.json.error_node || '') + '\\n'\n+ 'Error: ' + String($('Normalize Error').item.json.error_message || '').slice(0, 500)\n}}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -464,
        -544
      ],
      "id": "e9b528bd-d9ec-4648-859f-222af614cf0f",
      "name": "Send Admin Alert",
      "retryOnFail": true,
      "maxTries": 2,
      "waitBetweenTries": 1000,
      "continueOnFail": true
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Normalize Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Error": {
      "main": [
        [
          {
            "node": "Send Admin Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Admin Alert": {
      "main": [
        [
          {
            "node": "Append Error Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false,
    "timezone": "Europe/Riga"
  },
  "nodeGroups": []
}