đź“– Create a factual learning assistant with RAG, Gemini, Telegram & MongoDB

⚡ 468 views · 📖 Internal Wiki & Knowledge Base

Description

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

How to customize the workflow

đź’ˇ Example Use Case

đź”— Nodes Used

Telegram, Telegram Trigger, Google Drive, Google Drive Trigger, AI Agent, Simple Memory

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup