Assistant d'Apprentissage IA (RAG) : Google Gemini avec Drive et Recherche Vectorielle Supabase
Ceci est unPersonal Productivity, AI RAGworkflow d'automatisation du domainecontenant 28 nœuds.Utilise principalement des nœuds comme Code, Postgres, GoogleDrive, SplitInBatches, Agent. Assistant d'Apprentissage IA (RAG) : Google Gemini avec Drive et Recherche Vectorielle Supabase
- •Informations de connexion à la base de données PostgreSQL
- •Informations d'identification Google Drive API
- •Clé API Google Gemini
- •URL et Clé API Supabase
Nœuds utilisés (28)
Catégorie
{
"meta": {
"instanceId": "a243f35537ecbb3a29ba49c4cf2200720075b362bcc7d02523f79748238bcfd6",
"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": {
"id": "VCZQfcHNj0rHxcNf",
"name": "GEMINI_API_KUDDUS"
}
},
"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": {
"id": "OweRv8RLSfhKJyfg",
"name": "Supabase account"
}
},
"typeVersion": 1.3
},
{
"id": "1a55495f-44be-4c71-9a9d-f4886a8980a8",
"name": "Mémoire de chat Postgres",
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"position": [
368,
608
],
"parameters": {
"sessionKey": "={{ $json.sessionId }}",
"sessionIdType": "customKey",
"contextWindowLength": 10
},
"credentials": {
"postgres": {
"id": "KbYSAyR6T3ljhFKn",
"name": "Postgres account"
}
},
"typeVersion": 1.3
},
{
"id": "39d7a9b3-66d8-41fb-8454-6a80885131d1",
"name": "Calculateur",
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"position": [
768,
464
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d943532d-4ae7-4829-a381-191cf84ea622",
"name": "À réception d'un message de chat",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
176,
192
],
"webhookId": "6f7911bb-b08c-40ba-b613-a81d3d26ee18",
"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": {
"id": "VCZQfcHNj0rHxcNf",
"name": "GEMINI_API_KUDDUS"
}
},
"typeVersion": 1
},
{
"id": "225fb496-37d1-4dd7-b008-179ebb0880cc",
"name": "Conversion de dossiers/fichiers en vecteurs",
"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": "Agent d'étude",
"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": "Note adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
-224,
96
],
"parameters": {
"width": 336,
"height": 640,
"content": "# 🤖 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 → AI Agent → Vector Search + Memory + Tools → 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": "Note adhésive 1",
"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": "Note adhésive 2",
"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": "Note adhésive 3",
"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": {
"id": "VCZQfcHNj0rHxcNf",
"name": "GEMINI_API_KUDDUS"
}
},
"typeVersion": 1
},
{
"id": "7682b868-5215-452d-b110-ff8007f2d059",
"name": "Chargeur de données par défaut 2",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1408,
1376
],
"parameters": {
"options": {},
"dataType": "binary"
},
"typeVersion": 1.1
},
{
"id": "ceacbea3-3c6a-47d1-83a6-386cb1166414",
"name": "Exécuter une requête SQL",
"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": {
"id": "KbYSAyR6T3ljhFKn",
"name": "Postgres account"
}
},
"typeVersion": 2.6
},
{
"id": "90883ae9-8d17-4a72-83be-da4dae013343",
"name": "Code en 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": "Lorsqu'exécuté par un autre 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": "Boucle sur les éléments",
"type": "n8n-nodes-base.splitInBatches",
"position": [
832,
1120
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "8e8a66a7-9a2c-4ed9-91b3-80d805b1dbab",
"name": "Rechercher fichiers et dossiers",
"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": {
"id": "CVN95k3ctbjWs60e",
"name": "Google_Drive_gaming"
}
},
"typeVersion": 3
},
{
"id": "21559a2e-f0d3-40a1-8809-5f2a31cde811",
"name": "Insertion dans 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": {
"id": "OweRv8RLSfhKJyfg",
"name": "Supabase account"
}
},
"typeVersion": 1
},
{
"id": "a818d7b0-1c5e-4273-96d1-d72ff2960823",
"name": "Télécharger le fichier",
"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": {
"id": "CVN95k3ctbjWs60e",
"name": "Google_Drive_gaming"
}
},
"typeVersion": 3
},
{
"id": "0cf08172-6b3e-44a9-aec7-44a2b5e582ff",
"name": "Note adhésive 4",
"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": "Note adhésive 5",
"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": "Note adhésive 6",
"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": "Note adhésive 7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
944
],
"parameters": {
"color": 5,
"width": 368,
"height": 512,
"content": "# 📁 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 → Parse ID → Init DB → Fetch Files → Loop → Download → Embed → 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": "Note adhésive 8",
"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": "Note adhésive 9",
"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": "Note adhésive 10",
"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. ⚠️ Drops existing table!\n"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"39d7a9b3-66d8-41fb-8454-6a80885131d1": {
"ai_tool": [
[
{
"node": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
"type": "ai_tool",
"index": 0
}
]
]
},
"a818d7b0-1c5e-4273-96d1-d72ff2960823": {
"main": [
[
{
"node": "21559a2e-f0d3-40a1-8809-5f2a31cde811",
"type": "main",
"index": 0
}
]
]
},
"472c0470-a590-476a-b23b-77617b042a39": {
"main": [
[],
[
{
"node": "a818d7b0-1c5e-4273-96d1-d72ff2960823",
"type": "main",
"index": 0
}
]
]
},
"90883ae9-8d17-4a72-83be-da4dae013343": {
"main": [
[
{
"node": "ceacbea3-3c6a-47d1-83a6-386cb1166414",
"type": "main",
"index": 0
}
]
]
},
"ceacbea3-3c6a-47d1-83a6-386cb1166414": {
"main": [
[
{
"node": "8e8a66a7-9a2c-4ed9-91b3-80d805b1dbab",
"type": "main",
"index": 0
}
]
]
},
"7682b868-5215-452d-b110-ff8007f2d059": {
"ai_document": [
[
{
"node": "21559a2e-f0d3-40a1-8809-5f2a31cde811",
"type": "ai_document",
"index": 0
}
]
]
},
"1a55495f-44be-4c71-9a9d-f4886a8980a8": {
"ai_memory": [
[
{
"node": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
"type": "ai_memory",
"index": 0
}
]
]
},
"edf2e17e-a730-486b-8e2a-8acaef9e84a3": {
"ai_tool": [
[
{
"node": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
"type": "ai_tool",
"index": 0
}
]
]
},
"0db018d8-693f-4e47-be62-4b34d7b8d77f": {
"ai_embedding": [
[
{
"node": "edf2e17e-a730-486b-8e2a-8acaef9e84a3",
"type": "ai_embedding",
"index": 0
}
]
]
},
"f37c1723-0049-4b1d-8354-3acfd5179cb4": {
"ai_languageModel": [
[
{
"node": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"8e8a66a7-9a2c-4ed9-91b3-80d805b1dbab": {
"main": [
[
{
"node": "472c0470-a590-476a-b23b-77617b042a39",
"type": "main",
"index": 0
}
]
]
},
"54a5e290-1ec4-4b97-96ed-d424aaf3c2ca": {
"ai_embedding": [
[
{
"node": "21559a2e-f0d3-40a1-8809-5f2a31cde811",
"type": "ai_embedding",
"index": 0
}
]
]
},
"225fb496-37d1-4dd7-b008-179ebb0880cc": {
"ai_tool": [
[
{
"node": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
"type": "ai_tool",
"index": 0
}
]
]
},
"d943532d-4ae7-4829-a381-191cf84ea622": {
"main": [
[
{
"node": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
"type": "main",
"index": 0
}
]
]
},
"21559a2e-f0d3-40a1-8809-5f2a31cde811": {
"main": [
[
{
"node": "472c0470-a590-476a-b23b-77617b042a39",
"type": "main",
"index": 0
}
]
]
},
"1e5ac5c6-ae2c-400d-b531-a18c823a3d07": {
"main": [
[
{
"node": "90883ae9-8d17-4a72-83be-da4dae013343",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Avancé - Productivité personnelle, RAG IA
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
Mantaka Mahir
@mantakamahirAl Automation Expert || Al Agents || n8n || Python || LangChain || Helping businesses scale revenue and reduce costs with Al driven automation .
Partager ce workflow