# Smarter RAG agents with Gemini and Supabase: n8n workflow

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

Source: https://millionrounds.com/workflow/smarter-rag-agents-with-gemini-and-supabase (Millionrounds; every figure on the page links to its filing or article)

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

# Smarter RAG agents with Gemini and Supabase

Started by someone opening a chat with it, and works across Supabase and Supabase vectors. It puts Gemini behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 24 steps, 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%2Fsmarter-rag-agents-with-gemini-and-supabase)

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

**0** Branches: places the flow splits

**2** Loops or waits

**2** Services it connects to

## The flow

Starts it 3 Model 12 Logic 5 Service 4

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

- 1 **Recursive Character Text Splitter** Text Splitter Recursive Character Text Splitter *Model*
- 2 **When chat message received** Chat trigger *Starts it*
- 3 **Embeddings Google Gemini1** Embeddings Google Gemini *Model*
- 4 **On form submission** Form trigger *Starts it*
- 5 **Schedule Trigger** Schedule trigger *Starts it*
- 6 **Reranker** Reranker Cohere *Model*
- 7 **Google Gemini 2.0 Flash** Lm Chat Google Gemini *Model*
- 8 **Postgres Chat Memory** Memory Postgres Chat *Model*
- 9 **Embeddings Google Gemini** Embeddings Google Gemini *Model*
- 10 **Default Data Loader** Document Default Data Loader *Model*
- 11 **Query Builder** Google Gemini *Model*
- 12 **Insert into Supabase Vectorstore** Vector Store Supabase *Model*
- 13 **Extract from File** Extract From File *Service*
- 14 **Get many rows** Supabase *Service*
- 15 **Supabase Vector Store** Vector Store Supabase *Model*
- 16 **RAG Agent** Agent *Model*
- 17 **Set File Data** Set *Logic*
- 18 **Loop Over Items** Split In Batches *Logic*
- 19 **Delete Old Doc Rows** Supabase *Service*
- 20 **Merge** Merge *Logic*
- 21 **Edit Fields** Set *Logic*
- 22 **Metadata Obtention** Google Gemini *Model*
- 23 **Update a row** Supabase *Service*
- 24 **Wait** Wait *Logic*

## How it's built

- **Starts on:** Someone opening a chat with it
- **Steps:** 24, 2 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Supabase, 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 Supabase 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 24 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 24 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%2Fsmarter-rag-agents-with-gemini-and-supabase)
- **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.

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

## Workflows like it

Also lead generation, with the same services where possible, closest in size first.

- [**Qualify mortgage leads and collect documents with Gemini** 24 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/qualify-mortgage-leads-and-collect-documents-with-gemini)
- [**Speed to Lead: SMS Qualification (Real Estate) with OpenAI** 24 steps · calls a model · Supabase, Twilio](https://millionrounds.com/workflow/speed-to-lead-sms-qualification-real-estate-with-openai)
- [**Qualify Facebook leads with ElevenLabs and Supabase** 24 steps · Gmail, Slack](https://millionrounds.com/workflow/qualify-facebook-leads-with-elevenlabs-and-supabase)
- [**Reddit lead finder: prospecting with OpenAI and Supabase** 23 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/reddit-lead-finder-prospecting-with-openai-and-supabase)
- [**Speed to Lead: SMS Qualification (Solar Installers)** 25 steps · calls a model · Supabase, Twilio](https://millionrounds.com/workflow/speed-to-lead-sms-qualification-solar-installers)
- [**Capture, score and route Gmail leads with Groq Llama 3.3** 22 steps · calls a model · Gmail, Slack](https://millionrounds.com/workflow/capture-score-and-route-gmail-leads-with-groq-llama-3-3)
