Deploy a custom AI Document Q&A chatbot on Telegram using this powerful n8n workflow. Integrates Google Gemini, Supabase vector storage, and advanced RAG capabilities. Explore n8n templates for AI.
Download this n8n workflow template and start using it instantly.



















Users needing a private, centralized knowledge base accessible via a messaging app.
Technical users and developers looking for advanced n8n templates integrating LangChain agents and vector databases.
Businesses aiming to automate document information retrieval (RAG).
Anyone interested in leveraging Google Gemini's embedding and chat models within a custom n8n workflow.
This automation solves the problem of siloed document data by transforming your PDF files into a searchable knowledge base accessible via Telegram. The core of this system is a powerful n8n workflow that uses a Telegram Trigger to initiate one of two scenarios: either processing a document for ingestion or answering a user's conversational query.
When a PDF is uploaded, the n8n node structure handles downloading the file, extracting text, generating vector embeddings using the Google Gemini model, and securely storing them in a Supabase vector store. When a question is asked, the system performs Retrieval-Augmented Generation (RAG) by fetching the most relevant document chunks from Supabase before generating a final, contextually rich answer using the Gemini Chat Model. This seamless integration showcases the power of building advanced AI assistants using n8n and its specialized AI n8n nodes.
The entire process is controlled by a single n8n workflow, starting with the Telegram Trigger n8n node:
Telegram Trigger fires upon receiving any message. A Command Router n8n node inspects the incoming payload to determine if it contains a document (PDF upload) or text (chat message).Extract from File extracts text content from the PDF.Recursive Character Text Splitter n8n node.Embeddings Google Gemini generates high-dimensional vectors for each chunk.Supabase - Save Embeddings stores these vectors and the corresponding text chunks into the userknowledgebase table in your Supabase instance.AI Agent n8n node, which maintains conversation history via the Simple Memory n8n node.Answer questions with a vector store tool (RAG via Supabase/Gemini) for document-specific questions or the OpenWeatherMap tool for real-time weather data.Google Gemini Chat Model for reasoning and response generation.Code n8n node (Handle formatting and split). This critical step cleans up HTML formatting (as LLMs often generate unsupported tags) and splits the potentially long response into multiple messages to adhere to Telegram's 4096-character limit. The final messages are delivered via the Telegram n8n node.To deploy this specialized n8n workflow, follow these steps:
n8n trigger and all reply nodes.Google Gemini Chat Model and the Embeddings Google Gemini n8n node.pgvector extension and run the provided SQL script to create the userknowledgebase table and the matchdocuments function. Ensure the table name userknowledge_base is correctly configured in the Supabase Vector Store n8n node and the Supabase - Save Embeddings n8n node. Telegram Trigger (n8n trigger): Starts the n8n workflow upon receiving a Telegram message (text or document).
Command Router (Switch): Directs the flow based on whether the input is a file (document) or a chat message (text).
AI Agent (Langchain Agent n8n node): The brain of the chat flow. Uses the Gemini model and orchestrates the use of specialized tools based on the user's query.
Simple Memory (Langchain Memory n8n node): Stores conversation history linked to the user's ID (sessionKey) to maintain context in the n8n workflow.
Answer questions with a vector store (Langchain Tool n8n node): The RAG tool. Used by the AI Agent to query the Supabase knowledge base for relevant document snippets.
Supabase Vector Store (n8n node): Configured for retrieval, enabling similarity search against the userknowledgebase table.
Embeddings Google Gemini (n8n node): Generates 768-dimension vectors for document chunks during the ingestion process.
Extract from File (n8n node): Specifically configured to extract text from the PDF file downloaded from Telegram.
Recursive Character Text Splitter (n8n node): Optimally breaks down large documents into smaller, meaningful chunks before embedding.
Handle formatting and split (Code n8n node): A custom Python script that post-processes the AI's output, removing unsupported Telegram HTML tags, escaping characters, and splitting the final message into chunks to ensure successful delivery via the Telegram n8n node.
Use this powerful n8n workflow to automate complex document parsing, utilizing Mistral OCR for extraction, structured data generation via specialized AI agents, and automated delivery through Telegram. A comprehensive n8n template for data processing.

Create a powerful Retrieval-Augmented Generation (RAG) system using a comprehensive n8n workflow. Analyze uploaded files with Llama Parser, index data in Pinecone, and deploy a Gemini-powered chatbot for Q&A.

Deploy a robust doctor appointment scheduler using this n8n workflow. It leverages Telegram for instant chat, Google Gemini for transcription, and Google Sheets for availability tracking and booking, all managed by a powerful n8n node agent.

Build a powerful RAG system using this n8n workflow. Automatically index Google Drive files into a vector store and answer questions via Telegram using the GPT-4-mini n8n node.

Use this advanced n8n workflow to build a powerful Retrieval-Augmented Generation (RAG) system. Integrate Google Drive, OpenAI embeddings, and Pinecone DB for instant document Q&A via chat or a custom UI webhook.

Build a powerful RAG system using this n8n workflow. Ingest research papers, generate Voyage-Context-3 contextual embeddings, store vectors in MongoDB Atlas, and run an interactive Q&A agent powered by OpenAI. This n8n templates example showcases advanced AI flows.

A Senior Software Engineer with over 14 years of experience, I'm a coding enthusiast passionate about building scalable full-stack and backend cloud solutions.







































