# PDF RAG agent with Telegram: n8n workflow template

> Started by an incoming Telegram message, and works across Google Drive and Telegram. It puts Azure OpenAI behind a retrieval step, so answers are drawn from...

Source: https://millionrounds.com/workflow/pdf-rag-agent-with-telegram (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)

# PDF RAG agent with Telegram

Started by an incoming Telegram message, and works across Google Drive and Telegram. It puts Azure OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 32 steps, 3 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: Azure OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fpdf-rag-agent-with-telegram)

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

**3** Branches: places the flow splits

**1** Loop or waits

**2** Services it connects to

## The flow

Starts it 4 Model 14 Logic 4 Service 10

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

- 1 **Azure OpenAI Chat Model1** Lm Chat Azure Open Ai *Model*
- 2 **Embeddings Mistral Cloud** Embeddings Mistral Cloud *Model*
- 3 **Run Ingestion** Manual trigger *Starts it*
- 4 **PDF Ingest Webhook** Webhook *Starts it*
- 5 **Token Splitter** Text Splitter Token Splitter *Model*
- 6 **Embeddings Mistral Cloud2** Embeddings Mistral Cloud *Model*
- 7 **Telegram Trigger** Telegram trigger *Starts it*
- 8 **Azure OpenAI Chat Model3** Lm Chat Azure Open Ai *Model*
- 9 **Embeddings Mistral Cloud3** Embeddings Mistral Cloud *Model*
- 10 **Simple Memory** Memory Buffer Window *Model*
- 11 **Simple Memory2** Memory Buffer Window *Model*
- 12 **Chat Trigger** Chat trigger *Starts it*
- 13 **AI Agent** Agent *Model*
- 14 **Postgres PGVector Store** Vector Store PGVector *Model*
- 15 **List All File Names** Google Drive *Service*
- 16 **Default Data Loader** Document Default Data Loader *Model*
- 17 **Postgres PGVector Store2** Vector Store PGVector *Model*
- 18 **If Text Message Received** If *Logic*
- 19 **AI Agent2** Agent *Model*
- 20 **Postgres PGVector Store3** Vector Store PGVector *Model*
- 21 **Loop Over Items** Split In Batches *Logic*
- 22 **If PDF File Received** If *Logic*
- 23 **Send a Text Message** Telegram *Service*
- 24 **Download Corresponding File** Google Drive *Service*
- 25 **Approve Ingestion** Telegram *Service*
- 26 **Send Refusal Message** Telegram *Service*
- 27 **Send PDF File** Http Request *Service*
- 28 **If User Approved** If *Logic*
- 29 **Download PDF File** Telegram *Service*
- 30 **User Dissapproved** Telegram *Service*
- 31 **Send Downloaded PDF File** Http Request *Service*
- 32 **Send Finished Message** Telegram *Service*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 32, with 3 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Drive, Telegram
- **Model:** Azure 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 and Telegram accounts, and a key for Azure 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 Azure 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 32 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 32 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%2Fpdf-rag-agent-with-telegram)
- **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)[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

Also documents and files, with the same services where possible, closest in size first.

- [**AI knowledge assistant with Gemini and OpenAI** 32 steps · calls a model · Google Drive, Pinecone](https://millionrounds.com/workflow/ai-knowledge-assistant-with-gemini-and-openai)
- [**Document-based RAG chat assistant with Google Drive** 32 steps · calls a model · Google Drive, Supabase](https://millionrounds.com/workflow/document-based-rag-chat-assistant-with-google-drive)
- [**Sync Google Drive documents to Pinecone RAG with Gemini** 32 steps · calls a model · Google Drive, Google Sheets](https://millionrounds.com/workflow/sync-google-drive-documents-to-pinecone-rag-with-gemini)
- [**Extract text from images & PDFs with Telegram and Mistral** 32 steps · Telegram](https://millionrounds.com/workflow/extract-text-from-images-and-pdfs-with-telegram-and-mistral)
- [**Send, chase, and e-signature with Airtable and TurboDocx** 33 steps · Airtable, Gmail](https://millionrounds.com/workflow/send-chase-and-e-signature-with-airtable-and-turbodocx)
- [**Chat with Google Drive and Pinecone** 30 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/chat-with-google-drive-and-pinecone)
