RAG-basierter Telegram-KI-Lernassistent (mit MongoDB und Google Drive)
Dies ist ein Automatisierungsworkflow mit 17 Nodes. Hauptsächlich werden Telegram, FormTrigger, GoogleDrive, Agent, TelegramTrigger und andere Nodes verwendet. Erstellen Sie einen Faktenlern-Assistenten mit RAG, Gemini, Telegram und MongoDB
- •Telegram Bot Token
- •Google Drive API-Anmeldedaten
- •Google Gemini API Key
- •MongoDB-Verbindungsstring
Verwendete Nodes (17)
Kategorie
{
"name": "RAG-based AI Learning Assistant for Telegram using MongoDB and Google Drive",
"tags": [],
"nodes": [
{
"name": "Standard-Datenlader",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
-160,
256
],
"parameters": {
"options": {},
"dataType": "binary"
},
"typeVersion": 1.1,
"id": "Standard-Datenlader-0"
},
{
"name": "Bei Empfang einer Chat-Nachricht",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
96,
-32
],
"parameters": {
"options": {}
},
"typeVersion": 1.3,
"id": "Bei-Empfang-einer-Chat-Nachricht-1"
},
{
"name": "Datei hochgeladen",
"type": "n8n-nodes-base.googleDriveTrigger",
"position": [
-672,
128
],
"parameters": {
"event": "fileCreated",
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"triggerOn": "specificFolder",
"folderToWatch": {
"__rl": true,
"mode": "list",
"value": "<GOOGLE_DRIVE_FOLDER_ID_WATCH>",
"cachedResultUrl": "https://drive.google.com/drive/folders/<GOOGLE_DRIVE_FOLDER_ID_WATCH>",
"cachedResultName": "YT"
}
},
"credentials": {},
"typeVersion": 1,
"id": "Datei-hochgeladen-2"
},
{
"name": "MongoDB Atlas Vector Store - Einfügen",
"type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
"position": [
-240,
48
],
"parameters": {
"mode": "insert",
"options": {},
"mongoCollection": {
"__rl": true,
"mode": "list",
"value": "<MONGO_ATLAS_COLLECTION_NAME>",
"cachedResultName": "<MONGO_ATLAS_COLLECTION_NAME>"
},
"vectorIndexName": "<MONGO_ATLAS_VECTOR_INDEX_NAME_INSERT>",
"embeddingBatchSize": 10
},
"credentials": {},
"typeVersion": 1.3,
"id": "MongoDB-Atlas-Vector-Store---Einf-gen-3"
},
{
"name": "MongoDB Atlas Vector Store - Abrufen",
"type": "@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas",
"position": [
544,
224
],
"parameters": {
"mode": "retrieve-as-tool",
"options": {},
"mongoCollection": {
"__rl": true,
"mode": "list",
"value": "<MONGO_ATLAS_COLLECTION_NAME>",
"cachedResultName": "<MONGO_ATLAS_COLLECTION_NAME>"
},
"toolDescription": "Tool for AI Agent: Use this to search and retrieve relevant documents from the vector store to answer questions or analyze or fulfill tasks.",
"vectorIndexName": "<MONGO_ATLAS_VECTOR_INDEX_NAME_RETRIEVE>"
},
"credentials": {},
"typeVersion": 1.3,
"id": "MongoDB-Atlas-Vector-Store---Abrufen-4"
},
{
"name": "Google Gemini Chat-Modell",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
272,
256
],
"parameters": {
"options": {},
"modelName": "models/gemini-2.5-flash-lite"
},
"credentials": {},
"typeVersion": 1,
"id": "Google-Gemini-Chat-Modell-5"
},
{
"name": "Datei herunterladen",
"type": "n8n-nodes-base.googleDrive",
"position": [
-480,
128
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "list",
"value": "<GOOGLE_DRIVE_FILE_ID_DOWNLOAD>",
"cachedResultUrl": "https://docs.google.com/document/d/<GOOGLE_DRIVE_FILE_ID_DOWNLOAD>/edit?usp=drivesdk",
"cachedResultName": "History of modern India Spectrum 2"
},
"options": {},
"operation": "download"
},
"credentials": {},
"typeVersion": 3,
"id": "Datei-herunterladen-6"
},
{
"name": "RAG-Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
384,
32
],
"parameters": {
"text": "={{ $json.message.text }}{{ $json.chatInput }}",
"options": {
"systemMessage": "You are an Expert UPSC Examination Analyst and Study Assistant. Your primary function is to accurately, comprehensively, and analytically answer user queries related to the Union Public Service Commission (UPSC) Civil Services Examination (CSE).\n\nCore Directives and Persona\nExpertise: You are a master of the UPSC syllabus, exam patterns, current affairs relevance, and interdisciplinary analysis required for the Mains and Prelims examinations.\n\nRAG Mandate: You must utilize the context retrieved from the uploaded documents/knowledge base via the Retrieval-Augmented Generation (RAG) system to formulate your answers.\n\nSource Usage: Answer the query based primarily on the provided documents. Do not hallucinate or introduce information from your general training knowledge if it is contradicted by the documents.\n\nResponse Rules\nComprehensiveness & Depth: Provide answers that are deep, well-structured, and suitable for a high-level competitive exam like UPSC.\n\nAnalytical Approach: If the query asks for analysis, evaluation, comparison, or critical assessment, you must not simply restate facts. Instead, synthesize and analyze the information from the documents to provide a nuanced, insightful, and well-reasoned argument, as an expert would.\n\nSynthesis over Quotation: Do not use direct quotes or phrases like \"according to the document,\" \"the knowledge base states,\" or \"as per the database.\" Integrate the information naturally into a coherent and original answer.\n\nFormatting: Structure your response using clear headings, subheadings, and bullet points where appropriate to enhance readability for an examiner.\n\nLanguage and Tone: Maintain a formal, objective, and authoritative tone suitable for an academic and expert-level response.\n\nQuery Handling Procedure\nAnalyze Query: Determine the core subject, key concepts, and the type of response required (e.g., factual, analytical, comparative).\n\nRetrieve Context: Use the RAG tool to fetch the most relevant and complete information from the indexed documents.\n\nDraft Response: Synthesize the retrieved context and your domain expertise to craft a complete answer that adheres to all the above rules. "
},
"promptType": "define"
},
"typeVersion": 2.2,
"id": "RAG-Agent-7"
},
{
"name": "Bei Datei-Upload",
"type": "n8n-nodes-base.formTrigger",
"position": [
-672,
-32
],
"parameters": {
"options": {},
"formTitle": "file upload",
"formFields": {
"values": [
{
"fieldType": "file",
"fieldLabel": "file",
"acceptFileTypes": ".pdf, .csv, .jpg, .jpeg, .png"
}
]
}
},
"typeVersion": 2.3,
"id": "Bei-Datei-Upload-8"
},
{
"name": "Auf Lernenden-Frage warten",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
96,
96
],
"parameters": {
"updates": [
"message"
],
"additionalFields": {
"chatIds": "@educationalch"
}
},
"credentials": {},
"typeVersion": 1.2,
"id": "Auf-Lernenden-Frage-warten-9"
},
{
"name": "Antwort per Telegram senden",
"type": "n8n-nodes-base.telegram",
"position": [
752,
32
],
"parameters": {
"text": "={{ $json.output }}",
"chatId": "=<TELEGRAM_CHAT_ID>",
"additionalFields": {
"appendAttribution": false
}
},
"credentials": {},
"retryOnFail": false,
"typeVersion": 1.2,
"id": "Antwort-per-Telegram-senden-10"
},
{
"name": "Dokumente in Embeddings konvertieren",
"type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
"position": [
-384,
416
],
"parameters": {},
"credentials": {},
"typeVersion": 1,
"id": "Dokumente-in-Embeddings-konvertieren-11"
},
{
"name": "Dokumente aus Embeddings abrufen",
"type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
"position": [
656,
384
],
"parameters": {},
"credentials": {},
"typeVersion": 1,
"id": "Dokumente-aus-Embeddings-abrufen-12"
},
{
"name": "Einfacher Speicher",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
400,
240
],
"parameters": {},
"typeVersion": 1.3,
"id": "Einfacher-Speicher-13"
},
{
"name": "Notizzettel",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1440,
-112
],
"parameters": {
"width": 672,
"height": 1344,
"content": "Who's it for?\nThis template is perfect for educational institutions, coaching centers (like UPSC, GMAT, or specialized technical training), internal corporate knowledge bases, and SaaS companies that need to provide instant, accurate, and source-grounded answers based on proprietary documents.\n\nIt's designed for users who want to leverage **Google Gemini's** powerful reasoning but ensure its answers are strictly factual and based only on their verified knowledge repository.\n\n## How it works / What it does\nThis workflow establishes a **Retrieval-Augmented Generation (RAG) pipeline** to build a secure, fact-based AI Agent. It operates in two main phases:\n\n**Knowledge Ingestion:** When a new document (e.g., a PDF, lecture notes, or policy manual) is uploaded via a **form** or **Google Drive**, the **Embeddings Google Gemini** node converts the content into numerical vectors. These vectors are then stored in a secure **MongoDB Atlas Vector Store**, creating a private knowledge base.\n\n**AI Query & Response:** A user asks a question via **Telegram**. The **RAG Agent** uses the question to perform a semantic search on the **MongoDB Vector Store**, retrieving the most relevant, source-specific passages. It then feeds this retrieved context to the **Google Gemini Chat Model** to generate a precise, factual answer, which is sent back to the user on Telegram.\n\nThis process ensures the agent never \"hallucinates\" or uses general internet knowledge, making the responses accurate and trustworthy.\n\n## Requirements\nTo use this template, you will need the following accounts and credentials:\n\n* **n8n Account**\n* **Google Gemini API Key:** For generating vector embeddings and powering the AI Agent.\n* **MongoDB Atlas Cluster:** A free-tier cluster is sufficient, configured with a Vector Search index.\n* **Telegram Bot:** A bot created via BotFather and a Chat ID where the bot will listen for and send messages.\n* **Google Drive Credentials** (if using the Google Drive ingestion path).\n\n## How to set up\n\n1. **Set up MongoDB Atlas:** Create a free cluster and a database. Create a Vector Search Index on your collection to enable efficient searching.\n2. **Configure Ingestion Path (Left Side):** Set up the **On File Upload** webhook or connect your **Google Drive** credentials. Configure the **Embeddings** and **MongoDB Insert** nodes with your credentials, collection name, and index name.\n3. **Configure Chat Path (Right Side):** Set up the **Telegram Trigger** with your Bot Token/Webhook. Configure the **Google Gemini Chat Model** and the **MongoDB Retrieve** tool with your credentials/index details.\n4. **Final Step:** Configure the **Send Answer via Telegram** node with your Bot Token and the Chat ID."
},
"typeVersion": 1,
"id": "Notizzettel-14"
},
{
"name": "Notizzettel 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-752,
-160
],
"parameters": {
"color": 4,
"width": 816,
"height": 752,
"content": "Workflow 1: Knowledge Ingestion Pipeline\n(Triggers on file upload to form or Google Drive)"
},
"typeVersion": 1,
"id": "Notizzettel-1-15"
},
{
"name": "Notizzettel 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-160
],
"parameters": {
"color": 6,
"width": 896,
"height": 768,
"content": "Workflow 2: RAG Chatbot Query Pipeline\n(Triggers on question received via Telegram)"
},
"typeVersion": 1,
"id": "Notizzettel-2-16"
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"connections": {
"RAG-Agent-7": {
"main": [
[
{
"node": "Antwort-per-Telegram-senden-10",
"type": "main",
"index": 0
}
]
]
},
"Datei-herunterladen-6": {
"main": [
[
{
"node": "MongoDB-Atlas-Vector-Store---Einf-gen-3",
"type": "main",
"index": 0
}
]
]
},
"Datei-hochgeladen-2": {
"main": [
[
{
"node": "Datei-herunterladen-6",
"type": "main",
"index": 0
}
]
]
},
"Einfacher-Speicher-13": {
"ai_memory": [
[
{
"node": "RAG-Agent-7",
"type": "ai_memory",
"index": 0
}
]
]
},
"Bei-Datei-Upload-8": {
"main": [
[
{
"node": "MongoDB-Atlas-Vector-Store---Einf-gen-3",
"type": "main",
"index": 0
}
]
]
},
"Standard-Datenlader-0": {
"ai_document": [
[
{
"node": "MongoDB-Atlas-Vector-Store---Einf-gen-3",
"type": "ai_document",
"index": 0
}
]
]
},
"Google-Gemini-Chat-Modell-5": {
"ai_languageModel": [
[
{
"node": "RAG-Agent-7",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Bei-Empfang-einer-Chat-Nachricht-1": {
"main": [
[
{
"node": "RAG-Agent-7",
"type": "main",
"index": 0
}
]
]
},
"MongoDB Atlas Vector Store1": {
"ai_tool": [
[
{
"node": "RAG-Agent-7",
"type": "ai_tool",
"index": 0
}
]
]
},
"Auf-Lernenden-Frage-warten-9": {
"main": [
[
{
"node": "RAG-Agent-7",
"type": "main",
"index": 0
}
]
]
},
"Dokumente-in-Embeddings-konvertieren-11": {
"ai_embedding": [
[
{
"node": "MongoDB-Atlas-Vector-Store---Einf-gen-3",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Dokumente-aus-Embeddings-abrufen-12": {
"ai_embedding": [
[
{
"node": "MongoDB Atlas Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
}
}
}Wie verwende ich diesen Workflow?
Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.
Für welche Szenarien ist dieser Workflow geeignet?
Experte
Ist es kostenpflichtig?
Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.
Verwandte Workflows
Pawan
@gladiatorAutomation consultant with expertise in n8n, AI models, and workflow optimization. I help educators, startups, and businesses design scalable automation for content creation, exam prep, and process efficiency. Skilled in integrating Google Sheets, Telegram, and AI agents for impactful results.
Diesen Workflow teilen