# Run a Telegram RAG support chatbot with OpenAI and Pinecone: n8n workflow

> Started by an incoming Telegram message, and works across Google Sheets and Telegram. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/run-a-telegram-rag-support-chatbot-with-openai-and-pinecone (Millionrounds; every figure on the page links to its filing or article)

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

# Run a Telegram RAG support chatbot with OpenAI and Pinecone

Started by an incoming Telegram message, and works across Google Sheets and Telegram. It hands the judgement calls to OpenAI. 20 steps, 1 branch: a working afternoon to understand properly.

Medium Calls a model: OpenAI

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

**20 steps** Medium: a working afternoon

**1** Branch: places the flow splits

**0** Loops or waits

**2** Services it connects to

## The flow

Starts it 1 Model 2 Logic 5 Service 12

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

- 1 **1. Telegram Trigger - Receive Messages** Telegram trigger *Starts it*
- 2 **2. Code - Detect Message Type** Code *Logic*
- 3 **3. Switch - Route by Message Type** Switch *Logic*
- 4 **13. Code - Build Query Text from Any Input** Code *Logic*
- 5 **4. Telegram - Get Voice File URL** Telegram *Service*
- 6 **7. Telegram - Get Photo File URL** Telegram *Service*
- 7 **10. Telegram - Get Document File URL** Telegram *Service*
- 8 **14. HTTP - OpenAI Embed Query** Http Request *Service*
- 9 **5. HTTP - Download Voice File** Http Request *Service*
- 10 **8. HTTP - Download Photo File** Http Request *Service*
- 11 **11. HTTP - Download Document File** Http Request *Service*
- 12 **15. HTTP - Pinecone Vector Search** Http Request *Service*
- 13 **6. OpenAI - Transcribe Voice to Text** Open Ai *Model*
- 14 **9. OpenAI - Analyze Image with Vision** Open Ai *Model*
- 15 **12. Extract From File - Read PDF Text** Extract From File *Service*
- 16 **16. Code - Build RAG Context from Results** Code *Logic*
- 17 **17. HTTP - AI Generate Answer** Http Request *Service*
- 18 **18. Code - Format Reply and Prepare Log** Code *Logic*
- 19 **19. Telegram - Send Reply to User** Telegram *Service*
- 20 **20. Sheets - Log Conversation** Google Sheets *Service*

## How it's built

- **Starts on:** An incoming Telegram message
- **Steps:** 20, with 1 branch
- **Size:** Medium: a working afternoon
- **Connects to:** Google Sheets, Telegram
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Google Sheets 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. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Plan an afternoon. 20 steps is enough that you should read each one before running it.

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 20 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%2Frun-a-telegram-rag-support-chatbot-with-openai-and-pinecone)
- **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 Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)[Telegram](https://millionrounds.com/workflows?service=Telegram#library)

## Workflows like it

Also customer support, with the same services where possible, closest in size first.

- [**Answer Facebook Messenger product questions with OpenAI** 20 steps · calls a model · Google Sheets](https://millionrounds.com/workflow/answer-facebook-messenger-product-questions-with-openai)
- [**Run an AI student helpdesk with OpenAI and Google Sheets** 20 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/run-an-ai-student-helpdesk-with-openai-and-google-sheets)
- [**Telegram AI voice agent - multiple language support** 20 steps · calls a model · Google Sheets, Telegram](https://millionrounds.com/workflow/telegram-ai-voice-agent-multiple-language-support)
- [**Triage support tickets with OpenAI and HubSpot** 20 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/triage-support-tickets-with-openai-and-hubspot)
- [**Answer HR and IT policy questions on Telegram with OpenAI** 21 steps · calls a model · Telegram](https://millionrounds.com/workflow/answer-hr-and-it-policy-questions-on-telegram-with-openai)
- [**Automate multi-channel customer support with Gmail** 21 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/automate-multi-channel-customer-support-with-gmail)
