Skip to main content

Create a factual learning assistant with RAG, Gemini, Telegram & MongoDB

Workflow preview

Workflow preview
100%
Create a factual learning assistant with RAG, Gemini, Telegram & MongoDB preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Who's it for? This template is perfect for educational institutions, coaching centers (like UPSC, GMAT, or specialized technical training), internal corporate knowledge bases, and SaaS companies th...

Best for

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

Tools used

@n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.chattrigger, n8n-nodes-base.googledrivetrigger, @n8n/n8n-nodes-langchain.vectorstoremongodbatlas, @n8n/n8n-nodes-langchain.lmchatgooglegemini, n8n-nodes-base.googledrive, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.formtrigger

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Create a factual learning assistant with RAG, Gemini, Telegram & MongoDB
Workflow name
Create a factual learning assistant with RAG, Gemini, Telegram & MongoDB

Who's it for?

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

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

How it works / What it does

This workflow establishes a Retrieval-Augmented Generation (RAG) pipeline to build a secure, fact-based AI Agent. It operates in two main phases:

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

2. AI Query & Response:

A user asks a question via Telegram. The AI 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.

This process ensures the agent never "hallucinates" or uses general internet knowledge, making the responses accurate and trustworthy.

Requirements

To use this template, you will need the following accounts and credentials:

  1. n8n Account
  2. Google Gemini API Key: For generating vector embeddings and powering the AI Agent.
  3. MongoDB Atlas Cluster: A free-tier cluster is sufficient, configured with a Vector Search index.
  4. Telegram Bot: A bot created via BotFather and a Chat ID where the bot will listen for and send messages.
  5. Google Drive Credentials (if using the Google Drive ingestion path).

How to set up

  • Set up MongoDB Atlas: Create a free cluster and a database. Create a Vector Search Index on your collection to enable efficient searching.
  • Configure Ingestion Path:
    • Set up the Webhook trigger for your "On form submission" or connect your Google Drive credentials.
    • Configure the Embeddings Google Gemini node with your API Key.
    • Connect the MongoDB Atlas Vector Store node with your database credentials, collection name, and index name.
  • Configure Chat Path:
    • Set up the Telegram Trigger with your Bot Token to listen for incoming messages.
    • Configure the Google Gemini Chat Model with your API Key.
    • Connect the MongoDB Atlas Vector Store 1 node as a Tool within the AI Agent. Ensure it points to the same vector store as the ingestion path.
  • Final Step: Configure the Send a text message node with your Telegram Bot Token and the Chat ID.

How to customize the workflow

  • Change Knowledge Source: Replace the Google Drive nodes with nodes for Notion, SharePoint, Zendesk, or another document source.
  • Change Chat Platform: Replace the Telegram nodes with a Slack, Discord, or WhatsApp Cloud trigger and response node.
  • Refine the Agent's Persona: Open the AI Agent node and edit the System Instruction to give the bot a specific role (e.g., "You are a senior UPSC coach. Answer questions politely and cite sources.").

đź’ˇ Example Use Case

  • An UPSC/JEE/NEET coaching uploads NCERT summaries and previous year notes to Google Drive.
  • Students ask questions in the Telegram group — the bot instantly replies with contextually accurate answers from the uploaded materials.
  • The same agent can generate daily quizzes or concise notes from this curated content automatically.

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 - Default Data Loader

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

Block 2 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.3

Block 3 - File uploaded

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

Block 4 - MongoDB Atlas Vector Store - Insert

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas - vectorStoreMongoDBAtlas
Config choices
Version 1.3

Block 5 - MongoDB Atlas Vector Store - Retrieve

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreMongoDBAtlas - vectorStoreMongoDBAtlas
Config choices
Version 1.3

Block 6 - Google Gemini Chat Model

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

Block 7 - Download file

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

Block 8 - RAG Agent

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

Block 9 - On File Upload

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

Block 10 - Listen for Aspirant Question

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

Block 11 - Send Answer via Telegram

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

Block 12 - Convert Documents to Embeddings

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

Block 13 - Retrieve Documents from Embeddings

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

Block 14 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 15 - Sticky Note

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

Block 16 - Sticky Note1

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

Block 17 - Sticky Note2

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

3. Summary Table

Workflow Create a factual learning assistant with RAG, Gemini, Telegram & MongoDB
Complexity advanced
Nodes 17
Categories Internal Wiki, AI RAG
Author Pawan
Published 14 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9595/9595.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 Create a factual learning assistant with RAG, Gemini, Telegram & MongoDB do?

Who's it for? This template is perfect for educational institutions, coaching centers (like UPSC, GMAT, or specialized technical training), internal corporate knowledge bases, and SaaS companies th...

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.