๐Ÿ“– Create an AI Telegram bot using Google Drive, Qdrant, and OpenAI GPT-4.1

โšก 345 views ยท ๐Ÿ“– Internal Wiki & Knowledge Base

Description

How it works

This workflow creates an intelligent Telegram bot with a knowledge base powered by Qdrant vector database. The bot automatically processes documents uploaded to Google Drive, stores them as embeddings, and uses this knowledge to answer questions in Telegram. It consists of two independent flows: document processing (Google Drive โ†’ Qdrant) and chat interaction (Telegram โ†’ AI Agent โ†’ Telegram).

Step-by-step

Document Processing Flow:

Telegram Chat Flow:

Set up steps

Estimated set up time: 15 minutes

  1. Google Drive Setup:

    • Add your Google Drive OAuth2 credentials to the New File Trigger, Download File, and Move to Processed Folder nodes.
    • Create two folders in your Google Drive: one for incoming files and one for processed files.
    • Copy the folder IDs from the URLs and update them in the New File Trigger (folderToWatch) and Move to Processed Folder (folderId) nodes.
  2. Qdrant Setup:

    • Add your Qdrant API credentials to the Insert into Qdrant and Qdrant Knowledge Base nodes.
    • Create a collection in your Qdrant instance (e.g., โ€œTest-youtube-adept-ecomโ€).
    • Update the collection name in both Qdrant nodes.
  3. OpenAI Setup:

    • Add your OpenAI API credentials to the OpenAI Chat Model and OpenAI Embeddings nodes.
    • (Optional) Replace the fine-tuned model ID in OpenAI Chat Model with your own model or use a standard model like gpt-4-turbo.
  4. Telegram Setup:

    • Create a Telegram bot via @BotFather and obtain the bot token.
    • Add your Telegram bot credentials to the Telegram Message Trigger and Send Response to Telegram nodes.
    • Update the authorized chat ID in the Filter Authorized User node (replace 26899549 with your Telegram user ID).
  5. Customize System Prompt (Optional):

    • Modify the system message in the AI Agent node to customize your botโ€™s personality and behavior.
    • The current prompt is configured for an n8n automation expert creating social media content.
  6. Activate the Workflow:

    • Toggle โ€œActiveโ€ in the top-right to enable both the Google Drive trigger and Telegram trigger.
    • Upload a document to your Google Drive folder to test the document processing flow.
    • Send a message to your Telegram bot to test the chat interaction flow.

๐Ÿ”— Nodes Used

Telegram, Telegram Trigger, Google Drive, Google Drive Trigger, Filter, AI Agent

๐Ÿ“ฅ Import

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

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup