Automation library · Data collection

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.

LargeCalls a model: OpenAI, OpenRouterRetrieval

25 stepsLarge: read it before trusting it with anything live
0Branches: places the flow splits
0Loops or waits
4Services it connects to

The flow

Starts it 4Model 11Logic 2Service 8

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

  1. 1Language Model (OpenRouter)Lm Chat Open RouterModel
  2. 2Embed the queryEmbeddings Open AiModel
  3. 3New PDF added to Drive folderGoogle Drive triggerStarts it
  4. 4PDF updated in Drive folderGoogle Drive triggerStarts it
  5. 5Split into document chunks 02Document Default Data LoaderModel
  6. 6Split into document chunks 01Document Default Data LoaderModel
  7. 7Embeddings OpenAI 01Embeddings Open AiModel
  8. 8Embeddings OpenAI 02Embeddings Open AiModel
  9. 9PDF moved to trashGoogle Drive triggerStarts it
  10. 10User sends a messageTelegram triggerStarts it
  11. 11Postgres Chat MemoryMemory Postgres ChatModel
  12. 12Answer from knowledge baseAgentModel
  13. 13Search knowledge baseVector Store SupabaseModel
  14. 14Download the PDFGoogle DriveService
  15. 15Remove outdated vectorsSupabaseService
  16. 16Re-index into vector databaseVector Store SupabaseModel
  17. 17Index into vector databaseVector Store SupabaseModel
  18. 18Remove vectors from databaseSupabaseService
  19. 19Send a text messageTelegramService
  20. 20Extract text from PDFExtract From FileService
  21. 21Download updated PDFGoogle DriveService
  22. 22Confirm file removed from DriveGoogle DriveService
  23. 23Tag with file ID and name 01SetLogic
  24. 24Extract text from updated PDFExtract From FileService
  25. 25Tag with file ID and name 02SetLogic

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.