# Build a RAG knowledge base from PDFs with Gemini and Supabase: n8n workflow

> Started by someone opening a chat with it, and works across Google Drive, Google Sheets and Supabase vectors.

Source: https://millionrounds.com/workflow/build-a-rag-knowledge-base-from-pdfs-with-gemini-and-supabas (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)

# Build a RAG knowledge base from PDFs with Gemini and Supabase

Started by someone opening a chat with it, and works across Google Drive, Google Sheets and Supabase vectors. It puts Gemini behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 27 steps, 3 branches, 2 loops or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: Gemini Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fbuild-a-rag-knowledge-base-from-pdfs-with-gemini-and-supabas)

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

**3** Branches: places the flow splits

**2** Loops or waits

**3** Services it connects to

## The flow

Starts it 2 Model 8 Logic 10 Service 7

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

- 1 **Recursive Text Splitter** Text Splitter Recursive Character Text Splitter *Model*
- 2 **Embeddings Google Gemini** Embeddings Google Gemini *Model*
- 3 **Schedule Trigger** Schedule trigger *Starts it*
- 4 **Gemini Flash (RAG)** Lm Chat Google Gemini *Model*
- 5 **Gemini Embeddings (Query)** Embeddings Google Gemini *Model*
- 6 **When chat message received** Chat trigger *Starts it*
- 7 **PDF Binary Loader** Document Default Data Loader *Model*
- 8 **Insert to Supabase pgvector** Vector Store Supabase *Model*
- 9 **Get row(s) in sheet** Google Sheets *Service*
- 10 **SerajUAE RAG Agent** Agent *Model*
- 11 **SerajUAE Knowledge Base** Vector Store Supabase *Model*
- 12 **Update row in sheet** Google Sheets *Service*
- 13 **Filter** Filter *Logic*
- 14 **Loop Over Items** Split In Batches *Logic*
- 15 **All Done** Set *Logic*
- 16 **Seraj or Drive?** If *Logic*
- 17 **Fetch File Page** Http Request *Service*
- 18 **Extract Drive File ID + Title** Code *Logic*
- 19 **Extract PDF URL + Title** Code *Logic*
- 20 **Download PDF (Drive)** Google Drive *Service*
- 21 **Drive Link?** If *Logic*
- 22 **Wait** Wait *Logic*
- 23 **Download PDF (Seraj)** Http Request *Service*
- 24 **Extract from File** Extract From File *Service*
- 25 **Code in JavaScript** Code *Logic*
- 26 **text pdf?** If *Logic*
- 27 **Update row in sheet1** Google Sheets *Service*

## How it's built

- **Starts on:** Someone opening a chat with it
- **Steps:** 27, with 3 branches, 2 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Drive, Google Sheets, Supabase vectors
- **Model:** Gemini
- **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 Google Drive, Google Sheets and Supabase vectors accounts, and a key for Gemini. 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 Gemini. 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 27 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 27 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%2Fbuild-a-rag-knowledge-base-from-pdfs-with-gemini-and-supabas)
- **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.

[Google Drive](https://millionrounds.com/workflows?service=Google+Drive#library)[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#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 email auto-responder system- AI RAG agent for email inbox** 27 steps · calls a model · Gmail, Google Docs](https://millionrounds.com/workflow/ai-email-auto-responder-system-ai-rag-agent-for-email-inbox)
- [**Automated email responses with OpenAI and Supabase** 27 steps · calls a model · Outlook, Postgres](https://millionrounds.com/workflow/automated-email-responses-with-openai-and-supabase)
- [**Generate AI YouTube shorts with Claude and Gemini** 27 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/generate-ai-youtube-shorts-with-claude-and-gemini)
- [**Personal finance tracker with Telegram Bot and Gemini** 27 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/personal-finance-tracker-with-telegram-bot-and-gemini)
- [**Screen LinkedIn jobs and send tailored applications with Apify** 27 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/screen-linkedin-jobs-and-send-tailored-applications-with-api)
- [**Track AI search winners and uncover topic gaps with SE Ranking** 27 steps · Google Sheets](https://millionrounds.com/workflow/track-ai-search-winners-and-uncover-topic-gaps-with-se-ranki)
