Automation library · Documents and files

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.

LargeCalls a model: Azure OpenAIRetrieval

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

The flow

Starts it 4Model 14Logic 4Service 10

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

  1. 1Azure OpenAI Chat Model1Lm Chat Azure Open AiModel
  2. 2Embeddings Mistral CloudEmbeddings Mistral CloudModel
  3. 3Run IngestionManual triggerStarts it
  4. 4PDF Ingest WebhookWebhookStarts it
  5. 5Token SplitterText Splitter Token SplitterModel
  6. 6Embeddings Mistral Cloud2Embeddings Mistral CloudModel
  7. 7Telegram TriggerTelegram triggerStarts it
  8. 8Azure OpenAI Chat Model3Lm Chat Azure Open AiModel
  9. 9Embeddings Mistral Cloud3Embeddings Mistral CloudModel
  10. 10Simple MemoryMemory Buffer WindowModel
  11. 11Simple Memory2Memory Buffer WindowModel
  12. 12Chat TriggerChat triggerStarts it
  13. 13AI AgentAgentModel
  14. 14Postgres PGVector StoreVector Store PGVectorModel
  15. 15List All File NamesGoogle DriveService
  16. 16Default Data LoaderDocument Default Data LoaderModel
  17. 17Postgres PGVector Store2Vector Store PGVectorModel
  18. 18If Text Message ReceivedIfLogic
  19. 19AI Agent2AgentModel
  20. 20Postgres PGVector Store3Vector Store PGVectorModel
  21. 21Loop Over ItemsSplit In BatchesLogic
  22. 22If PDF File ReceivedIfLogic
  23. 23Send a Text MessageTelegramService
  24. 24Download Corresponding FileGoogle DriveService
  25. 25Approve IngestionTelegramService
  26. 26Send Refusal MessageTelegramService
  27. 27Send PDF FileHttp RequestService
  28. 28If User ApprovedIfLogic
  29. 29Download PDF FileTelegramService
  30. 30User DissapprovedTelegramService
  31. 31Send Downloaded PDF FileHttp RequestService
  32. 32Send Finished MessageTelegramService

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.