# AI agent to chat with OpenAI and Supabase: n8n workflow

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

Source: https://millionrounds.com/workflow/ai-agent-to-chat-with-openai-and-supabase (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Documents and files](https://millionrounds.com/workflows?category=Documents+and+files#library)

# AI agent to chat with OpenAI and Supabase

Started by someone opening a chat with it, and works across Supabase and Supabase vectors. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 22 steps, 2 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%2Fai-agent-to-chat-with-openai-and-supabase)

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

**2** Branches: places the flow splits

**1** Loop or waits

**2** Services it connects to

## The flow

Starts it 2 Model 10 Logic 5 Service 5

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

- 1 **Recursive Character Text Splitter** Text Splitter Recursive Character Text Splitter *Model*
- 2 **Embeddings OpenAI** Embeddings Open Ai *Model*
- 3 **When clicking ‘Test workflow’** Manual trigger *Starts it*
- 4 **When chat message received** Chat trigger *Starts it*
- 5 **OpenAI Chat Model1** Lm Chat Open Ai *Model*
- 6 **Embeddings OpenAI2** Embeddings Open Ai *Model*
- 7 **OpenAI Chat Model2** Lm Chat Open Ai *Model*
- 8 **Default Data Loader** Document Default Data Loader *Model*
- 9 **Insert into Supabase Vectorstore** Vector Store Supabase *Model*
- 10 **Get All Files** Supabase *Service*
- 11 **AI Agent** Agent *Model*
- 12 **Supabase Vector Store** Vector Store Supabase *Model*
- 13 **Vector Store Tool1** Tool Vector Store *Model*
- 14 **Loop Over Items** Split In Batches *Logic*
- 15 **Aggregate** Aggregate *Logic*
- 16 **If** If *Logic*
- 17 **Get All files** Http Request *Service*
- 18 **Download** Http Request *Service*
- 19 **Switch** Switch *Logic*
- 20 **Merge** Merge *Logic*
- 21 **Extract Document PDF** Extract From File *Service*
- 22 **Create File record2** Supabase *Service*

## How it's built

- **Starts on:** Someone opening a chat with it
- **Steps:** 22, with 2 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** 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 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 22 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 22 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%2Fai-agent-to-chat-with-openai-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 documents and files, with the same services where possible, closest in size first.

- [**Sync Supabase Storage files into a chat agent with OpenAI** 22 steps · calls a model · Supabase, Supabase vectors](https://millionrounds.com/workflow/sync-supabase-storage-files-into-a-chat-agent-with-openai)
- [**Chat with Supabase** 23 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/chat-with-supabase)
- [**Process documents with Google Drive and OpenAI** 23 steps · calls a model · Google Drive, Supabase vectors](https://millionrounds.com/workflow/process-documents-with-google-drive-and-openai)
- [**Detect and move duplicate Google Drive files with Supabase** 21 steps · Google Drive, Slack](https://millionrounds.com/workflow/detect-and-move-duplicate-google-drive-files-with-supabase)
- [**Process signed DocuSign contracts with Supabase and Claude** 23 steps · Gmail, Outlook](https://millionrounds.com/workflow/process-signed-docusign-contracts-with-supabase-and-claude)
- [**Keep RAG system updated with Google Drive** 20 steps · calls a model · Google Drive, Supabase](https://millionrounds.com/workflow/keep-rag-system-updated-with-google-drive)
