# Company knowledge base agent (RAG) with OpenAI: n8n workflow

> Started by an incoming Telegram message, and works across Google Drive, Supabase, Supabase vectors and Telegram.

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

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

# Company knowledge base agent (RAG) with OpenAI

Started by an incoming Telegram message, and works across Google Drive, Supabase, Supabase vectors and Telegram. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 31 steps, 1 branch: 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%2Fcompany-knowledge-base-agent-rag-with-openai)

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

**1** Branch: places the flow splits

**0** Loops or waits

**4** Services it connects to

## The flow

Starts it 3 Model 16 Logic 5 Service 7

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 **New File** Google Drive trigger *Starts it*
- 4 **File Updated** Google Drive trigger *Starts it*
- 5 **Recursive Character Text Splitter1** Text Splitter Recursive Character Text Splitter *Model*
- 6 **Embeddings OpenAI1** Embeddings Open Ai *Model*
- 7 **Telegram Trigger** Telegram trigger *Starts it*
- 8 **Window Buffer Memory1** Memory Buffer Window *Model*
- 9 **OpenAI Chat Model2** Lm Chat Open Ai *Model*
- 10 **Embeddings OpenAI3** Embeddings Open Ai *Model*
- 11 **OpenAI Chat Model3** Lm Chat Open Ai *Model*
- 12 **Default Data Loader** Document Default Data Loader *Model*
- 13 **Supabase Vector Store** Vector Store Supabase *Model*
- 14 **Set ID** Set *Logic*
- 15 **Delete Row(s)** Supabase *Service*
- 16 **Default Data Loader1** Document Default Data Loader *Model*
- 17 **Supabase Vector Store1** Vector Store Supabase *Model*
- 18 **Voice or Text** Switch *Logic*
- 19 **RAG Agent** Agent *Model*
- 20 **MarketingLadder** Tool Vector Store *Model*
- 21 **Supabase Vector Store3** Vector Store Supabase *Model*
- 22 **Download File** Google Drive *Service*
- 23 **Get FIle ID** Set *Logic*
- 24 **Download File2** Telegram *Service*
- 25 **Text** Set *Logic*
- 26 **Response** Telegram *Service*
- 27 **Extract from File** Extract From File *Service*
- 28 **Reformat** Limit *Logic*
- 29 **Transcribe** Open Ai *Model*
- 30 **Download File1** Google Drive *Service*
- 31 **Extract from File1** Extract From File *Service*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 31, with 1 branch
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Drive, Supabase, Supabase vectors, Telegram
- **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 Google Drive, Supabase, Supabase vectors and Telegram accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an incoming Telegram message.

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 31 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 31 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%2Fcompany-knowledge-base-agent-rag-with-openai)
- **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)[Supabase](https://millionrounds.com/workflows?service=Supabase#library)[Supabase vectors](https://millionrounds.com/workflows?service=Supabase+vectors#library)[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

Also chat assistants, with the same services where possible, closest in size first.

- [**Create a session-based Telegram chatbot with OpenAI** 31 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/create-a-session-based-telegram-chatbot-with-openai)
- [**Record Property Maintenance Issues with Slack** 31 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/record-property-maintenance-issues-with-slack)
- [**With Gemini and OpenAI** 31 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/with-gemini-and-openai)
- [**Finance transaction auto record into Notion with OpenAI** 30 steps · calls a model · Notion, Telegram](https://millionrounds.com/workflow/finance-transaction-auto-record-into-notion-with-openai)
- [**Manage safety inspections and corrective actions with DeepSeek** 32 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/manage-safety-inspections-and-corrective-actions-with-deepse)
- [**Manage weekly coaching check-ins with Google Sheets and Gmail** 32 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/manage-weekly-coaching-check-ins-with-google-sheets-and-gmai)
