Skip to main content

Document-based RAG chat assistant with Google Drive, Supabase & OpenAI

Workflow preview

Workflow preview
100%
Document-based RAG chat assistant with Google Drive, Supabase & OpenAI preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

What is this? This RAG workflow allows you to build a smart chat assistant that can answer user questions based on any collection of documents you provide. It automatically imports and processes fi...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.vectorstoresupabase, @n8n/n8n-nodes-langchain.embeddingsopenai, n8n-nodes-base.set, n8n-nodes-base.googledrive, @n8n/n8n-nodes-langchain.documentdefaultdataloader, n8n-nodes-base.switch

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Jainik Sheth.

Original n8n.io source

1.1 Workflow description

Title
Document-based RAG chat assistant with Google Drive, Supabase & OpenAI
Workflow name
Document-based RAG chat assistant with Google Drive, Supabase & OpenAI

What is this?

This RAG workflow allows you to build a smart chat assistant that can answer user questions based on any collection of documents you provide. It automatically imports and processes files from Google Drive, stores their content in a searchable vector database, and retrieves the most relevant information to generate accurate, context-driven responses. The workflow manages chat sessions and keeps the document database current, making it adaptable for use cases like customer support, internal knowledge bases, or HR assistant etc.

How it works

1. Chat RAG Agent

  • Uses OpenAI for responses, referencing only specific data from the vector store (data that is uploaded on google drive folder).
  • Maintains chat history in Postgres using a session key from the chat input.

2. Data Pipeline (File Ingestion)

  • Monitors Google Drive for new/updated files and automatically updates them in vector store
  • Downloads, extracts, and processes file content (PDFs, Google Docs).
  • Generates embeddings and stores them in the Supabase vector store for retrieval.

3. Vector Store Cleanup

  • Scheduled and manual routines to remove duplicate or outdated entries from the Supabase vector store.
  • Ensures only the latest and unique documents are available for retrieval.

4. File Management

  • Handles folder and file creation, upload, and metadata assignment in Google Drive.
  • Ensures files are organized and linked with their corresponding vector store entries.

Getting Started

  • Create and connect all relevant credentials
    • Google Drive
    • Postgres
    • Supabase
    • OpenAI
  • Run the table creation nodes first to set up your database tables in Postgres
  • Upload your documents through Google Drive (or swap out for a different file storage solution)
  • The agent will process them automatically (chunking text, storing tabular data in Postgres)
  • Start asking questions that leverage the agent's multiple reasoning approaches

Customization (optional)

This template provides a solid foundation that you can extend by:

  • Tuning the system prompt for your specific use case
  • Adding document metadata like summaries
  • Implementing more advanced RAG techniques
  • Optimizing for larger knowledge bases
  • Note, if you're using a different nodes eg. file storage, vector store etc the integration may vary a little

Prerequisites

  • Google account (google drive)
  • Supabase account
  • OpenAI APIs
  • Postgres account

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.2

Block 2 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 3 - Supabase Vector Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1.3

Block 4 - Embeddings OpenAI

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 5 - Edit Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 6 - Download file

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 7 - Supabase Vector Store1

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1.3

Block 8 - Embeddings OpenAI1

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 9 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1.1

Block 10 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 11 - Switch1

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 12 - Edit Fields1

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Create folder

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 14 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 15 - Upload file

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 16 - Update File

Type / Role
n8n-nodes-base.googleDriveTrigger - googleDriveTrigger
Config choices
Version 1

Block 17 - New File

Type / Role
n8n-nodes-base.googleDriveTrigger - googleDriveTrigger
Config choices
Version 1

Block 18 - Delete a row

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 19 - Remove Duplicates

Type / Role
n8n-nodes-base.removeDuplicates - removeDuplicates
Config choices
Version 2

Block 20 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 24 - Search files and folders

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Showing the first 24 of 37 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Document-based RAG chat assistant with Google Drive, Supabase & OpenAI
Complexity advanced
Nodes 37
Categories Internal Wiki, AI RAG
Author Jainik Sheth
Published 09 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9398/9398.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Document-based RAG chat assistant with Google Drive, Supabase & OpenAI do?

What is this? This RAG workflow allows you to build a smart chat assistant that can answer user questions based on any collection of documents you provide. It automatically imports and processes fi...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.