Use this professional n8n workflow template to build a secure Retrieval-Augmented Generation (RAG) system. Integrate Telegram, Google Gemini, and MongoDB Atlas to create an expert AI learning assistant based strictly on your proprietary documents.
Download this n8n workflow template and start using it instantly.
Educational institutions and coaching centers (e.g., UPSC, specialized training) requiring factual QA based on syllabus documents.
Businesses needing an internal knowledge base that strictly references policy manuals or technical documents.
Users looking to create custom, fact-grounded AI Assistants without relying on general LLM knowledge.
Developers exploring advanced RAG implementation within an n8n workflow.
This comprehensive n8n workflow template solves the crucial problem of AI hallucination by enforcing a strict RAG mandate. The goal is to create an expert study assistant, exemplified here as a UPSC Analyst, whose responses are derived exclusively from verified, uploaded documents. This powerful n8n automation is split into two robust pipelines: Knowledge Ingestion and AI Query. By using the Google Gemini embedding n8n node and storing vectors in MongoDB Atlas, this n8n workflow ensures a high degree of security and accuracy. Whether you use the Google Drive n8n trigger or the Webhook Form n8n trigger for ingestion, the process creates a verifiable source of truth, making this one of the most reliable n8n templates for knowledge management.
This n8n workflow operates in two phases:
File uploaded n8n node), or the Webhook Form n8n trigger (On File Upload).Download file).Default Data Loader processes the binary file data (e.g., PDFs, documents) in preparation for vectorization.Convert Documents to Embeddings n8n node, powered by Google Gemini, transforms the document text into numerical vector embeddings.MongoDB Atlas Vector Store - Insert n8n node securely pushes these fresh embeddings into the designated MongoDB Atlas collection, establishing the knowledge base.Listen for Aspirant Question n8n trigger (Telegram) fires when a user sends a message to the configured bot.RAG Agent n8n node, which acts as the orchestrator.MongoDB Atlas Vector Store - Retrieve n8n node. This tool performs a semantic search on the vector index using the query and retrieves the most relevant document chunks.RAG Agent feeds the user's original query, the retrieved context (from MongoDB), and the comprehensive system prompt (Expert UPSC Analyst persona) into the Google Gemini Chat Model n8n node.RAG Agent then passes this final answer to the Send Answer via Telegram n8n node, completing the n8n workflow execution.To deploy this advanced n8n workflow template, follow these steps:
Listen for Aspirant Question n8n trigger and the Send Answer via Telegram n8n node, ensuring you replace CHATID> and configure the appropriate chat group ID for the trigger.DRIVEFOLDERIDWATCH> with the ID of the folder containing your source documents. File uploaded (Google Drive Trigger): This n8n trigger starts the ingestion process when a new file is detected in a specific Google Drive folder. Part of the ingestion pipeline.
On File Upload (Form Trigger): An alternative n8n trigger, allowing users to upload files via a dynamic webhook form to kick off the ingestion pipeline.
Download file (Google Drive n8n node): Retrieves the actual binary content of the file detected by the trigger, making it available for processing.
Default Data Loader: A specialized Langchain n8n node used to structure the raw binary file data into a format suitable for the embedding model.
Convert Documents to Embeddings (Google Gemini n8n node): Essential RAG component. This node converts the documents into numerical vectors using the Google Gemini API.
MongoDB Atlas Vector Store - Insert: This core n8n node takes the generated embeddings and saves them into the specified MongoDB collection, acting as the knowledge base builder.
Listen for Aspirant Question (Telegram Trigger): The primary n8n trigger for the query path. It listens for incoming chat messages in a defined Telegram group or chat.
Google Gemini Chat Model (LLM n8n node): Serves as the large language model component, providing the reasoning and natural language generation for the RAG Agent.
Simple Memory (Langchain n8n node): Provides conversation history storage, allowing the RAG Agent to maintain context across multiple turns.
MongoDB Atlas Vector Store - Retrieve: Configured as a tool for the RAG Agent. It executes the semantic similarity search against the vector index to retrieve relevant document chunks based on the user's query.
RAG Agent (Langchain Agent n8n node): The brain of the operation. It interprets the prompt, decides whether to use the retrieval tool, manages the memory, and orchestrates the final answer synthesis according to the detailed system prompt (UPSC Analyst).
Send Answer via Telegram (Telegram n8n node): The final action n8n node, responsible for sending the synthesized output from the RAG Agent back to the user's chat.
Build a sophisticated, multi-level Telegram bot menu system using this modular n8n workflow. This n8n template uses Function nodes for configuration and routing, offering unparalleled scalability for complex chatbot logic.

Create a robust API server using a specialized n8n trigger for AI agents. This n8n workflow provides 14 tool operations to search and download Domain Index data, utilizing dynamic parameters via the n8n node structure.

Deploy a powerful n8n workflow to create a custom AI Data Analyst chatbot. Analyze live Google Sheets data instantly using the OpenAI n8n node and LangChain agents for real-time business intelligence.

Use this n8n workflow to automatically fetch Google Analytics (GA4) data, perform year-over-year comparison using OpenAI (GPT-4O), and instantly send professional, summarized reports via email and Telegram. Start automating routine data analysis with these powerful n8n templates.

Deploy a powerful n8n workflow for AI scheduling. This n8n template uses GPT-5, Google Sheets as a knowledge base, Google Calendar, and Gmail for fully automated client support and booking confirmation.

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







































