# Sync a Telegram RAG chatbot with Google Drive and OpenAI: n8n workflow

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

Source: https://millionrounds.com/workflow/sync-a-telegram-rag-chatbot-with-google-drive-and-openai (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)

# Sync a Telegram RAG chatbot with Google Drive and OpenAI

Started by an incoming Telegram message, and works across Google Drive, Supabase, Supabase vectors and Telegram. It puts OpenAI and OpenRouter behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 25 steps: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI, OpenRouter Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fsync-a-telegram-rag-chatbot-with-google-drive-and-openai)

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

**0** Branches: places the flow splits

**0** Loops or waits

**4** Services it connects to

## The flow

Starts it 4 Model 11 Logic 2 Service 8

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

- 1 **Language Model (OpenRouter)** Lm Chat Open Router *Model*
- 2 **Embed the query** Embeddings Open Ai *Model*
- 3 **New PDF added to Drive folder** Google Drive trigger *Starts it*
- 4 **PDF updated in Drive folder** Google Drive trigger *Starts it*
- 5 **Split into document chunks 02** Document Default Data Loader *Model*
- 6 **Split into document chunks 01** Document Default Data Loader *Model*
- 7 **Embeddings OpenAI 01** Embeddings Open Ai *Model*
- 8 **Embeddings OpenAI 02** Embeddings Open Ai *Model*
- 9 **PDF moved to trash** Google Drive trigger *Starts it*
- 10 **User sends a message** Telegram trigger *Starts it*
- 11 **Postgres Chat Memory** Memory Postgres Chat *Model*
- 12 **Answer from knowledge base** Agent *Model*
- 13 **Search knowledge base** Vector Store Supabase *Model*
- 14 **Download the PDF** Google Drive *Service*
- 15 **Remove outdated vectors** Supabase *Service*
- 16 **Re-index into vector database** Vector Store Supabase *Model*
- 17 **Index into vector database** Vector Store Supabase *Model*
- 18 **Remove vectors from database** Supabase *Service*
- 19 **Send a text message** Telegram *Service*
- 20 **Extract text from PDF** Extract From File *Service*
- 21 **Download updated PDF** Google Drive *Service*
- 22 **Confirm file removed from Drive** Google Drive *Service*
- 23 **Tag with file ID and name 01** Set *Logic*
- 24 **Extract text from updated PDF** Extract From File *Service*
- 25 **Tag with file ID and name 02** Set *Logic*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 25
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Drive, Supabase, Supabase vectors, Telegram
- **Model:** OpenAI, OpenRouter
- **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 and OpenRouter. 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 and OpenRouter. 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 25 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 25 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%2Fsync-a-telegram-rag-chatbot-with-google-drive-and-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 data collection, with the same services where possible, closest in size first.

- [**Convert LINE handwritten memo images to tagged, searchable notes** 25 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/convert-line-handwritten-memo-images-to-tagged-searchable-no)
- [**AI PPT Optimizer with Google Drive and Google Sheets** 25 steps · Google Drive, Google Sheets](https://millionrounds.com/workflow/ai-ppt-optimizer-with-google-drive-and-google-sheets)
- [**Classify and log AI use cases with Anthropic and Supabase** 25 steps · Email, Supabase](https://millionrounds.com/workflow/classify-and-log-ai-use-cases-with-anthropic-and-supabase)
- [**Match product manager jobs with Supabase and Claude** 25 steps · Supabase](https://millionrounds.com/workflow/match-product-manager-jobs-with-supabase-and-claude)
- [**AI Facebook ad spy tool with Apify and OpenAI** 24 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/ai-facebook-ad-spy-tool-with-apify-and-openai)
- [**AI-powered visual regression testing with Gemini and Linear** 24 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/ai-powered-visual-regression-testing-with-gemini-and-linear)
