Перейти к содержанию

Geni_error_catcher (I7DgFold1DUWIFbw)

Raw workflow JSON

{
  "updatedAt": "2025-12-10T02:57:51.000Z",
  "createdAt": "2025-12-05T10:14:50.057Z",
  "id": "I7DgFold1DUWIFbw",
  "name": "Geni_error_catcher",
  "description": null,
  "active": false,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        -128,
        -48
      ],
      "id": "a2aa3c50-1d6e-410c-a801-3eaa67f85686",
      "name": "Error Trigger"
    },
    {
      "parameters": {
        "jsCode": "// Code node: extract_chat_and_error\n// Вход: payload из Error Trigger\n// Выход: { chatId, lang, errorText, httpCode, nodeName, workflowName, workflowId, executionId, executionUrl }\n\nconst exec = $json.execution || {};\nconst wf   = $json.workflow  || {};\nconst err  = exec.error       || $json.error || {};\nconst ctx  = err.context      || {};\nconst req  = ctx.request      || {};\nconst body = req.body         || {};\n\n// 1) chatId: сначала пробуем взять из тела запроса (как в ensure_user),\n// потом из lastNode.data.json, если он есть.\nlet chatId = '';\n\nif (body.p_tg_user_id) {\n  chatId = String(body.p_tg_user_id);\n} else if (body.chat_id) {\n  chatId = String(body.chat_id);\n}\n\n// попытка вытащить из lastNode, если n8n его прокинул\n// (в Error Trigger это может быть не всегда, но на будущее пригодится)\nlet lastJson = {};\nif (ctx.lastNode && ctx.lastNode.data && ctx.lastNode.data.main) {\n  const main = ctx.lastNode.data.main;\n  if (Array.isArray(main) && main[0] && main[0][0] && main[0][0].json) {\n    lastJson = main[0][0].json;\n  }\n}\n\nif (!chatId) {\n  chatId = String(\n    lastJson.chatId ||\n    lastJson.chat?.id ||\n    lastJson.message?.chat?.id ||\n    ''\n  );\n}\n\n// 2) язык: берём из lastJson.lang, иначе по умолчанию ru\nlet lang = 'ru';\nif (typeof lastJson.lang === 'string') {\n  lang = ['ru', 'en'].includes(lastJson.lang.toLowerCase())\n    ? lastJson.lang.toLowerCase()\n    : 'ru';\n}\n\n// 3) текст ошибки и мета\nconst errorText = String(err.message || 'Unknown error');\nconst httpCode  = err.httpCode || null;\n\nconst nodeName      = (err.node && err.node.name) || exec.lastNodeExecuted || null;\nconst workflowName  = wf.name || null;\nconst workflowId    = wf.id   || null;\nconst executionId   = exec.id || null;\nconst executionUrl  = exec.url || null;\n\n// На выходе — чистый JSON, удобный для дальнейшего использования\nreturn [{\n  json: {\n    chatId,\n    lang,\n    errorText,\n    httpCode,\n    nodeName,\n    workflowName,\n    workflowId,\n    executionId,\n    executionUrl,\n  }\n}];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        96,
        -48
      ],
      "id": "f5da0580-d687-4a64-91fb-6bfd06a7b609",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "chatId": "={{ $json.chatId }}",
        "text": "={{ $json.lang === 'en'\n  ? (\n      '⚠️ Something went wrong while processing your request.\\n' +\n      'The team has been notified.\\n\\n' +\n      'Error: ' + $json.errorText + '\\n' +\n      'Ref: ' + $json.execId\n    )\n  : (\n      '⚠️ При обработке вашего запроса произошла ошибка.\\n' +\n      'Мы уже получили уведомление и разберёмся.\\n\\n' +\n      'Ошибка: ' + $json.errorText + '\\n' +\n      'ID выполнения: ' + $json.executionId\n    )\n}}\n",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "3a0c76a4-5352-468d-938a-cbc1dcfa969c",
      "name": "Instruct_mes",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        320,
        -48
      ],
      "webhookId": "c8e052b4-93e1-4379-885b-f24b1372ec56",
      "credentials": {
        "telegramApi": {
          "id": "ur7jSUPdiAaPVhCf",
          "name": "Geni AI"
        }
      }
    }
  ],
  "connections": {
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Instruct_mes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": null,
  "pinData": {
    "Error Trigger": [
      {
        "json": {
          "execution": {
            "id": "5292",
            "url": "https://n8n.geni-ai.online/workflow/sMc5cw8oFAYs8Org/executions/5292",
            "error": {
              "level": "warning",
              "tags": {},
              "timestamp": 1764930818122,
              "context": {
                "itemIndex": 0,
                "request": {
                  "body": {
                    "p_tg_user_id": "748140117",
                    "p_tg_username": "GRIGORIY_VOYAKIN"
                  },
                  "headers": {
                    "content-type": " application/json",
                    "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7",
                    "apikey": "**hidden**",
                    "Authorization": "**hidden**"
                  },
                  "method": "POST",
                  "uri": "https://bwbsclwdkighhzlyiman.supabas/rpc/ensure_user",
                  "gzip": true,
                  "rejectUnauthorized": true,
                  "followRedirect": true,
                  "resolveWithFullResponse": true,
                  "followAllRedirects": true,
                  "timeout": 300000,
                  "encoding": null,
                  "json": false,
                  "useStream": true
                }
              },
              "functionality": "regular",
              "name": "NodeApiError",
              "node": {
                "parameters": {
                  "preBuiltAgentsCalloutHttpRequest": "",
                  "curlImport": "",
                  "method": "POST",
                  "url": "=https://bwbsclwdkighhzlyiman.supabas/rpc/ensure_user",
                  "authentication": "predefinedCredentialType",
                  "nodeCredentialType": "supabaseApi",
                  "provideSslCertificates": false,
                  "sendQuery": false,
                  "sendHeaders": true,
                  "specifyHeaders": "keypair",
                  "headerParameters": {
                    "parameters": [
                      {
                        "name": "Content-Type",
                        "value": " application/json"
                      }
                    ]
                  },
                  "sendBody": true,
                  "contentType": "json",
                  "specifyBody": "json",
                  "jsonBody": "={\n  \"p_tg_user_id\": \"{{ $json.message.chat.id }}\",\n  \"p_tg_username\": \"{{ $json.message?.from?.username || '' }}\"\n}\n",
                  "options": {},
                  "infoMessage": ""
                },
                "type": "n8n-nodes-base.httpRequest",
                "typeVersion": 4.2,
                "position": [
                  -720,
                  2272
                ],
                "id": "31e25513-0b08-4ac8-afd6-76aa7ab1cf0a",
                "name": "ensure_user",
                "retryOnFail": true,
                "credentials": {
                  "supabaseApi": {
                    "id": "jGgpXKPYHiL193Rz",
                    "name": "Supabase account"
                  }
                }
              },
              "messages": [
                "getaddrinfo ENOTFOUND bwbsclwdkighhzlyiman.supabas",
                "getaddrinfo ENOTFOUND bwbsclwdkighhzlyiman.supabas"
              ],
              "httpCode": "ENOTFOUND",
              "message": "The connection cannot be established, this usually occurs due to an incorrect host (domain) value",
              "stack": "NodeApiError: The connection cannot be established, this usually occurs due to an incorrect host (domain) value\n    at ExecuteContext.requestWithAuthentication (C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\n8n-core\\src\\execution-engine\\node-execution-context\\utils\\request-helper-functions.ts:1498:10)\n    at processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at ExecuteContext.requestWithAuthentication (C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\n8n-core\\src\\execution-engine\\node-execution-context\\utils\\request-helper-functions.ts:1798:11)"
            },
            "lastNodeExecuted": "ensure_user",
            "mode": "webhook",
            "executionContext": {
              "version": 1,
              "establishedAt": 1764930812522,
              "source": "webhook"
            }
          },
          "workflow": {
            "id": "sMc5cw8oFAYs8Org",
            "name": "Geni_AI_v014-7"
          }
        }
      }
    ]
  },
  "versionId": "5f38012b-a67e-4250-91f5-e3adb1d68f17",
  "activeVersionId": null,
  "versionCounter": 6,
  "triggerCount": 0,
  "shared": [
    {
      "updatedAt": "2025-12-05T10:14:50.061Z",
      "createdAt": "2025-12-05T10:14:50.061Z",
      "role": "workflow:owner",
      "workflowId": "I7DgFold1DUWIFbw",
      "projectId": "MHclKTSzdRCLxmxU",
      "project": {
        "updatedAt": "2025-05-06T12:49:51.317Z",
        "createdAt": "2025-05-06T12:48:38.577Z",
        "id": "MHclKTSzdRCLxmxU",
        "name": "Grigoriy Voyakin <grigoriyvoyakinwork@gmail.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "projectRelations": [
          {
            "updatedAt": "2025-05-06T12:48:38.577Z",
            "createdAt": "2025-05-06T12:48:38.577Z",
            "userId": "15659665-1e18-4119-8f87-b50a3cb257b7",
            "projectId": "MHclKTSzdRCLxmxU",
            "user": {
              "updatedAt": "2025-12-10T02:57:46.000Z",
              "createdAt": "2025-05-06T12:48:38.340Z",
              "id": "15659665-1e18-4119-8f87-b50a3cb257b7",
              "email": "grigoriyvoyakinwork@gmail.com",
              "firstName": "Grigoriy",
              "lastName": "Voyakin",
              "personalizationAnswers": {
                "version": "v4",
                "personalization_survey_submitted_at": "2025-05-09T12:49:28.002Z",
                "personalization_survey_n8n_version": "1.91.3"
              },
              "settings": {
                "userActivated": true,
                "easyAIWorkflowOnboarded": true,
                "firstSuccessfulWorkflowId": "6ndVsjNc12yZ7vD6",
                "userActivatedAt": 1747397744116,
                "npsSurvey": {
                  "responded": true,
                  "lastShownAt": 1756144477136
                }
              },
              "disabled": false,
              "mfaEnabled": false,
              "lastActiveAt": "2025-12-09",
              "isPending": false
            }
          }
        ]
      }
    }
  ],
  "tags": [
    {
      "updatedAt": "2025-10-29T09:15:49.403Z",
      "createdAt": "2025-10-29T09:15:49.403Z",
      "id": "NFsjRzvK9b3zMBTF",
      "name": "docs"
    }
  ],
  "activeVersion": null
}