Skip to main content

Build a multi-functional Telegram bot with Gemini, RAG PDF search & Google Suite

Workflow preview

Workflow preview
100%
Build a multi-functional Telegram bot with Gemini, RAG PDF search & Google Suite preview
Open on n8n.io

Important notice

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

1. Workflow Overview

The Ultimate Beginner's Guide to an AI Powered Telegram Assistant (PDF, Brave search & Google Suite) This comprehensive workflow bundle is designed as a powerful starter kit, enabling you to build ...

Best for

  • Personal Productivity automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.telegramtrigger, n8n-nodes-base.telegram, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.openai, n8n-nodes-base.httprequest, @n8n/n8n-nodes-langchain.lmchatgooglegemini, @n8n/n8n-nodes-langchain.toolthink

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Build a multi-functional Telegram bot with Gemini, RAG PDF search & Google Suite
Workflow name
Build a multi-functional Telegram bot with Gemini, RAG PDF search & Google Suite

The Ultimate Beginner's Guide to an AI-Powered Telegram Assistant (PDF, Brave search & Google Suite)

This comprehensive workflow bundle is designed as a powerful starter kit, enabling you to build a multi-functional AI assistant on Telegram. It seamlessly integrates AI-powered voice interactions, an intelligent PDF document search using a Retrieval-Augmented Generation (RAG) system, and automates various Google Suite tasks like calendar management and document generation. Perfect for beginners looking to explore advanced AI and automation capabilities.

Disclaimer

This template is designed for self-hosted n8n instances.

🚀 Key Features

  • Telegram Bot Interface: Interact with your AI assistant using both text and voice commands through Telegram.
  • AI Voice Bot:
    • Transcribes user voice messages using OpenAI Whisper.
    • Processes requests with an AI agent powered by Google Gemini.
    • Responds with AI-synthesized voice using Replicate API.
  • PDF RAG System:
    • Index PDF documents from Google Drive via Telegram commands.
    • Utilizes Mistral AI for Optical Character Recognition (OCR) on PDFs.
    • Stores document content and embeddings in a Qdrant vector database.
    • Answers questions about your documents using Google Gemini, based on retrieved context.
  • Google Suite Automation:
    • Manage Google Calendar: Create events, find upcoming holidays, and list birthdays.
    • Google Drive: Search for PDF files and manage document templates.
    • Google Docs: Automatically generate invoices from templates.
  • Intelligent Web Search: Employs Brave Search for fetching real-time information from the web.
  • Versatile AI Agent: Leverages Google Gemini with a suite of tools including a calculator, date & time utilities, and custom integrations (e.g., example Airbnb tools).
  • Command-Driven Functionality: Easily trigger specific actions using Telegram commands like /help, /pdf, /rag, /invoice, /chat, /brave, and /birthday.

⚙️ How It Works

The workflow is initiated by messages or commands sent to your Telegram bot. A central Switch node directs the flow based on the input received.

1. Telegram Interaction & Command Routing

  • A Telegram Trigger node listens for new messages (text or voice).
  • A "typing..." indicator is sent to Telegram for better user experience.
  • The Switch node parses the message content and routes it to the appropriate sub-workflow based on predefined commands (e.g., /pdf, /rag, /voice) or general chat.

2. AI Voice Bot Functionality

  • For voice messages (or if the voice path is triggered):
    • The voice file is downloaded from Telegram.
    • OpenAI Whisper transcribes the audio into text.
    • The transcribed text is fed to an AI Agent (powered by Google Gemini and equipped with various tools and memory).
    • The AI Agent's text response is then sent to the Replicate API to generate a natural-sounding voice.
    • The generated audio response is sent back to the user on Telegram.

3. PDF RAG System with Mistral OCR & Qdrant

  • Indexing PDFs (via /qdrant <Google_Drive_File_ID> command):
    • The specified PDF is downloaded from Google Drive.
    • The PDF is uploaded to Mistral AI for OCR processing.
    • The extracted text (in markdown format) is retrieved.
    • The text is split into manageable chunks.
    • OpenAI Embeddings are generated for each chunk.
    • These chunks and their embeddings are stored in a Qdrant vector collection.
    • A confirmation message is sent to Telegram.
  • Querying PDFs (via /rag <your_question> command):
    • The user's question is processed by a RetrievalQA Chain.
    • This chain uses Google Gemini as the Language Model and retrieves relevant document chunks from Qdrant based on semantic similarity (embeddings).
    • Google Gemini then generates a concise answer based on the user's question and the retrieved contextual information from the documents.
    • The answer is sent back to the user on Telegram.
  • Searching PDFs in Drive (via /pdf <search_term> command):
    • Searches your Google Drive for PDF files matching the provided search term.
    • Sends a list of found PDF files (name and ID) to the user on Telegram, allowing them to easily identify files for indexing with /qdrant.

4. AI Chat & Task Automation (General Chat & /chat command)

  • Handles general text messages or transcribed voice inputs that are not specific commands.
  • An AI Agent (Google Gemini) processes these inputs.
  • The agent is equipped with tools such as:
    • Google Calendar Tools: To create events, find the next public holiday, or list upcoming birthdays.
    • Brave Search Tool: To search the internet for information.
    • Calculator Tool: For mathematical computations.
    • Date & Time Utility: For handling and formatting dates.
    • Example Airbnb Tools: Demonstrates extensibility for custom tool integrations.
  • The agent utilizes a "Think Node" process for reasoning and Window Buffer Memory to maintain conversational context.
  • Responses are formulated and sent back to the user on Telegram.

5. Google Automations

  • Invoice Generation (via /invoice command):
    • Copies a predefined Google Docs invoice template from your Google Drive.
    • Populates the new document with details (client name, items, etc. – currently uses placeholder data from an 'Edit Fields' node, which can be customized to parse input from the command).
    • Converts the populated Google Doc into a PDF file.
    • Sends the generated PDF invoice to the user via Telegram.
  • Calendar Management (via AI Agent or specific commands like /birthday):
    • The /birthday command fetches upcoming birthdays from a specified Google Calendar.
    • The AI Agent can also interact with Google Calendar to create events or retrieve information based on natural language requests.

6. Web Search (via /brave <query> command or AI Agent)

  • Performs a web search using the Brave Search API.
  • Returns a list of search results, including titles and URLs, to the user on Telegram.

7. Help Command (/help)

  • Provides the user with a formatted list of all available Telegram commands and their basic usage instructions.

🛠️ Setup Steps & Credentials

To get this workflow bundle up and running, you'll need to configure several credentials:

  1. Telegram:
    • Create a new bot via @BotFather on Telegram to obtain a Bot Token.
    • Add this token to the Telegram Trigger node and all Telegram (sender) nodes in the workflow.
  2. OpenAI:
    • Obtain an API Key from platform.openai.com.
    • Create an OpenAI credential.
    • Use this credential in the Convert audio to text (OpenAI node for Whisper transcription) and all Embeddings OpenAI nodes (for RAG system).
  3. Replicate API (Text-to-Speech):
    • Sign up at replicate.com and get your API token.
    • Create an HTTP Bearer Auth credential using this token.
    • Assign this credential to the Call Replicate API (HTTP Request) node.
  4. Google Gemini (PaLM API):
    • Get an API key from Google AI Studio or Google Cloud Console.
    • Create a Google Gemini(PaLM) Api credential.
    • Assign it to all Google Gemini Chat Model nodes.
  5. Qdrant (Vector Database):
    • Set up a Qdrant instance (either cloud-hosted or self-managed).
    • Note your Qdrant instance URL and API Key (if security is enabled).
    • Create a QdrantApi credential with these details.
    • Assign it to the Qdrant Vector Store nodes.
    • For the Refresh collection node (an HTTP Request node used to clear the collection for /pdf command demo), create an HTTP Header Auth credential with your Qdrant API key if required by your instance.
  6. Mistral AI (PDF OCR):
    • Obtain an API key from console.mistral.ai.
    • Create a Mistral Cloud API credential.
    • Assign this to the Mistral Upload, Mistral Signed URL, and Mistral DOC OCR (HTTP Request) nodes.
  7. Google Drive & Google Docs:
    • Ensure the Google Drive API and Google Docs API are enabled in your Google Cloud Console project.
    • Set up OAuth 2.0 credentials (Client ID and Client Secret).
    • Create Google Drive OAuth2 Api and Google Docs OAuth2 Api credentials.
    • Assign these to the respective Google Drive and Google Docs nodes throughout the workflow.
    • Important: Configure relevant Folder IDs (for PDF search, invoice template source, invoice output) and the invoice template Document ID in the Google Drive and Google Docs nodes.
  8. Google Calendar:
    • Enable the Google Calendar API in your Google Cloud Console project.
    • Set up OAuth 2.0 credentials.
    • Create a Google Calendar OAuth2 Api credential.
    • Assign it to the Google CalendarTool and Google Calendar nodes.
    • Specify the correct calendar names or IDs in the nodes (e.g., for birthdays, holidays, new event creation).
  9. Brave Search:
    • Get a Brave Search API key from their developer portal.
    • Create a Brave Search API credential.
    • Assign it to the Brave Search nodes and tools.
  10. (Optional) Airbnb MCP Client:
    • The workflow includes example nodes for Airbnb MCP tools. If you intend to use or expand these, set up the corresponding MCP Client API credentials.

💡 Customization & Learning

This "Beginner Bundle" is not just a ready-to-use solution but also a fantastic learning resource:

  • Explore AI Agent Prompts: Dive into the AI Agent nodes to see how prompts are structured to guide the LLM's behavior, including the "Think Node" process and character guidance for robust messaging.
  • Modify Toolsets: Easily add or remove tools for the AI agent to expand its capabilities.
  • Invoice Customization: Adapt the Edit Fields node and the Google Docs template to match your invoicing needs. You can extend it to parse invoice details directly from the Telegram command.
  • RAG Parameters: Experiment with chunk sizes, overlap, and different embedding models in the RAG pipeline.
  • Extend Commands: Add new commands and corresponding functionalities by expanding the main Switch node and building out new automation paths.

By setting up and dissecting this workflow, beginners can gain a practical understanding of building complex, AI-driven applications, integrating various services, and managing different data flows.

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 - Sticky Note12

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

Block 2 - Listen for incoming events

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

Block 3 - Download voice file

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

Block 4 - Combine content and set properties

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - Convert audio to text

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.5

Block 6 - Send Typing action

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

Block 7 - Sticky Note13

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

Block 8 - Sticky Note14

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

Block 9 - Sticky Note15

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

Block 10 - Sticky Note16

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

Block 11 - Call Replicate API

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

Block 12 - Send AI Voice Response via Telegram

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

Block 13 - Download Replicate Audio

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 14 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 15 - Send AI Text Response (Chat)

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

Block 16 - Send Brave Search Results via Telegram

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

Block 17 - Think

Type / Role
@n8n/n8n-nodes-langchain.toolThink - toolThink
Config choices
Version 1

Block 18 - Calculator

Type / Role
@n8n/n8n-nodes-langchain.toolCalculator - toolCalculator
Config choices
Version 1

Block 19 - Date & Time

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

Block 20 - Brave Search 2

Type / Role
@brave/n8n-nodes-brave-search.braveSearch - braveSearch
Config choices
Version 1

Block 21 - Brave Search

Type / Role
@brave/n8n-nodes-brave-search.braveSearchTool - braveSearchTool
Config choices
Version 1

Block 22 - Google Calendar Create Event

Type / Role
n8n-nodes-base.googleCalendarTool - googleCalendarTool
Config choices
Version 1.3

Block 23 - Google Calendar Next Holiday

Type / Role
n8n-nodes-base.googleCalendarTool - googleCalendarTool
Config choices
Version 1.3

Block 24 - Question and Answer Chain

Type / Role
@n8n/n8n-nodes-langchain.chainRetrievalQa - chainRetrievalQa
Config choices
Version 1.5

Showing the first 24 of 79 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Build a multi-functional Telegram bot with Gemini, RAG PDF search & Google Suite
Complexity advanced
Nodes 79
Categories Personal Productivity, AI Chatbot
Author Issam AGGOUR
Published 30 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4525/4525.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 multi-functional Telegram bot with Gemini, RAG PDF search & Google Suite do?

The Ultimate Beginner's Guide to an AI Powered Telegram Assistant (PDF, Brave search & Google Suite) This comprehensive workflow bundle is designed as a powerful starter kit, enabling you to build ...

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 Personal Productivity, AI Chatbot use case.