Hi guys, please i need ur help, i’m tryin to make an ai assistant which can scan pdf files and answer users using only information from google drive.. i think that i’ did everything correct, but ai agent skips step when it needs to look up for information from google drive and uses ai just to answer questions here is my workflow
{
“name”: “info”,
“nodes”: [
{
“parameters”: {
“updates”: [
“message”
],
“additionalFields”: {}
},
“id”: “341b79e9-c505-4303-adbf-49f3a5a6b243”,
“name”: “Telegram Trigger”,
“type”: “n8n-nodes-base.telegramTrigger”,
“typeVersion”: 1.1,
“position”: [
-960,
192
],
“webhookId”: “6ed50111-9b95-44be-8e88-e23ffaf4610d”,
“credentials”: {
“telegramApi”: {
“id”: “EnJGz27qwXz1936F”,
“name”: “Telegram account 2”
}
}
},
{
“parameters”: {
“rules”: {
“values”: [
{
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“leftValue”: “={{ $json.message.voice.file_id }}”,
“rightValue”: “”,
“operator”: {
“type”: “string”,
“operation”: “exists”,
“singleValue”: true
}
}
],
“combinator”: “and”
},
“renameOutput”: true,
“outputKey”: “Voice”
},
{
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “8c844924-b2ed-48b0-935c-c66a8fd0c778”,
“leftValue”: “={{ $json.message.text }}”,
“rightValue”: “”,
“operator”: {
“type”: “string”,
“operation”: “exists”,
“singleValue”: true
}
}
],
“combinator”: “and”
},
“renameOutput”: true,
“outputKey”: “Text”
}
]
},
“options”: {}
},
“id”: “c005b1fd-9524-4e63-b4d4-837ee287e0ad”,
“name”: “Switch”,
“type”: “n8n-nodes-base.switch”,
“typeVersion”: 3.2,
“position”: [
-784,
192
]
},
{
“parameters”: {
“chatId”: “={{ $(‘Telegram Trigger’).item.json.message.chat.id }}”,
“text”: “={{ $json.output }}”,
“additionalFields”: {
“appendAttribution”: false
}
},
“id”: “b3997eb9-1000-4160-8594-12f4b154e820”,
“name”: “Response”,
“type”: “n8n-nodes-base.telegram”,
“typeVersion”: 1.2,
“position”: [
528,
192
],
“webhookId”: “ac2c424d-f210-4300-8535-22b21bb1905f”,
“credentials”: {
“telegramApi”: {
“id”: “EnJGz27qwXz1936F”,
“name”: “Telegram account 2”
}
}
},
{
“parameters”: {
“resource”: “file”,
“fileId”: “={{ $json.message.voice.file_id }}”,
“additionalFields”: {}
},
“id”: “da13b870-9b7c-4e9c-a234-b4c84a2e317a”,
“name”: “Download File”,
“type”: “n8n-nodes-base.telegram”,
“typeVersion”: 1.2,
“position”: [
-528,
32
],
“webhookId”: “44f2baa4-d47e-46e0-948b-d4bdd74e9d8b”,
“credentials”: {
“telegramApi”: {
“id”: “EnJGz27qwXz1936F”,
“name”: “Telegram account 2”
}
}
},
{
“parameters”: {
“resource”: “audio”,
“operation”: “transcribe”,
“options”: {}
},
“id”: “123cfa41-1766-4178-8251-7dfcdbc898e7”,
“name”: “Transcribe”,
“type”: “@n8n/n8n-nodes-langchain.openAi”,
“typeVersion”: 1.6,
“position”: [
-384,
32
],
“credentials”: {
“openAiApi”: {
“id”: “vj57XTtwxvs1wLSP”,
“name”: “OpenAi account 2”
}
}
},
{
“parameters”: {
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.embeddingsOpenAi”,
“typeVersion”: 1.2,
“position”: [
384,
768
],
“id”: “457cab66-88f7-4fe1-a389-b5999d29b6c8”,
“name”: “Embeddings OpenAI”,
“credentials”: {
“openAiApi”: {
“id”: “vj57XTtwxvs1wLSP”,
“name”: “OpenAi account 2”
}
}
},
{
“parameters”: {
“tableId”: “chat_logs”,
“fieldsUi”: {
“fieldValues”: [
{
“fieldId”: “session_id”,
“fieldValue”: “={{ $json.sessionId }}”
},
{
“fieldId”: “user_id”,
“fieldValue”: “={{ $json.user_id || $json.message.from.id }}”
},
{
“fieldId”: “username”,
“fieldValue”: “={{ $json.username || $json.message.from.username }}”
},
{
“fieldId”: “role”,
“fieldValue”: “user”
},
{
“fieldId”: “content”,
“fieldValue”: “={{ $json.text }}”
},
{
“fieldId”: “metadata”,
“fieldValue”: “={{ JSON.stringify($json) }}”
},
{
“fieldId”: “first_name”,
“fieldValue”: “={{ $json.first_name || $json.message.from.first_name }}”
}
]
}
},
“type”: “n8n-nodes-base.supabase”,
“typeVersion”: 1,
“position”: [
-368,
272
],
“id”: “0ba839cd-8052-4f05-95fc-4c90ed9ff220”,
“name”: “Save User Message”,
“credentials”: {
“supabaseApi”: {
“id”: “x62fAvywfVAC6gmG”,
“name”: “Supabase account”
}
}
},
{
“parameters”: {
“tableId”: “chat_logs”,
“fieldsUi”: {
“fieldValues”: [
{
“fieldId”: “session_id”,
“fieldValue”: “={{ $(‘Set Final Text’).item.json.sessionId }}”
},
{
“fieldId”: “user_id”,
“fieldValue”: “={{ $(‘Set Final Text’).item.json.user_id }}”
},
{
“fieldId”: “username”,
“fieldValue”: “={{ $(‘Set Final Text’).item.json.username }}”
},
{
“fieldId”: “role”,
“fieldValue”: “assistant”
},
{
“fieldId”: “content”,
“fieldValue”: “={{ $(‘ИНФО АГЕНТ’).item.json.output }}”
},
{
“fieldId”: “metadata”,
“fieldValue”: “={{ JSON.stringify($(‘Set Final Text’).item.json.update || $(‘Set Final Text’).item.json) }}”
},
{
“fieldId”: “first_name”,
“fieldValue”: “={{ $(‘Set Final Text’).item.json.first_name }}”
}
]
}
},
“type”: “n8n-nodes-base.supabase”,
“typeVersion”: 1,
“position”: [
752,
192
],
“id”: “bfcf705b-98d7-452f-a94f-972fca941699”,
“name”: “Save Bot Message”,
“credentials”: {
“supabaseApi”: {
“id”: “x62fAvywfVAC6gmG”,
“name”: “Supabase account”
}
}
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $(‘Set Final Text’).item.json.text }}”,
“options”: {
“systemMessage”: “You exist to help people implement automations and use AI solutions in life and business. Your job is to uncover the user’s problem or question and provide a clear answer using your database.\n\nIMPORTANT:\n\nYou don’t make things up. You use your knowledge base (via the DATA_TOOL) to retrieve relevant info and insights.\n\nTOOL:\nu have a data tool node to search for information from ur database, u must answer using only infomation from data base\n\nConversation Flow:\n\nMake sure the person has entered the chat with a specific goal or a desire to learn something new.\n\nUnderstand their current situation. If they have a business, ask about its stage, challenges, or questions.\nExample: “Describe what’s going on in your project.”\n\nUnderstand their goal (if they have one) and what’s blocking it.\nExample: “What are you struggling with? What do you think is holding you back?”\n\nConfirm that you can help. Use the knowledge base to find relevant answers or insights that could move them forward.\n\nOffer a clear plan. Suggest actionable solutions that directly match their request. Explain what can be done and how.\n\nAlways end with a question or call to action, so the dialogue doesn’t hit a dead end.\n\nTone & Style:\n\nTalk in a way that even a kid or grandparent can understand. AI is a tough topic for many, so avoid heavy jargon.\n\nUse real-life examples and analogies to explain complex tools and ideas.\n\nStick to the structured conversation flow.\n\nResponse Format:\n\nYou’re chatting in Telegram. Send replies in Markdown format optimized for messaging.\n\nMake the text easy and pleasant to read. Use formatting to guide attention.\n\nYou must always answer in russian lagnuage\n”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.7,
“position”: [
-80,
192
],
“id”: “5fdc7a7c-2c5e-4132-b805-d82ae95a6624”,
“name”: “ИНФО АГЕНТ”,
“retryOnFail”: false
},
{
“parameters”: {
“tableName”: {
“__rl”: true,
“value”: “documents”,
“mode”: “list”,
“cachedResultName”: “documents”
},
“options”: {
“queryName”: “match_documents”
}
},
“type”: “@n8n/n8n-nodes-langchain.vectorStoreSupabase”,
“typeVersion”: 1,
“position”: [
224,
640
],
“id”: “b208e9ea-7228-4590-bd15-444a2492dfc5”,
“name”: “DATA BASE”,
“credentials”: {
“supabaseApi”: {
“id”: “x62fAvywfVAC6gmG”,
“name”: “Supabase account”
}
}
},
{
“parameters”: {
“name”: “documents”,
“description”: “Provide a detailed and fact-based answer. Use the database as long-term memory, which contains real examples of how AI solutions have been implemented in businesses. Include evaluations, results, and future forecasts where available. Always mention specific project or company names if they are present in the data. Do not generalize — stick to concrete cases.”,
“topK”: “=30”
},
“type”: “@n8n/n8n-nodes-langchain.toolVectorStore”,
“typeVersion”: 1,
“position”: [
224,
384
],
“id”: “a3fc2a9c-6d32-4eef-bde3-89fb1c904da1”,
“name”: “DATA_TOOL”
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $json.session_id }}”,
“contextWindowLength”: 10
},
“type”: “@n8n/n8n-nodes-langchain.memoryPostgresChat”,
“typeVersion”: 1.3,
“position”: [
48,
384
],
“id”: “4a6f4044-2922-4d62-b17e-536bd527a678”,
“name”: “ВРЕМЕННАЯ ПАМЯТЬ 1”,
“credentials”: {
“postgres”: {
“id”: “dFUPRTlIEdCAMTB5”,
“name”: “Postgres account”
}
}
},
{
“parameters”: {
“model”: {
“_rl": true,
“value”: “gpt-4o”,
“mode”: “list”,
“cachedResultName”: “gpt-4o”
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
-80,
384
],
“id”: “65483b9f-cbac-4e47-9d1d-aa15202cc058”,
“name”: “МОЗГ 1”,
“credentials”: {
“openAiApi”: {
“id”: “vj57XTtwxvs1wLSP”,
“name”: “OpenAi account 2”
}
}
},
{
“parameters”: {
“method”: “POST”,
“url”: “https://api.telegram.org/bot8306226059:AAF6zD4gdrkaJzYoDxjDWxjlyfdgRraNs_8/sendChatAction”,
“sendBody”: true,
“specifyBody”: “json”,
“jsonBody”: “={\n “chat_id”: {{ $(‘Telegram Trigger’).item.json.message.chat.id }},\n “action”: “typing”\n}\n”,
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
0,
0
],
“id”: “ee76d59c-b723-4818-8d6c-99045f126803”,
“name”: “Typing 1”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “fe7ecc99-e1e8-4a5e-bdd6-6fce9757b234”,
“name”: “text”,
“value”: “={{ $json.text || $json.message.text }}”,
“type”: “string”
},
{
“id”: “8386c97a-d1b9-4000-9e17-86c2158e91af”,
“name”: “sessionId”,
“value”: "={{ 'user’ + $(‘Switch’).item.json.message.from.id }}”,
“type”: “string”
},
{
“id”: “877d9358-6785-4299-be83-7c78fd41924f”,
“name”: “user_id”,
“value”: “={{ $(‘Telegram Trigger’).item.json.message.from.id }}”,
“type”: “string”
},
{
“id”: “c58ae87e-c307-4af6-945f-bb8350aafc3d”,
“name”: “username”,
“value”: “={{ $(‘Telegram Trigger’).item.json.message.from.username }}”,
“type”: “string”
},
{
“id”: “a44439db-9b02-4093-9cc9-19af6c9e1a3c”,
“name”: “first_name”,
“value”: “={{ $(‘Telegram Trigger’).item.json.message.from.first_name }}”,
“type”: “string”
},
{
“id”: “d65b621c-b717-408d-b88c-20690ebb9b90”,
“name”: “update”,
“value”: “={{ $(‘Telegram Trigger’).item.json }}”,
“type”: “string”
}
]
},
“includeOtherFields”: true,
“options”: {}
},
“id”: “de39bfd1-413a-43a6-93b4-d2326d90f7f6”,
“name”: “Set Final Text”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-528,
272
]
},
{
“parameters”: {
“model”: {
“__rl”: true,
“value”: “gpt-4o-mini”,
“mode”: “list”,
“cachedResultName”: “gpt-4o-mini”
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
384,
512
],
“id”: “ba0c1253-e9c3-4d82-9f8d-e05dde0d488b”,
“name”: “4o-mini”,
“credentials”: {
“openAiApi”: {
“id”: “vj57XTtwxvs1wLSP”,
“name”: “OpenAi account 2”
}
}
}
],
“pinData”: {},
“connections”: {
“Telegram Trigger”: {
“main”: [
[
{
“node”: “Switch”,
“type”: “main”,
“index”: 0
}
]
]
},
“Switch”: {
“main”: [
[
{
“node”: “Download File”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Set Final Text”,
“type”: “main”,
“index”: 0
}
]
]
},
“Download File”: {
“main”: [
[
{
“node”: “Transcribe”,
“type”: “main”,
“index”: 0
}
]
]
},
“Transcribe”: {
“main”: [
[
{
“node”: “Set Final Text”,
“type”: “main”,
“index”: 0
}
]
]
},
“Embeddings OpenAI”: {
“ai_embedding”: [
[
{
“node”: “DATA BASE”,
“type”: “ai_embedding”,
“index”: 0
}
]
]
},
“Save User Message”: {
“main”: [
[
{
“node”: “ИНФО АГЕНТ”,
“type”: “main”,
“index”: 0
},
{
“node”: “Typing 1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Response”: {
“main”: [
[
{
“node”: “Save Bot Message”,
“type”: “main”,
“index”: 0
}
]
]
},
“ИНФО АГЕНТ”: {
“main”: [
[
{
“node”: “Response”,
“type”: “main”,
“index”: 0
}
]
]
},
“DATA BASE”: {
“ai_vectorStore”: [
[
{
“node”: “DATA_TOOL”,
“type”: “ai_vectorStore”,
“index”: 0
}
]
]
},
“DATA_TOOL”: {
“ai_tool”: [
[
{
“node”: “ИНФО АГЕНТ”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“ВРЕМЕННАЯ ПАМЯТЬ 1”: {
“ai_memory”: [
[
{
“node”: “ИНФО АГЕНТ”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“МОЗГ 1”: {
“ai_languageModel”: [
[
{
“node”: “ИНФО АГЕНТ”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Set Final Text”: {
“main”: [
[
{
“node”: “Save User Message”,
“type”: “main”,
“index”: 0
}
]
]
},
“4o-mini”: {
“ai_languageModel”: [
[
{
“node”: “DATA_TOOL”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
}
},
“active”: false,
“settings”: {
“executionOrder”: “v1”
},
“versionId”: “c2292dd0-e9e3-4165-907c-601fad895661”,
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “3091918d3fbc45a53bc69df1cd50497ab92a0e89b8011cbad121267c1c5393fa”
},
“id”: “JpdMUEUdJkREr3l6”,
“tags”:
}