Build a Retrieval-Based Chatbot with Telegram, OpenAI and Google Drive PDF Backup
📚 Telegram RAG Chatbot with PDF Document & Google Drive Backup An upgraded Retrieval-Augmented Generation (RAG) chatbot built in n8n that lets users ask questions via Telegram and receive accurate answers from uploaded PDFs. It embeds documents using OpenAI and backs them up to Google Drive.
👤 Who’s it for
Perfect for: Knowledge workers who want instant access to private documents Support teams needing searchable SOPs and guides Educators enabling course material Q&A for students Individuals automating personal document search + cloud backup
⚙️ How it works / What it does
💬 Telegram Chat Handling
User sends a message
Triggered by the Telegram bot, the workflow checks if the message is text.
Text message → OpenAI RAG Agent
If the message is text, it's passed to a GPT-powered document agent.
This agent:
Retrieves relevant info from embedded documents using semantic search
Returns a context-aware answer to the user
Send answer back
The bot sends the generated response back to the Telegram user.
Non-text input fallback
If the message is not text, the bot replies with a polite unsupported message.
📄 PDF Upload and Embedding
User uploads PDFs manually
A manual trigger starts the embedding flow.
Default Data Loader
Reads and chunks the PDF(s) into text segments.
Insert to Vector Store (Embedding)
Text chunks are embedded using OpenAI and saved for retrieval.
Backup to Google Drive
The original PDF is uploaded to Google Drive for safekeeping.
🛠️ How to set up
Telegram Bot Create via BotFather Connect it to the Telegram Trigger node
OpenAI Use your OpenAI API key Connect the Embeddings and Chat Model nodes (GPT-3.5/4) Ensure both embedding and querying use the same Embedding node
Google Drive Set up credentials in n8n for your Google account Connect the “Backup to Google Drive” node
PDF Ingestion Use the “Upload your PDF here” trigger Connect it to the loader, embedder, and backup flow
✅ Requirements
Telegram bot token OpenAI API key (GPT + Embeddings) n8n instance (self-hosted or cloud) Google Drive integration PDF files to upload
🧩 How to customize the workflow
| Feature | How to Customize | |-------------------------------|-------------------------------------------------------------------| | Auto-ingest from folders | Add Google Drive/Dropbox watchers for new PDFs | | Add file upload via Telegram | Extend Telegram bot to receive PDFs and run the embedding flow | | Track user questions | Log Telegram usernames and questions to a database | | Summarize documents | Add summarization step on upload | | Add Markdown or HTML support | Format replies for better Telegram rendering |
Built with 💬 Telegram + 📄 PDF + 🧠 OpenAI Embeddings + ☁️ Google Drive + ⚡ n8n
Related Templates
Use OpenRouter in n8n versions <1.78
What it is: In version 1.78, n8n introduced a dedicated node to use the OpenRouter service, which lets you to use a lot...
Task Deadline Reminders with Google Sheets, ChatGPT, and Gmail
Intro This template is for project managers, team leads, or anyone who wants to automatically remind teammates of tasks ...
🤖 Build Resilient AI Workflows with Automatic GPT and Gemini Failover Chain
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. How it works This...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments