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 →
{
"name": "Supabase RAG AI Agent",
"nodes": [
{
"parameters": {
"model": "gpt-4o-mini",
"options": {}
},
"id": "b98c17c5-3bef-4378-8d81-61b127711661",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
860,
520
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"model": "gpt-4o-mini",
"options": {}
},
"id": "e850aa69-1910-4986-99f2-214a8759b777",
"name": "OpenAI Chat Model1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [
1880,
460
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsonMode": "expressionData",
"jsonData": "={{ $json.data }}",
"options": {
"metadata": {
"metadataValues": [
{
"name": "=file_id",
"value": "={{ $('Set File ID').item.json.file_id }}"
}
]
}
}
},
"id": "9f5b6c56-58f6-4ae5-96fd-f3efd9b35fd6",
"name": "Default Data Loader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"typeVersion": 1,
"position": [
2020,
1000
]
},
{
"parameters": {
"model": "text-embedding-3-small",
"options": {}
},
"id": "5eaf6315-fcd0-4a4d-a1b3-37f5793f6e5c",
"name": "Embeddings OpenAI1",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1,
"position": [
1860,
1000
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"name": "user_documents",
"description": "Contains all the user's documents that you can check for context to answer user questions."
},
"id": "b3868e8d-fbce-4c16-8174-0e5475cfffba",
"name": "Retrieve Documents",
"type": "@n8n/n8n-nodes-langchain.toolVectorStore",
"typeVersion": 1,
"position": [
1660,
280
]
},
{
"parameters": {
"content": "## Agent Tools for RAG",
"height": 528.85546469693,
"width": 583.4552380860637,
"color": 4
},
"id": "d4a657c6-2f17-4071-8cee-0b1b12f74b1c",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
1480,
160
]
},
{
"parameters": {
"content": "## Tool to Add a Google Drive File to Vector DB",
"height": 671.8877842322804,
"width": 2070.8894079025763,
"color": 5
},
"id": "38517d9e-61cf-4b36-bbb2-607a04e870c8",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
260,
700
]
},
{
"parameters": {
"operation": "download",
"fileId": {
"__rl": true,
"value": "={{ $('Set File ID').item.json.file_id }}",
"mode": "id"
},
"options": {
"googleFileConversion": {
"conversion": {
"docsToFormat": "text/plain"
}
}
}
},
"id": "d9e3d812-9158-44e2-b9e9-8c28c5cd0921",
"name": "Download File",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [
1360,
880
],
"executeOnce": true,
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"triggerOn": "specificFolder",
"folderToWatch": {
"__rl": true,
"value": "1914m3M7kRzkd5RJqAfzRY9EBcJrKemZC",
"mode": "list",
"cachedResultName": "Meeting Notes",
"cachedResultUrl": "https://drive.google.com/drive/folders/1914m3M7kRzkd5RJqAfzRY9EBcJrKemZC"
},
"event": "fileCreated",
"options": {}
},
"id": "6c24f48d-2a8e-471d-b477-dd9576e57eec",
"name": "File Created",
"type": "n8n-nodes-base.googleDriveTrigger",
"typeVersion": 1,
"position": [
320,
780
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"triggerOn": "specificFolder",
"folderToWatch": {
"__rl": true,
"value": "1914m3M7kRzkd5RJqAfzRY9EBcJrKemZC",
"mode": "list",
"cachedResultName": "Meeting Notes",
"cachedResultUrl": "https://drive.google.com/drive/folders/1914m3M7kRzkd5RJqAfzRY9EBcJrKemZC"
},
"event": "fileUpdated",
"options": {}
},
"id": "7bf930ea-3810-40e3-a252-c13da33660db",
"name": "File Updated",
"type": "n8n-nodes-base.googleDriveTrigger",
"typeVersion": 1,
"position": [
320,
1000
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "text",
"options": {}
},
"id": "81e0f199-024b-489d-88dd-e7bf6c3a453b",
"name": "Extract Document Text",
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
1620,
880
],
"alwaysOutputData": true
},
{
"parameters": {
"model": "text-embedding-3-small",
"options": {}
},
"id": "c0f6a1f6-5732-48e3-8830-bb78263bd352",
"name": "Embeddings OpenAI",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1,
"position": [
1700,
560
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {},
"id": "8920aea0-c877-47b3-9026-d8ab57e8579d",
"name": "Postgres Chat Memory",
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1,
"position": [
1000,
520
],
"notesInFlow": false,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"options": {}
},
"id": "ed70601e-e7e9-4fc5-af9f-bdf4a931fc48",
"name": "Recursive Character Text Splitter",
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"typeVersion": 1,
"position": [
2020,
1200
]
},
{
"parameters": {
"operation": "delete",
"tableId": "documents",
"filterType": "string",
"filterString": "=metadata->>file_id=like.*{{ $json.file_id }}*"
},
"id": "bd9eb3dc-75b9-4577-a210-1951988a389e",
"name": "Delete Old Doc Rows",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
1060,
880
],
"alwaysOutputData": true,
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "10646eae-ae46-4327-a4dc-9987c2d76173",
"name": "file_id",
"value": "={{ $json.id }}",
"type": "string"
}
]
},
"options": {}
},
"id": "0b439eba-c467-475b-a1a2-481f636f37fe",
"name": "Set File ID",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
740,
880
]
},
{
"parameters": {
"content": "## RAG AI Agent with Chat Interface",
"height": 464.8027193303974,
"width": 1035.6381264595484
},
"id": "7c003acd-f420-474f-9547-33e13c3c357f",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
432.49413148117685,
220
]
},
{
"parameters": {
"tableName": {
"__rl": true,
"value": "documents",
"mode": "list",
"cachedResultName": "documents"
},
"options": {
"queryName": "match_documents"
}
},
"id": "1bda5922-bcfb-489c-a0fb-516d9496d54a",
"name": "Supabase Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"typeVersion": 1,
"position": [
1540,
440
],
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"options": {}
},
"id": "dd1086c5-e813-49ea-971f-ba01ccc6f803",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1300,
300
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "9a9a245e-f1a1-4282-bb02-a81ffe629f0f",
"name": "chatInput",
"value": "={{ $json?.chatInput || $json.body.chatInput }}",
"type": "string"
},
{
"id": "b80831d8-c653-4203-8706-adedfdb98f77",
"name": "sessionId",
"value": "={{ $json?.sessionId || $json.body.sessionId}}",
"type": "string"
}
]
},
"options": {}
},
"id": "4076ba7c-931d-40f5-872d-c9b2dc669ab1",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
740,
300
]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.chatInput }}",
"options": {
"systemMessage": "You are a personal assistant who helps answer questions from a corpus of documents when you don't know the answer yourself."
}
},
"id": "50003c9d-29bf-4d0e-9e04-a49804742dc8",
"name": "RAG AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.6,
"position": [
960,
300
]
},
{
"parameters": {
"mode": "insert",
"tableName": {
"__rl": true,
"value": "documents",
"mode": "list",
"cachedResultName": "documents"
},
"options": {
"queryName": "match_documents"
}
},
"id": "6c7181ba-9e33-4972-83b4-0efaac7e16a2",
"name": "Insert into Supabase Vectorstore",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"typeVersion": 1,
"position": [
1900,
780
],
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"public": true,
"options": {}
},
"id": "e448d46a-7a01-436c-bebd-0cd21c2bfcb3",
"name": "When chat message received",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
480,
300
]
},
{
"parameters": {
"httpMethod": "POST",
"path": "invoke_agent",
"authentication": "headerAuth",
"responseMode": "responseNode",
"options": {}
},
"id": "b575cc9f-71c7-4406-936c-ca39e6eff09b",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
480,
500
],
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
}
}
],
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "RAG AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Retrieve Documents",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Retrieve Documents": {
"ai_tool": [
[
{
"node": "RAG AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Download File": {
"main": [
[
{
"node": "Extract Document Text",
"type": "main",
"index": 0
}
]
]
},
"File Created": {
"main": [
[
{
"node": "Set File ID",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Extract Document Text": {
"main": [
[
{
"node": "Insert into Supabase Vectorstore",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Insert into Supabase Vectorstore",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Insert into Supabase Vectorstore",
"type": "ai_document",
"index": 0
}
]
]
},
"Postgres Chat Memory": {
"ai_memory": [
[
{
"node": "RAG AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"Delete Old Doc Rows": {
"main": [
[
{
"node": "Download File",
"type": "main",
"index": 0
}
]
]
},
"Set File ID": {
"main": [
[
{
"node": "Delete Old Doc Rows",
"type": "main",
"index": 0
}
]
]
},
"File Updated": {
"main": [
[
{
"node": "Set File ID",
"type": "main",
"index": 0
}
]
]
},
"Supabase Vector Store": {
"ai_vectorStore": [
[
{
"node": "Retrieve Documents",
"type": "ai_vectorStore",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "RAG AI Agent",
"type": "main",
"index": 0
}
]
]
},
"RAG AI Agent": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
},
"versionId": "3c35c49a-bc44-4379-b6f0-109f579f79bc",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "cri0nBz0U55sWr4I",
"tags": []
}
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.
googleDriveOAuth2ApihttpHeaderAuthopenAiApipostgressupabaseApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
How this works
This workflow empowers teams to build an intelligent AI agent that retrieves and reasons over documents stored in Supabase using retrieval-augmented generation (RAG), delivering accurate, context-aware responses to user queries without manual searching. It's ideal for knowledge workers, support teams, or developers who need quick insights from large document repositories, such as reports or manuals, integrated seamlessly with Google Drive for file handling. The key step involves embedding documents via OpenAI's embeddings model, storing them in a vector database, and then retrieving relevant chunks to inform the AI's chat responses powered by OpenAI's language model.
Use this workflow when you have unstructured data in Google Drive that requires on-demand querying, like customer support FAQs or internal wikis, to automate responses and reduce response times. Avoid it for simple keyword searches or when data is highly structured and better suited to traditional databases, as the RAG setup adds complexity for basic needs. Common variations include swapping Google Drive for other file sources or fine-tuning the retrieval threshold for more precise results in specialised domains.
About this workflow
Supabase RAG AI Agent. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, toolVectorStore. Event-driven trigger; 24 nodes.
Source: https://github.com/daboi2331/ai-agents-masterclass/blob/main/n8n-streamlit-agent/Supabase_RAG_AI_Agent_Basic_Auth.json — 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.
Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.
Your AI workforce is ready. Are you?
Agent IA Projet Client. Uses executeWorkflowTrigger, lmChatOpenAi, toolWorkflow, vectorStoreQdrant. Event-driven trigger; 79 nodes.
This intelligent chatbot leverages cutting-edge financial APIs and AI-driven analysis to deliver comprehensive stock research reports. Get instant access to professional-grade investment analysis that
RAG_Ingest. Uses httpRequest, vectorStoreSupabase, documentDefaultDataLoader, textSplitterRecursiveCharacterTextSplitter. Event-driven trigger; 73 nodes.