πŸ“– Build a retrieval-based chatbot with Telegram, OpenAI and Google Drive PDF backup

⚑ 1,619 views Β· πŸ“– Internal Wiki & Knowledge Base

Description

πŸ“š Telegram RAG Chatbot with PDF Document & Google Drive Backup

πŸ‘€ Who’s it for

Perfect for:

βš™οΈ How it works / What it does

πŸ’¬ Telegram Chat Handling

  1. User sends a message
    Triggered by the Telegram bot, the workflow checks if the message is text.

  2. 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
  3. Send answer back
    The bot sends the generated response back to the Telegram user.

  4. Non-text input fallback
    If the message is not text, the bot replies with a polite unsupported message.

πŸ“„ PDF Upload and Embedding

  1. User uploads PDFs manually
    A manual trigger starts the embedding flow.

  2. Default Data Loader
    Reads and chunks the PDF(s) into text segments.

  3. Insert to Vector Store (Embedding)
    Text chunks are embedded using OpenAI and saved for retrieval.

  4. Backup to Google Drive
    The original PDF is uploaded to Google Drive for safekeeping.

πŸ› οΈ How to set up

  1. Telegram Bot

    • Create via BotFather
    • Connect it to the Telegram Trigger node
  2. 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
  3. Google Drive

    • Set up credentials in n8n for your Google account
    • Connect the β€œBackup to Google Drive” node
  4. PDF Ingestion

    • Use the β€œUpload your PDF here” trigger
    • Connect it to the loader, embedder, and backup flow

βœ… Requirements

🧩 How to customize the workflow

FeatureHow to Customize
Auto-ingest from foldersAdd Google Drive/Dropbox watchers for new PDFs
Add file upload via TelegramExtend Telegram bot to receive PDFs and run the embedding flow
Track user questionsLog Telegram usernames and questions to a database
Summarize documentsAdd summarization step on upload
Add Markdown or HTML supportFormat replies for better Telegram rendering

Built with πŸ’¬ Telegram + πŸ“„ PDF + 🧠 OpenAI Embeddings + ☁️ Google Drive + ⚑ n8n

πŸ”— Nodes Used

Telegram, Telegram Trigger, Google Drive, AI Agent, Embeddings OpenAI, OpenAI Chat Model

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup