This workflow corresponds to n8n.io template #10653 — we link there as the canonical source.
This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "0db018d8-693f-4e47-be62-4b34d7b8d77f",
"name": "Embeddings Google Gemini",
"type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
"position": [
912,
592
],
"parameters": {},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "edf2e17e-a730-486b-8e2a-8acaef9e84a3",
"name": "Supabase Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
912,
400
],
"parameters": {
"mode": "retrieve-as-tool",
"options": {},
"tableName": {
"__rl": true,
"mode": "list",
"value": "documents",
"cachedResultName": "documents"
},
"toolDescription": "Use this tool to search and retrieve relevant information from the user's study materials stored in the vector database. Query the documents to answer user questions accurately."
},
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "1a55495f-44be-4c71-9a9d-f4886a8980a8",
"name": "Postgres Chat Memory",
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"position": [
368,
608
],
"parameters": {
"sessionKey": "={{ $json.sessionId }}",
"sessionIdType": "customKey",
"contextWindowLength": 10
},
"credentials": {
"postgres": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "39d7a9b3-66d8-41fb-8454-6a80885131d1",
"name": "Calculator",
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"position": [
768,
464
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d943532d-4ae7-4829-a381-191cf84ea622",
"name": "When chat message received",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
176,
192
],
"parameters": {
"public": true,
"options": {}
},
"typeVersion": 1.3
},
{
"id": "f37c1723-0049-4b1d-8354-3acfd5179cb4",
"name": "Google Gemini Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
256,
448
],
"parameters": {
"options": {},
"modelName": "models/gemini-2.5-pro"
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "225fb496-37d1-4dd7-b008-179ebb0880cc",
"name": "Folder all file to vector",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
576,
448
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "DXm6uptDmBBGVVWV",
"cachedResultUrl": "/workflow/DXm6uptDmBBGVVWV",
"cachedResultName": "Drive folder all file to Supabase Vector Store Database for RAG"
},
"workflowInputs": {
"value": {
"Drive_Folder_link": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Drive_Folder_link', ``, 'string') }}"
},
"schema": [
{
"id": "Drive_Folder_link",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Drive_Folder_link",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Drive_Folder_link"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
"name": "Study Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
448,
192
],
"parameters": {
"text": "={{ $json.chatInput }}",
"options": {
"systemMessage": "You are a Study AI Assistant that helps users interact with their study materials in a natural, conversational way.\n\n## Core Behavior\n\n**Always respond conversationally and helpfully.** You can answer questions, provide information from stored materials, and assist with file uploads - all while maintaining a friendly, natural dialogue.\n\n## Input Handling\n\n### 1. Google Drive Links\nWhen you detect a Google Drive URL (folder or file):\n- **Pattern**: `https://drive.google.com/drive/folders/` or `https://drive.google.com/file/d/`\n- **Action**: Automatically trigger the `DriveFolderToSupabase` workflow\n- **Response**: Confirm the upload is processing: \"I'm uploading your files to the vector store. This will take a moment...\"\n\n### 2. Study Material Queries\nWhen users ask questions about their materials:\n- **Search the vector store** using available retrieval tools\n- **Always check the vector store first** before saying you don't have information\n- Provide clear, helpful answers with citations\n- Include document names, sections, or page numbers when available\n\n### 3. General Conversation\nWhen users engage in general conversation:\n- Respond naturally and helpfully\n- If they're asking about themselves or their materials, **search the vector store**\n- Use context from previous messages in the conversation\n- Be conversational, not robotic\n\n## Critical Rules\n\n1. **Never refuse to search**: If someone asks \"what is in the documents\" or \"tell me about X\", immediately query the vector store with relevant keywords\n2. **Infer intent**: Questions like \"about me\", \"what's my name\", or \"vector database\" should trigger a vector store search for relevant content\n3. **Use broad searches**: When unsure, search with general terms rather than refusing to help\n4. **Acknowledge limitations gracefully**: Only say you can't find information AFTER searching, not before\n5. **Maintain conversation context**: Reference previous exchanges naturally\n\n## Search Strategy\n\nWhen querying the vector store:\n- Use **keywords and concepts** from the user's question\n- Try **multiple related terms** if the first search yields poor results\n- For vague queries like \"tell me what's in the documents\", search with terms like: \"overview\", \"introduction\", \"main topic\", \"summary\"\n- **Always attempt a search** before saying you don't have the information\n\n## Response Format\n\n- **Direct answers** to questions\n- **Cite sources** when providing information from documents\n- **Suggest related topics** when appropriate\n- **Ask clarifying questions** only when absolutely necessary (not as a default)\n\n## Examples\n\n**Bad Response**: \"I need a specific question or topic to search for.\"\n**Good Response**: *[Searches vector store]* \"Based on your uploaded materials, I found information about [topic]. Here's what I can tell you...\"\n\n**Bad Response**: \"I don't have access to personal information like your name.\"\n**Good Response**: *[Searches vector store for personal info]* \"I searched your documents and found [relevant information], or if nothing is found: \"I searched your uploaded materials but didn't find personal information stored. What would you like to know about your study content?\"\n"
},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"id": "cf65699a-9e5a-4c24-b256-fe3892c154fd",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-224,
96
],
"parameters": {
"width": 336,
"height": 640,
"content": "# \ud83e\udd16 AI Study Assistant (RAG Chat)\n\n**Purpose:** Conversational AI that helps you study by answering questions from your uploaded documents.\n\n**Flow:** Chat Input \u2192 AI Agent \u2192 Vector Search + Memory + Tools \u2192 Response\n\n**Key Features:**\n- Natural conversation with your study materials\n- Auto-processes Drive links shared in chat\n- Semantic search across documents\n- Persistent chat memory\n- Calculator for math problems\n\n**Tools Connected:**\n1. Supabase Vector Store (document search)\n2. Drive Folder Uploader (auto-index new files)\n3. Calculator (math operations)\n4. Postgres Memory (conversation history)\n"
},
"typeVersion": 1
},
{
"id": "eddf672b-4bd8-45d6-bf4e-29ddd688f1e5",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
416,
32
],
"parameters": {
"color": 4,
"width": 288,
"height": 352,
"content": "**AI Agent (Core)** - Orchestrates all tools and memory. Handles Drive links, searches documents, maintains context, and responds naturally using Gemini 2.5 Pro.\n"
},
"typeVersion": 1
},
{
"id": "c201dfbd-714c-4629-8a49-9acc006af38a",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
912,
256
],
"parameters": {
"height": 272,
"content": "**Document Search Tool** - Retrieves relevant information from uploaded study materials using semantic similarity search with 768-dim embeddings.\n"
},
"typeVersion": 1
},
{
"id": "e29b5f39-3fcb-40b2-9ba0-02ef7d070f2a",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
512,
512
],
"parameters": {
"height": 208,
"content": "\n\n\n\n\n\n**Drive Uploader Tool** - When user shares a Drive link in chat, automatically triggers the indexing workflow to add files to vector store.\n"
},
"typeVersion": 1
},
{
"id": "54a5e290-1ec4-4b97-96ed-d424aaf3c2ca",
"name": "Embeddings Google Gemini4",
"type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
"position": [
1232,
1392
],
"parameters": {},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "7682b868-5215-452d-b110-ff8007f2d059",
"name": "Default Data Loader2",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1408,
1376
],
"parameters": {
"options": {},
"dataType": "binary"
},
"typeVersion": 1.1
},
{
"id": "ceacbea3-3c6a-47d1-83a6-386cb1166414",
"name": "Execute a SQL query",
"type": "n8n-nodes-base.postgres",
"position": [
400,
1120
],
"parameters": {
"query": "DROP TABLE IF EXISTS documents CASCADE;\n\nCREATE EXTENSION IF NOT EXISTS vector;\n\nCREATE TABLE IF NOT EXISTS documents (\n id bigserial PRIMARY KEY,\n content text,\n metadata jsonb,\n embedding vector(768)\n);\n\nCREATE OR REPLACE FUNCTION match_documents(\n query_embedding vector(768),\n match_count int DEFAULT NULL,\n filter jsonb DEFAULT '{}'::jsonb\n)\nRETURNS TABLE (\n id bigint,\n content text,\n metadata jsonb,\n similarity double precision\n)\nLANGUAGE sql\nAS $$\n SELECT\n d.id,\n d.content,\n d.metadata,\n 1 - (d.embedding <=> query_embedding) AS similarity\n FROM documents d\n WHERE (filter = '{}'::jsonb OR d.metadata @> filter)\n ORDER BY d.embedding <=> query_embedding\n LIMIT match_count;\n$$;\n",
"options": {},
"operation": "executeQuery"
},
"credentials": {
"postgres": {
"name": "<your credential>"
}
},
"typeVersion": 2.6
},
{
"id": "90883ae9-8d17-4a72-83be-da4dae013343",
"name": "Code in JavaScript",
"type": "n8n-nodes-base.code",
"position": [
176,
1120
],
"parameters": {
"jsCode": "// Get the Drive_Folder_link from the workflow input\nconst driveUrl = $input.first().json.Drive_Folder_link;\n\n// Extract Google Drive folder/file ID from URL\nfunction getDriveId(url) {\n const folderMatch = url.match(/\\/folders\\/([a-zA-Z0-9_-]+)/);\n const fileMatch = url.match(/\\/file\\/d\\/([a-zA-Z0-9_-]+)/);\n return folderMatch ? folderMatch[1] : (fileMatch ? fileMatch[1] : null);\n}\n\n// Process input items\nreturn items.map(item => {\n const chatInput = item.json.chatInput || driveUrl || '';\n const driveId = getDriveId(chatInput);\n\n return {\n json: {\n originalInput: chatInput,\n folderId: driveId,\n driveId: driveId\n }\n };\n});\n"
},
"typeVersion": 2
},
{
"id": "1e5ac5c6-ae2c-400d-b531-a18c823a3d07",
"name": "When Executed by Another Workflow",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
-32,
1120
],
"parameters": {
"inputSource": "jsonExample",
"jsonExample": "{\n \"Drive_Folder_link\": \"https://drive.google.com/drive/folders/example\"\n}"
},
"typeVersion": 1.1
},
{
"id": "472c0470-a590-476a-b23b-77617b042a39",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"position": [
832,
1120
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "8e8a66a7-9a2c-4ed9-91b3-80d805b1dbab",
"name": "Search files and folders",
"type": "n8n-nodes-base.googleDrive",
"position": [
608,
1120
],
"parameters": {
"filter": {
"folderId": {
"__rl": true,
"mode": "id",
"value": "={{ $('Code in JavaScript').item.json.folderId }}"
}
},
"options": {},
"resource": "fileFolder"
},
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 3
},
{
"id": "21559a2e-f0d3-40a1-8809-5f2a31cde811",
"name": "Insert into Supabase Vectorstore",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
1280,
1120
],
"parameters": {
"mode": "insert",
"options": {
"queryName": "match_documents"
},
"tableName": {
"__rl": true,
"mode": "list",
"value": "documents",
"cachedResultName": "documents"
}
},
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "a818d7b0-1c5e-4273-96d1-d72ff2960823",
"name": "Download File",
"type": "n8n-nodes-base.googleDrive",
"position": [
1072,
1136
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {
"googleFileConversion": {
"conversion": {
"docsToFormat": "text/plain"
}
}
},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 3
},
{
"id": "0cf08172-6b3e-44a9-aec7-44a2b5e582ff",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
592,
1296
],
"parameters": {
"width": 176,
"height": 128,
"content": "**List Drive Files** - Retrieves all files from the specified Google Drive folder using extracted folder ID.\n"
},
"typeVersion": 1
},
{
"id": "98009dab-d49a-4205-9d9b-da29c3560d98",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1040,
960
],
"parameters": {
"width": 150,
"content": "**List Drive Files** - Retrieves all files from the specified Google Drive folder using extracted folder ID.\n"
},
"typeVersion": 1
},
{
"id": "57415dae-d6cd-4c5a-8305-ee9100bec975",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1264,
864
],
"parameters": {
"color": 7,
"height": 240,
"content": "**Store Embeddings** - Generates 768-dim vectors via Gemini and inserts documents into Supabase for semantic search.\n**AI Embeddings** - Converts text to 768-dimensional vectors using Google Gemini text-embedding-004 model.\n**Document Loader** - Extracts and formats text from binary files for the embedding generator.\n"
},
"typeVersion": 1
},
{
"id": "677fd038-4cd9-483b-84ff-98373a6affb4",
"name": "Sticky Note7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
944
],
"parameters": {
"color": 5,
"width": 368,
"height": 512,
"content": "# \ud83d\udcc1 Drive to Supabase Vector Store for Study RAG\n\nProcesses Google Drive folder files into Supabase vector embeddings for RAG applications.\n\n**Flow:** Drive URL \u2192 Parse ID \u2192 Init DB \u2192 Fetch Files \u2192 Loop \u2192 Download \u2192 Embed \u2192 Store\n\n**Requirements:**\n- Google Drive OAuth2\n- Supabase + Postgres credentials\n- Google Gemini API key\n\n**Input:** `{\"Drive_Folder_link\": \"your_drive_url\"}`\n**Output:** Vector embeddings in Supabase documents table\n"
},
"typeVersion": 1
},
{
"id": "975c4447-f0fe-48fd-afb9-e4da35b30080",
"name": "Sticky Note8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
1280
],
"parameters": {
"width": 176,
"height": 128,
"content": "**Trigger Node** - Starts workflow when called from another n8n workflow. Accepts Drive folder URL as input.\n"
},
"typeVersion": 1
},
{
"id": "a9cdb11e-fbb5-43b8-aa5d-6ea48be4fc85",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
160,
1280
],
"parameters": {
"width": 150,
"height": 128,
"content": "**Extract Folder ID** - Parses Google Drive URL using regex to extract folder/file ID for API calls.\n"
},
"typeVersion": 1
},
{
"id": "01282543-fd57-4815-af73-bf26a2ff4a12",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"position": [
368,
1280
],
"parameters": {
"width": 176,
"content": "**Initialize Database** - Creates Supabase vector table with pgvector extension and match_documents search function. \u26a0\ufe0f Drops existing table!\n"
},
"typeVersion": 1
}
],
"connections": {
"Calculator": {
"ai_tool": [
[
{
"node": "Study Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Download File": {
"main": [
[
{
"node": "Insert into Supabase Vectorstore",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Download File",
"type": "main",
"index": 0
}
]
]
},
"Code in JavaScript": {
"main": [
[
{
"node": "Execute a SQL query",
"type": "main",
"index": 0
}
]
]
},
"Execute a SQL query": {
"main": [
[
{
"node": "Search files and folders",
"type": "main",
"index": 0
}
]
]
},
"Default Data Loader2": {
"ai_document": [
[
{
"node": "Insert into Supabase Vectorstore",
"type": "ai_document",
"index": 0
}
]
]
},
"Postgres Chat Memory": {
"ai_memory": [
[
{
"node": "Study Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Supabase Vector Store": {
"ai_tool": [
[
{
"node": "Study Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Embeddings Google Gemini": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "Study Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Search files and folders": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Embeddings Google Gemini4": {
"ai_embedding": [
[
{
"node": "Insert into Supabase Vectorstore",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Folder all file to vector": {
"ai_tool": [
[
{
"node": "Study Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Study Agent",
"type": "main",
"index": 0
}
]
]
},
"Insert into Supabase Vectorstore": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Code in JavaScript",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
googleDriveOAuth2ApigooglePalmApipostgressupabaseApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
A complete AI-powered study assistant system that lets you chat naturally with your documents stored in Google Drive:
Source: https://n8n.io/workflows/10653/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow acts as a 24/7 sales agent, engaging leads across WhatsApp, Instagram, Facebook, Telegram, and your website. It intelligently transcribes audio messages, answers questions using a knowle
• Create a Google Drive folder to watch. • Connect your Google Drive account in n8n and authorize access. • Point the Google Drive Trigger node to this folder (new/modified files trigger the flow).
use cases: research stock market in Indonesia. analyze the performance of companies belonging to certain subsectors or company comparing financial metrics between BBCA and BBRI providing technical ana
The workflow operates through a three-step process that handles incoming chat messages with intelligent tool orchestration: Message Trigger: The node triggers whenever a user message arrives and passe
An extendable RAG template to build powerful, explainable AI assistants — with query understanding, semantic metadata, and support for free-tier tools like Gemini, Gemma and Supabase.