Automation library · Content

Create a RAG Telegram bot with Google Drive and PostgreSQL

Started by another system calling it, and works across Google Drive, Postgres and Telegram. 29 steps, 4 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large

29 stepsLarge: read it before trusting it with anything live
4Branches: places the flow splits
1Loop or waits
3Services it connects to

The flow

Starts it 2Logic 11Service 16

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

  1. 1Telegram WebhookWebhookStarts it
  2. 2Google Drive TriggerGoogle Drive triggerStarts it
  3. 3Get UserPostgresService
  4. 4Download FileGoogle DriveService
  5. 5User State RouterCodeLogic
  6. 6Extract TextCodeLogic
  7. 7Is New User?IfLogic
  8. 8Split Into ChunksCodeLogic
  9. 9Register New UserPostgresService
  10. 10Is Verified?IfLogic
  11. 11Loop ChunksSplit In BatchesLogic
  12. 12Send PIN RequestTelegramService
  13. 13Has Text?IfLogic
  14. 14PIN Correct?IfLogic
  15. 15Embed ChunkHttp RequestService
  16. 16Log IngestionPostgresService
  17. 17Embed QueryHttp RequestService
  18. 18No Text MessageTelegramService
  19. 19Mark User VerifiedPostgresService
  20. 20Wrong PIN MessageTelegramService
  21. 21Format Chunk EmbeddingCodeLogic
  22. 22Format Query EmbeddingCodeLogic
  23. 23Send WelcomeTelegramService
  24. 24Store ChunkPostgresService
  25. 25Search DocumentsPostgresService
  26. 26Build PromptCodeLogic
  27. 27Ask LLMHttp RequestService
  28. 28Send AnswerTelegramService
  29. 29Log QueryPostgresService

How it's built

Starts on
Another system calling it
Steps
29, with 4 branches, 1 loop or waits
Size
Large: read it before trusting it with anything live
Connects to
Google Drive, Postgres, Telegram
Model
None. This is plumbing, not judgement

Questions

What does it need to run?

An n8n account, plus your own Google Drive, Postgres and Telegram accounts. You connect your own accounts after importing it; none are included.

What starts it?

It starts on another system calling it.

Does it use AI?

No. Every step is fixed logic or a call to a service, so it does the same thing every time.

How long does it take to set up?

Take your time. At 29 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 29 steps before you point it at anything that matters.