Skip to main content

Build a retrieval-based chatbot with Telegram, OpenAI and Google Drive PDF backup

Workflow preview

Workflow preview
100%
Build a retrieval-based chatbot with Telegram, OpenAI and Google Drive PDF backup preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.embeddingsopenai, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.vectorstoreinmemory, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.stickynote, n8n-nodes-base.telegramtrigger, n8n-nodes-base.if, n8n-nodes-base.telegram

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Trung Tran.

Original n8n.io source

1.1 Workflow description

Title
Build a retrieval-based chatbot with Telegram, OpenAI and Google Drive PDF backup
Workflow name
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

  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

  • 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

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Embeddings OpenAI

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 2 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1.1

Block 3 - Insert Data to Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreInMemory - vectorStoreInMemory
Config choices
Version 1.2

Block 4 - Query Data Tool

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreInMemory - vectorStoreInMemory
Config choices
Version 1.2

Block 5 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 6 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Telegram Trigger

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1.2

Block 8 - Is text message?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 9 - Send respond to user

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 10 - Un-supported message type

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 11 - Telegram document query agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 12 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Code

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Upload your PDF document here

Type / Role
n8n-nodes-base.formTrigger - formTrigger
Config choices
Version 2.2

Block 16 - Backup document(s) to Google Drive

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 17 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note9

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note10

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Build a retrieval-based chatbot with Telegram, OpenAI and Google Drive PDF backup
Complexity advanced
Nodes 24
Categories Internal Wiki, AI RAG
Author Trung Tran
Published 05 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6994/6994.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Build a retrieval-based chatbot with Telegram, OpenAI and Google Drive PDF backup do?

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...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.