# Interactive knowledge base chat with Supabase RAG: n8n workflow

> Started by someone opening a chat with it, and works across Gmail, Google Drive, Postgres, Supabase and one other.

Source: https://millionrounds.com/workflow/interactive-knowledge-base-chat-with-supabase-rag (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Data collection](https://millionrounds.com/workflows?category=Data+collection#library)

# Interactive knowledge base chat with Supabase RAG

Started by someone opening a chat with it, and works across Gmail, Google Drive, Postgres, Supabase and one other. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 43 steps, 3 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Finteractive-knowledge-base-chat-with-supabase-rag)

**43 steps** Large: read it before trusting it with anything live

**3** Branches: places the flow splits

**1** Loop or waits

**5** Services it connects to

## The flow

Starts it 3 Model 9 Logic 10 Service 21

The steps in the order they run, from what starts it.

- 1 **File Created** Google Drive trigger *Starts it*
- 2 **Update to File** Google Drive trigger *Starts it*
- 3 **Embeddings OpenAI** Embeddings Open Ai *Model*
- 4 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 5 **Postgres Chat Memory** Memory Postgres Chat *Model*
- 6 **List Documents** Postgres Tool *Service*
- 7 **Query Document Rows** Postgres Tool *Service*
- 8 **Character Text Splitter** Text Splitter Character Text Splitter *Model*
- 9 **When chat message received** Chat trigger *Starts it*
- 10 **Embeddings OpenAI2** Embeddings Open Ai *Model*
- 11 **Get Full Document Text - Get File Contents** Postgres Tool *Service*
- 12 **Loop Over Items** Split In Batches *Logic*
- 13 **Supabase Vector Store** Vector Store Supabase *Model*
- 14 **RAG AI Agent** Agent *Model*
- 15 **Default Data Loader** Document Default Data Loader *Model*
- 16 **Edit Fields2** Set *Logic*
- 17 **Supabase Vector Store2** Vector Store Supabase *Model*
- 18 **Set File ID** Set *Logic*
- 19 **Validate File** If *Logic*
- 20 **Check for Duplicates** Postgres *Service*
- 21 **Set Error Type** Set *Logic*
- 22 **IF Duplicate Check** If *Logic*
- 23 **Error Logger** Supabase *Service*
- 24 **Log Duplicate** Supabase *Service*
- 25 **Debug File ID** Set *Logic*
- 26 **Error Notification** Gmail *Service*
- 27 **Slack Duplicate Notification** Gmail *Service*
- 28 **Delete old Doc** Supabase *Service*
- 29 **Delete Old Data Rows** Supabase *Service*
- 30 **Insert Metadata** Postgres *Service*
- 31 **Download File** Google Drive *Service*
- 32 **Switch** Switch *Logic*
- 33 **Extract from File PDF** Extract From File *Service*
- 34 **Extract from TXT** Extract From File *Service*
- 35 **Extract from CSV** Extract From File *Service*
- 36 **Extract from XLSX** Extract From File *Service*
- 37 **Extract from RTF** Extract From File *Service*
- 38 **Extract from DOC** Extract From File *Service*
- 39 **Aggregate** Aggregate *Logic*
- 40 **Insert Table Rows** Postgres *Service*
- 41 **Summarize** Summarize *Service*
- 42 **Set Schema** Set *Logic*
- 43 **Schema Document Metadata** Postgres *Service*

## How it's built

- **Starts on:** Someone opening a chat with it
- **Steps:** 43, with 3 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Gmail, Google Drive, Postgres, Supabase, Supabase vectors
- **Model:** OpenAI
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

An n8n account, plus your own Gmail, Google Drive, Postgres, Supabase and Supabase vectors accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on someone opening a chat with it.

Does it use AI?

Yes. It calls OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 43 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 43 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Finteractive-knowledge-base-chat-with-supabase-rag)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Google Drive](https://millionrounds.com/workflows?service=Google+Drive#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)[Supabase](https://millionrounds.com/workflows?service=Supabase#library)[Supabase vectors](https://millionrounds.com/workflows?service=Supabase+vectors#library)

## Workflows like it

Also data collection, with the same services where possible, closest in size first.

- [**AI-Powered news (stock, economy...) collector with Gemini** 41 steps · calls a model · Gmail, RSS](https://millionrounds.com/workflow/ai-powered-news-stock-economy-collector-with-gemini)
- [**WordPress - AI chatbot to enhance user experience** 45 steps · calls a model · Postgres, Supabase](https://millionrounds.com/workflow/wordpress-ai-chatbot-to-enhance-user-experience)
- [**Spotify to YouTube playlist synchronization with Discord** 45 steps · Discord, Supabase](https://millionrounds.com/workflow/spotify-to-youtube-playlist-synchronization-with-discord)
- [**Central AI agent of an IT company with Gemini and OpenRouter** 39 steps · calls a model · Google Drive, Pinecone](https://millionrounds.com/workflow/central-ai-agent-of-an-it-company-with-gemini-and-openrouter)
- [**Score job listings and generate tailored cover letters** 39 steps · calls a model · Apify, Gmail](https://millionrounds.com/workflow/score-job-listings-and-generate-tailored-cover-letters)
- [**An email assistant to manage your Gmail inbox with Gemini** 37 steps · calls a model · Email, Gmail](https://millionrounds.com/workflow/an-email-assistant-to-manage-your-gmail-inbox-with-gemini)
