Files
MTUCI-RAG-Example/support_files/n8n/workflows/Обработка запроса пользователя (1).json
T

425 lines
11 KiB
JSON

{
"name": "Обработка запроса пользователя",
"nodes": [
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.4,
"position": [
-272,
-16
],
"id": "061743cb-30cd-4d2d-8b16-113983f3058f",
"name": "When chat message received",
"webhookId": "9582845f-c8f7-42c5-8010-9f4e274028c1",
"disabled": true
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.message }}",
"hasOutputParser": true,
"options": {
"systemMessage": "Ты — ассистент, который отвечает на вопросы пользователей.\n\nОБЯЗАТЕЛЬНЫЙ ПОРЯДОК РАБОТЫ:\n1. Сначала ВСЕГДА вызови инструмент поиска по базе знаний.\n2. Проанализируй полученные результаты.\n3. Если в результатах есть ответ на вопрос - используй его.\n4. Если ответа нет в базе знаний - укажи, что заявка передаётся специалисту."
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
16,
-224
],
"id": "4145dbbc-435b-40c6-96d8-763204a2a847",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "openai/gpt-oss-120b"
},
"responsesApiEnabled": false,
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.3,
"position": [
-64,
128
],
"id": "58936870-7416-44a7-b3f3-f9d441b1d790",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "1nJ1BJpmEz5PgE4G",
"name": "PolzaAI SchoolHepler"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $json.session_id }}"
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.4,
"position": [
-64,
336
],
"id": "f28acb38-e8ed-4d18-88a0-5ba8170bbf8e",
"name": "Simple Memory"
},
{
"parameters": {
"mode": "retrieve-as-tool",
"toolDescription": "Поиск по базе знаний. Возвращает релевантные документы и фрагменты текста по запросу пользователя. Используй этот инструмент для получения фактических данных перед ответом.",
"memoryKey": {
"__rl": true,
"value": "={{ $json.collection_name }}",
"mode": "id"
},
"topK": 10,
"includeDocumentMetadata": false
},
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
"typeVersion": 1.3,
"position": [
64,
160
],
"id": "d2972aa7-2cbe-4eaa-8b26-d50742f56379",
"name": "Simple Vector Store"
},
{
"parameters": {
"model": "qwen/qwen3-embedding-8b",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.2,
"position": [
64,
384
],
"id": "351b9336-788a-4a58-9b17-16a03570e5a7",
"name": "Embeddings OpenAI",
"credentials": {
"openAiApi": {
"id": "1nJ1BJpmEz5PgE4G",
"name": "PolzaAI SchoolHepler"
}
}
},
{
"parameters": {
"httpMethod": "POST",
"path": "126bdb74-0630-415d-a8f7-6f699eac1a2c",
"responseMode": "responseNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-480,
-224
],
"id": "bb7780bd-8dad-48f5-8a1d-4f29a5b981c9",
"name": "Webhook запрос от пользователя",
"webhookId": "126bdb74-0630-415d-a8f7-6f699eac1a2c"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "0823a8e5-4e4c-4308-9d13-873718f4eaff",
"name": "message",
"value": "={{ $json.body.message }}",
"type": "string"
},
{
"id": "c9e5c033-1afc-4241-b751-dec53f4bae73",
"name": "collection_name",
"value": "={{ $json.body.collection_name }}",
"type": "string"
},
{
"id": "dd16d556-1d31-4458-b817-ff41325cf4dc",
"name": "session_id",
"value": "={{ $json.body.session_id }}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.5,
"position": [
-256,
-224
],
"id": "9961d520-7f99-417e-b490-398af83c026e",
"name": "Набор данных"
},
{
"parameters": {
"respondWith": "text",
"responseBody": "={{ $('AI Agent').item.json.output.output }}",
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.5,
"position": [
768,
-208
],
"id": "4185c82c-d175-4dcf-8322-e0a4343a458f",
"name": "Respond to Webhook"
},
{
"parameters": {
"jsonSchemaExample": "{\n\t\"respond_specialist\": true,\n\t\"output\": \"AI-agent message\"\n}",
"autoFix": true
},
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"typeVersion": 1.3,
"position": [
224,
-16
],
"id": "6d7b0681-0b9a-4986-a5fb-b304966a9df1",
"name": "Structured Output Parser"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "7720521f-fc12-4951-9139-4a2bd7e1d75d",
"leftValue": "={{ $json.output.respond_specialist }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
352,
-224
],
"id": "50a346b0-ed53-431d-9b6b-182f9440e694",
"name": "If"
},
{
"parameters": {
"chatId": "924632699",
"text": "=Пользователь с ID сессии {{ $('Набор данных').item.json.session_id }} спрашивает:\n\n> {{ $('Набор данных').item.json.message }}",
"additionalFields": {
"appendAttribution": false,
"parse_mode": "MarkdownV2"
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
560,
-416
],
"id": "a754cd7f-116b-46c4-801f-9a7c28f4fbdb",
"name": "Send a text message",
"webhookId": "f070ee47-10e5-4b99-acda-80ed4d4b0551",
"credentials": {
"telegramApi": {
"id": "TMf5pmo2QkGa0FLR",
"name": "Telegram account"
}
}
}
],
"pinData": {},
"connections": {
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Structured Output Parser",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Simple Vector Store": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Simple Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Webhook запрос от пользователя": {
"main": [
[
{
"node": "Набор данных",
"type": "main",
"index": 0
}
]
]
},
"Набор данных": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "Send a text message",
"type": "main",
"index": 0
}
],
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Send a text message": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate"
},
"versionId": "a67627cb-e138-410f-99a3-7303ce35ed3c",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "e2065f384907dad1891d76029e33dd9f27db30e53c43de730e3d4d635e31e1e5"
},
"nodeGroups": [],
"id": "GhysEdTOeQjkVtzj",
"tags": [
{
"updatedAt": "2026-07-07T06:38:48.585Z",
"createdAt": "2026-07-07T06:38:48.585Z",
"id": "5vOw2cslMQJWsEiT",
"name": "демо"
},
{
"updatedAt": "2026-07-09T10:39:58.552Z",
"createdAt": "2026-07-09T10:39:58.552Z",
"id": "Svg7ELOEItGRgTWW",
"name": "агент"
},
{
"updatedAt": "2026-07-07T06:37:53.737Z",
"createdAt": "2026-07-07T06:37:53.737Z",
"id": "vhdY444aWHvzAmz8",
"name": "нетология"
}
]
}