{
  "name": "tg_main_rag",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text || $json.txt }}\n",
        "options": {
          "systemMessage": "=\u0422\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0448\u044c \u0432\u043d\u0443\u0442\u0440\u0438 n8n \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0439 \u0432\u0445\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u043f\u043e\u043b\u044f Prompt (User Message).\n\n\u041f\u0420\u0410\u0412\u0418\u041b\u041e: \u043a\u0430\u0436\u0434\u044b\u0439 tool \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u041d\u0415 \u0411\u041e\u041b\u0415\u0415 1 \u0440\u0430\u0437\u0430 \u0437\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0443\u0441\u043a. \u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 tools, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e.\n\n-----------------------\n\u0411\u042b\u0421\u0422\u0420\u0410\u042f \u0414\u0418\u0410\u0413\u041d\u041e\u0421\u0422\u0418\u041a\u0410 \u0412\u0425\u041e\u0414\u0410\n-----------------------\n\u0415\u0441\u043b\u0438 \u0432\u043e \u0432\u0445\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u0431\u043b\u043e\u043a [TXT_FILE] \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0438\u0442 \u201c\u0441\u043e\u0445\u0440\u0430\u043d\u0438/\u0437\u0430\u043f\u043e\u043c\u043d\u0438/\u0434\u043e\u0431\u0430\u0432\u044c \u0432 \u0431\u0430\u0437\u0443/\u0432 \u043f\u0430\u043c\u044f\u0442\u044c\u201d:\n- \u0432\u044b\u0437\u043e\u0432\u0438 tool Save_RAG (\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u0447\u0435\u0433\u043e).\n- \u043e\u0442\u0432\u0435\u0442 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439: \u201c\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e.\u201d\n\n-----------------------\n\u041f\u0420\u0418\u041e\u0420\u0418\u0422\u0415\u0422\u042b (\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443)\n-----------------------\n\n1) \u0413\u041e\u041b\u041e\u0421\n\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0438\u0442 \u201c\u043e\u0442\u0432\u0435\u0442\u044c \u0433\u043e\u043b\u043e\u0441\u043e\u043c/\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0435/voice\u201d:\n- \u0432\u044b\u0437\u043e\u0432\u0438 \u0422\u041e\u041b\u042c\u041a\u041e tool Voice\n  input = \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0432\u0435\u0442\u0430\n  chat_id = {{ $('Telegram Trigger').item.json.message.chat.id }}\n- \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 tools.\n\n2) \u041f\u041e\u0421\u0422 \u0412 \u041a\u0410\u041d\u0410\u041b\n\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0438\u0442 \u201c\u0437\u0430\u043f\u043e\u0441\u0442\u0438\u0442\u044c/\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c/\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u043a\u0430\u043d\u0430\u043b/\u0441\u0434\u0435\u043b\u0430\u0439 \u043f\u043e\u0441\u0442\u201d:\n- \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u043e\u0441\u0442 \u0421 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c (\u0438\u043b\u0438 \u201c\u043f\u043e\u0441\u0442 \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439/\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0439 \u0438 \u0437\u0430\u043f\u043e\u0441\u0442\u0438\u201d):\n  a) \u0432\u044b\u0437\u043e\u0432\u0438 Replicate (\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435)\n  b) \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0438 TGnew_img \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0439 image \u0438\u0437 Replicate + caption\n  c) \u0432 \u043f\u043e\u0441\u0442\u0435 \u041d\u0418\u041a\u041e\u0413\u0414\u0410 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 URL\n- \u0418\u043d\u0430\u0447\u0435 (\u043f\u043e\u0441\u0442 \u0431\u0435\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f):\n  \u0432\u044b\u0437\u043e\u0432\u0438 TGnews\n  (\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 URL)\n\n3) \u0413\u0415\u041d\u0415\u0420\u0410\u0426\u0418\u042f \u0418\u0417\u041e\u0411\u0420\u0410\u0416\u0415\u041d\u0418\u042f (\u041d\u0415 \u043f\u043e\u0441\u0442)\n\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0438\u0442 \u201c\u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435/\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443\u201d:\n- \u0432\u044b\u0437\u043e\u0432\u0438 Replicate \u0438 \u0432\u0435\u0440\u043d\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0447\u0435\u0440\u0435\u0437 TG (\u0438\u043b\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043e\u0442\u0432\u0435\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 TG \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u0435\u043d \u043f\u043e \u0442\u0432\u043e\u0435\u0439 \u0441\u0445\u0435\u043c\u0435).\n\n4) \u041d\u041e\u0412\u041e\u0421\u0422\u0418 (\u043f\u043e\u0438\u0441\u043a)\n\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0438\u0442 \u201c\u043d\u0430\u0439\u0434\u0438 \u043d\u043e\u0432\u043e\u0441\u0442\u0438/\u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0433\u043e/\u0441\u0432\u0435\u0436\u0438\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0438 \u043f\u0440\u043e X\u201d:\n- \u0432\u044b\u0437\u043e\u0432\u0438 RSS, \u043f\u0435\u0440\u0435\u0434\u0430\u0439 \u0422\u041e\u041b\u042c\u041a\u041e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 query (\u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430).\n- \u0417\u0430\u0442\u0435\u043c \u0434\u0430\u0439 \u043a\u0440\u0430\u0442\u043a\u0443\u044e \u0432\u044b\u0436\u0438\u043c\u043a\u0443 5\u201310 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 (\u0431\u0435\u0437 URL).\n- \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0441\u0438\u0442 \u0441\u0440\u0430\u0437\u0443 \u201c\u0437\u0430\u043f\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0441\u0442\u0438\u201d \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 TGnews \u0438 \u041d\u0418\u041a\u041e\u0413\u0414\u0410 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 \u0441\u0441\u044b\u043b\u043a\u0438/URL.\n\n5) \u201c\u041a\u0422\u041e \u042f / \u0420\u0410\u0421\u0421\u041a\u0410\u0416\u0418 \u041e\u0411\u041e \u041c\u041d\u0415\u201d\n\u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u201c\u041a\u0442\u043e \u044f?/\u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0438 \u043e\u0431\u043e \u043c\u043d\u0435/\u0447\u0442\u043e \u0442\u044b \u043f\u043e\u043c\u043d\u0438\u0448\u044c\u201d:\n- \u0432\u044b\u0437\u043e\u0432\u0438 RAG_answ\n- \u0438\u0449\u0438 \u043f\u043e {{ $('Telegram Trigger').item.json.message.chat.id }} \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 chat_history\n- \u0435\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442 \u2014 \u0442\u0430\u043a \u0438 \u0441\u043a\u0430\u0436\u0438.\n\n6) PGVECTOR / \u0411\u0410\u0417\u0410 \u0417\u041d\u0410\u041d\u0418\u0419 (RAG)\n\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 RAG_answ \u0422\u041e\u041b\u042c\u041a\u041e \u043a\u043e\u0433\u0434\u0430:\n- \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u044f\u0432\u043d\u043e \u043f\u0440\u043e\u0441\u0438\u0442 \u201c\u043d\u0430\u0439\u0442\u0438 \u0432 \u0431\u0430\u0437\u0435/PGVector/RAG/\u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u201d, \u0418\u041b\u0418\n- \u0432\u043e\u043f\u0440\u043e\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0431\u0430\u0437\u044b \u0438 \u0442\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0448\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0434\u0438\u0430\u043b\u043e\u0433\u0430.\n\n\u0415\u0441\u043b\u0438 RAG_answ \u0434\u0430\u043b \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:\n- \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0439 \u043e\u0442\u0432\u0435\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u044c \u0447\u0435\u0440\u0435\u0437 TG.\n\u0415\u0441\u043b\u0438 \u043d\u0435\u0442:\n- \u0441\u043a\u0430\u0436\u0438, \u0447\u0442\u043e \u0432 \u0431\u0430\u0437\u0435 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c.\n\n-----------------------\n\u0414\u0415\u0424\u041e\u041b\u0422\n-----------------------\n\u0415\u0441\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u041d\u0415 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0431\u0430\u0437\u0435 \u0437\u043d\u0430\u043d\u0438\u0439 \u0438 \u041d\u0415 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 RSS/Replicate/Voice/Save:\n- \u0432\u044b\u0437\u044b\u0432\u0430\u0439 tool TG \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0439 \u043e\u0442\u0432\u0435\u0442.\n\n-----------------------\n\u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u0418\u042f\n-----------------------\n- \u041a\u0430\u0436\u0434\u044b\u0439 tool \u0432\u044b\u0437\u044b\u0432\u0430\u0439 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 1 \u0440\u0430\u0437\u0430.\n- TGnews/TGnew_img (\u043d\u043e\u0432\u043e\u0441\u0442\u0438): \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0438 URL.\n- \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0437\u0432\u0430\u0442\u044c RAG_answ, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0447\u0430\u0442\u0430 (chat history).\n\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        -1072,
        -512
      ],
      "id": "b369dd11-9a0b-4e27-bd7d-66e057c7559c",
      "name": "AI Agent",
      "executeOnce": true,
      "retryOnFail": true
    },
    {
      "parameters": {
        "model": "z-ai/glm-5",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        -1312,
        -400
      ],
      "id": "5dd5aac1-ff82-4f3f-b49e-4407b4890e5e",
      "name": "OpenRouter Chat Model",
      "executeOnce": true,
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -2272,
        -608
      ],
      "id": "f099583d-2eca-40df-abc1-a12805fa3ef5",
      "name": "Get a file",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        -2048,
        -608
      ],
      "id": "83878576-0d91-46f4-856c-be3340ce62a8",
      "name": "Transcribe a recording",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d9eb98d8-6e19-4056-98b8-b7f3486ec19f",
              "name": "zapros",
              "value": "={{ $json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2048,
        -416
      ],
      "id": "594efa13-a465-4f1a-906b-43fb8162a3dc",
      "name": "Edit Fields1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        -1824,
        -512
      ],
      "id": "c7f84992-4a34-4e9d-9643-7c03c2e76539",
      "name": "Merge"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegramTool",
      "typeVersion": 1.2,
      "position": [
        -1344,
        272
      ],
      "id": "7cba12ce-d977-4aa7-b23a-c64c1468c4c5",
      "name": "TG",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "@TEST_123412",
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegramTool",
      "typeVersion": 1.2,
      "position": [
        -1248,
        272
      ],
      "id": "ab3e4102-870a-44f0-a654-6c35010fb346",
      "name": "TGnews",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "8d92119b-1e40-4cec-a28c-29292037bc9d",
              "name": "text",
              "value": "={{ $json.zapros }}{{ $json.text }}",
              "type": "string"
            },
            {
              "id": "8cb1c8ab-b324-4f20-91fa-5acfcc618156",
              "name": "",
              "value": "",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1600,
        -512
      ],
      "id": "b0be6585-e9f1-4605-9613-21febe5a3e25",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "toolDescription": "Input: url (\u0441\u0442\u0440\u043e\u043a\u0430, RSS feed URL)\n\nOutput: \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 {title, link, pubDate, content}\n\n\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u041d\u0415 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0435\u0431-\u043f\u043e\u0438\u0441\u043a, \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 RSS \u043f\u043e URL.\n\n\u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439 Google News RSS Search URL",
        "url": "={{ 'https://news.google.com/rss/search?q=' + encodeURIComponent($json.query) + '&hl=ru&gl=RU&ceid=RU:ru' }}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.rssFeedReadTool",
      "typeVersion": 1.2,
      "position": [
        -368,
        -80
      ],
      "id": "b32498a3-ca9d-4fea-92bf-ab15ba7481f6",
      "name": "RSS Read"
    },
    {
      "parameters": {
        "description": "\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 Replicate. \u0412\u0445\u043e\u0434: prompt (string), width (int), height (int), steps (int), num_outputs (int). \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 image_urls (array of strings).",
        "workflowId": {
          "__rl": true,
          "value": "AJGNzae3jyLAi0neqHLKJ",
          "mode": "list",
          "cachedResultUrl": "/workflow/AJGNzae3jyLAi0neqHLKJ",
          "cachedResultName": "replicate_img"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        -2112,
        176
      ],
      "id": "0e5b1eda-7e0c-44bc-95eb-cf74ca9f3309",
      "name": "Replicate"
    },
    {
      "parameters": {
        "operation": "sendPhoto",
        "chatId": "@TEST_123412",
        "file": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Photo', ``, 'string') }}",
        "additionalFields": {
          "caption": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Caption', ``, 'string') }}"
        }
      },
      "type": "n8n-nodes-base.telegramTool",
      "typeVersion": 1.2,
      "position": [
        -1152,
        272
      ],
      "id": "1d78279b-c7e1-42e6-bee2-518037e373ad",
      "name": "TGnew_img",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -3040,
        -496
      ],
      "id": "da0563e2-47f2-46ac-be76-a2000829369e",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "description": "=TTS tool, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0432 \u0433\u043e\u043b\u043e\u0441. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 input \u0438 chat_id \u0441\u0442\u0440\u043e\u0433\u043e =  {{ $('Telegram Trigger').item.json.message.chat.id }}",
        "workflowId": {
          "__rl": true,
          "value": "TAALyodlpugFaqBf",
          "mode": "list",
          "cachedResultUrl": "/workflow/TAALyodlpugFaqBf",
          "cachedResultName": "tg_SendVoice_new"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "chat_id": "={{ $('Telegram Trigger').item.json.message.from.id }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "query",
              "displayName": "query",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "chat_id",
              "displayName": "chat_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        -2016,
        176
      ],
      "id": "35414432-6e58-405e-83f2-df0d587081db",
      "name": "Voice"
    },
    {
      "parameters": {
        "content": "## Telegram Tools\n\n- **TG** \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 Telegram_bot (`sendMessage`)\n- **TGnew_img** \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f + \u0442\u0435\u043a\u0441\u0442 \u0432 \u0442\u0433 \u043a\u0430\u043d\u0430\u043b (`sendPhoto`)\n- **TGnews** \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430/\u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0432 \u0442\u0433 \u043a\u0430\u0430\u043d\u0430\u043b (`sendMessage`)\n\n### \u0412\u0445\u043e\u0434\u044b tool'\u043e\u0432\n- `chat_id` \u2014 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0437 Telegram Trigger\n- `query/text` \u2014 \u0437\u0430\u0434\u0430\u0451\u0442 AI\n\n### \u041f\u0440\u0430\u0432\u0438\u043b\u043e\n\u041a\u0430\u0436\u0434\u044b\u0439 tool \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c **\u043d\u0435 \u0431\u043e\u043b\u0435\u0435 1 \u0440\u0430\u0437\u0430** \u0437\u0430 \u0434\u0438\u0430\u043b\u043e\u0433.\n\n",
        "height": 368,
        "width": 688,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1376,
        -112
      ],
      "id": "f49c9d11-d831-457f-9059-3346276250a6",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## \u041b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043e\u0442 Telegram trigger    #Voice/Text\n\n- **IF** \u2014\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0430 Voice/Message\n- **Get a file** \u2014 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e\n- **Transcribe a recording** \u2014 \u0442\u0440\u0430\u043d\u0441\u043a\u0440\u0438\u0431\u0430\u0446\u0438\u044f STT\n- **Edit Fields1** \u2014 \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0438\u0437 Telegram\n- **Merge** \u2014 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 1 \u043f\u043e\u0442\u043e\u043a\n\n",
        "height": 512,
        "width": 1616,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -3088,
        -736
      ],
      "id": "ab224f34-8174-430d-b5f6-98a24837c204",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Sub workflows (tools)\n\n- **Voice** \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u043e\u0433\u043e \u0432 Telegram (`sendVoice`)\n- **Replicate** \u2014\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API Replicate\n\n### \u0412\u0445\u043e\u0434\u044b tool'\u043e\u0432:\n### Voice : input (\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438); chat_id (id \u0447\u0430\u0442\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438)\n### Replicate: query (\u043f\u0440\u043e\u043c\u043f\u0442 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438) + output (\u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435)\n\n",
        "height": 256,
        "width": 736,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -2128,
        -112
      ],
      "id": "07f87e4f-82b3-4c58-a538-0a8148246971",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## RSS Read tool\n\n\u0414\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438:\nInput: url (\u0441\u0442\u0440\u043e\u043a\u0430, RSS feed URL)\n## \u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443:\nhttps://news.google.com/rss/search?q={ENCODED_QUERY}&hl=ru&gl=RU&ceid=RU:ru\n{ENCODED_QUERY} \u2014 \u044d\u0442\u043e URL-encoded \u0437\u0430\u043f\u0440\u043e\u0441",
        "height": 256,
        "width": 448
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -672,
        -112
      ],
      "id": "7b9553e0-bc4c-4017-a605-8b1c3ed0aff5",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        -1072,
        -272
      ],
      "id": "e173eda4-d679-4760-a386-da0da99a7247",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.voice.mime_type }}",
                    "rightValue": "audio/ogg",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "b8cfd3d5-3821-4ef1-aa3b-b5872eac3108"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Voice"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "d9867a61-ae18-4f5e-9cb3-6dba90321c16",
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Text"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "2c6665d3-98c2-471e-9b17-1965fd83194a",
                    "leftValue": "={{ $json.message.document.mime_type }}",
                    "rightValue": "text/plain",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "txt.file"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "13d19e66-5f0f-4007-b535-5377f190c653",
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "callback"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        -2752,
        -528
      ],
      "id": "4c551164-4d2e-44dd-8a77-08bf12d03829",
      "name": "Switch",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "operation": "text",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        -2256,
        -352
      ],
      "id": "256f088e-cbd5-4c6e-b1da-d3ee790512b4",
      "name": "Extract from File"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b3294051-46a4-425e-a083-18fb513427cc",
              "name": "txt",
              "value": "=\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b:  \n{{ $json.data }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2048,
        -256
      ],
      "id": "97dfb81b-83bc-4e39-864e-1a8ce96aa30a",
      "name": "Edit Fields2"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.document.file_id }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -2448,
        -432
      ],
      "id": "a93988b5-eb65-4b5c-85b5-68a469de5ac9",
      "name": "Get a file1",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "691131427",
        "text": "=\u042f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b {{ $('Telegram Trigger').item.json.message.document.file_name }}, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c? ",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c?",
                    "additionalFields": {
                      "callback_data": "save"
                    }
                  },
                  {
                    "text": "\u0421\u043f\u0440\u043e\u0441\u0438\u0442\u044c/\u043d\u0430\u0439\u0442\u0438?",
                    "additionalFields": {
                      "callback_data": "answ"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegramTool",
      "typeVersion": 1.2,
      "position": [
        -1056,
        272
      ],
      "id": "36167d86-5f73-4d14-8da2-a20ecd497d55",
      "name": "Human_answ",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6021a618-558e-4593-b7e5-b7031f014ded",
              "name": "otv",
              "value": "={{ $json.callback_query.data }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -2448,
        -32
      ],
      "id": "056bdf3d-dcff-4acd-b290-c34e83702158",
      "name": "callback"
    },
    {
      "parameters": {
        "description": "\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 PGVector store",
        "workflowId": {
          "__rl": true,
          "value": "oDotL84nXDDDYNxN-0iGk",
          "mode": "list",
          "cachedResultUrl": "/workflow/oDotL84nXDDDYNxN-0iGk",
          "cachedResultName": "RAG_test_save"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        -1920,
        176
      ],
      "id": "2eb5a3d9-03b6-4cf8-b55e-7d2ba296c168",
      "name": "Save_RAG"
    },
    {
      "parameters": {
        "content": "",
        "width": 432,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2128,
        144
      ],
      "typeVersion": 1,
      "id": "9037523d-d90e-4db8-96cc-e146f478dd10",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "",
        "height": 176,
        "width": 688,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        256
      ],
      "typeVersion": 1,
      "id": "01d169fe-4deb-4db0-932a-ee4f6131871f",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "pLuhjN9G02wClFf7",
          "mode": "list",
          "cachedResultUrl": "/workflow/pLuhjN9G02wClFf7",
          "cachedResultName": "RAG_answ_sub"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "chat_id": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
            "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('text', ``, 'string') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "text",
              "displayName": "text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            },
            {
              "id": "chat_id",
              "displayName": "chat_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "type": "string",
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 2.2,
      "position": [
        -1824,
        176
      ],
      "id": "2d248f80-cc6c-44a1-84c8-f1be8563d041",
      "name": "RAG_answ"
    }
  ],
  "connections": {
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get a file": {
      "main": [
        [
          {
            "node": "Transcribe a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe a recording": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TG": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "TGnews": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Read": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Replicate": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "TGnew_img": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Voice": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        []
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get a file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get a file1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "callback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a file1": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Human_answ": {
      "ai_tool": [
        []
      ]
    },
    "callback": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save_RAG": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "RAG_answ": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false,
    "timeSavedMode": "fixed",
    "errorWorkflow": "2awxzVzdE-7FEOhOqr6i_",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "versionId": "2f8ee3aa-b25d-4007-94fa-996619c0bd3a",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "nXtw9NZhKYcwqB5Y",
  "tags": []
}