Automation library · Customer support

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.

MediumCalls a model: OpenAI

20 stepsMedium: a working afternoon
1Branch: places the flow splits
0Loops or waits
2Services it connects to

The flow

Starts it 1Model 2Logic 5Service 12

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

  1. 11. Telegram Trigger - Receive MessagesTelegram triggerStarts it
  2. 22. Code - Detect Message TypeCodeLogic
  3. 33. Switch - Route by Message TypeSwitchLogic
  4. 413. Code - Build Query Text from Any InputCodeLogic
  5. 54. Telegram - Get Voice File URLTelegramService
  6. 67. Telegram - Get Photo File URLTelegramService
  7. 710. Telegram - Get Document File URLTelegramService
  8. 814. HTTP - OpenAI Embed QueryHttp RequestService
  9. 95. HTTP - Download Voice FileHttp RequestService
  10. 108. HTTP - Download Photo FileHttp RequestService
  11. 1111. HTTP - Download Document FileHttp RequestService
  12. 1215. HTTP - Pinecone Vector SearchHttp RequestService
  13. 136. OpenAI - Transcribe Voice to TextOpen AiModel
  14. 149. OpenAI - Analyze Image with VisionOpen AiModel
  15. 1512. Extract From File - Read PDF TextExtract From FileService
  16. 1616. Code - Build RAG Context from ResultsCodeLogic
  17. 1717. HTTP - AI Generate AnswerHttp RequestService
  18. 1818. Code - Format Reply and Prepare LogCodeLogic
  19. 1919. Telegram - Send Reply to UserTelegramService
  20. 2020. Sheets - Log ConversationGoogle SheetsService

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.