# AI agent - RAG Telegram chatbot n8n with OpenAI: n8n workflow

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

Source: https://millionrounds.com/workflow/ai-agent-rag-telegram-chatbot-n8n-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)

# AI agent - RAG Telegram chatbot n8n with OpenAI

Started by an incoming Telegram message, and works across Google Drive, 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. 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-rag-telegram-chatbot-n8n-with-openai)

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

**2** Branches: places the flow splits

**1** Loop or waits

**3** Services it connects to

## The flow

Starts it 2 Model 9 Logic 6 Service 5

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

- 1 **When clicking 'Test workflow'** Manual trigger *Starts it*
- 2 **Telegram Trigger** Telegram trigger *Starts it*
- 3 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 4 **Recursive Character Text Splitter** Text Splitter Recursive Character Text Splitter *Model*
- 5 **Embeddings OpenAI** Embeddings Open Ai *Model*
- 6 **Embeddings OpenAI2** Embeddings Open Ai *Model*
- 7 **Set Folder/ File URL in Google Drive** Set *Logic*
- 8 **Validation** Set *Logic*
- 9 **Question and Answer Chain** Chain Retrieval Qa *Model*
- 10 **Default Data Loader** Document Default Data Loader *Model*
- 11 **Supabase Vector Store** Vector Store Supabase *Model*
- 12 **Supabase Vector Store2** Vector Store Supabase *Model*
- 13 **Download Folder/ File** Google Drive *Service*
- 14 **Check User & Chat ID** If *Logic*
- 15 **Telegram Response** Telegram *Service*
- 16 **Response Error message** Telegram *Service*
- 17 **Loop Over Items** Split In Batches *Logic*
- 18 **Vector Store Retriever** Retriever Vector Store *Model*
- 19 **Message Router** Switch *Logic*
- 20 **Error message** Telegram *Service*
- 21 **Download File** Google Drive *Service*
- 22 **Add in Metadata** Code *Logic*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 22, with 2 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Drive, 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 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 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-rag-telegram-chatbot-n8n-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 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.

- [**AI-powered Telegram task assistant with Notion** 22 steps · calls a model · Notion, Telegram](https://millionrounds.com/workflow/ai-powered-telegram-task-assistant-with-notion)
- [**Audit landing page conversions with DeepSeek and Google Sheets** 22 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/audit-landing-page-conversions-with-deepseek-and-google-shee)
- [**Complete business WhatsApp AI-powered RAG chatbot with OpenAI** 22 steps · calls a model · Google Drive, Qdrant](https://millionrounds.com/workflow/complete-business-whatsapp-ai-powered-rag-chatbot-with-opena)
- [**Create an AI knowledge base assistant with Ollama and PGVector** 22 steps · calls a model · Telegram](https://millionrounds.com/workflow/create-an-ai-knowledge-base-assistant-with-ollama-and-pgvect)
- [**Empower your AI chatbot with OpenAI and Gmail** 22 steps · calls a model · Gmail, Google Docs](https://millionrounds.com/workflow/empower-your-ai-chatbot-with-openai-and-gmail)
- [**Generate AI camera moves with Seedance** 22 steps · calls a model · ClickUp, Google Drive](https://millionrounds.com/workflow/generate-ai-camera-moves-with-seedance)
