Personal RAG Knowledge Base Builder and Query Tool via Telegram - n8n Workflow

Automate building a Retrieval-Augmented Generation (RAG) knowledge base using this advanced n8n workflow. Extract summaries from YouTube videos or articles, store them in Google Sheets, and query them instantly using a Telegram bot.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users looking to automatically curate and summarize content from the web (YouTube, articles).
Knowledge workers or researchers who need a searchable, personalized knowledge base (RAG).
Developers seeking advanced n8n templates utilizing AI Agents and custom tools.
Anyone wanting to build a conversational interface for their private data store using a Telegram bot.

Overview

This powerful n8n workflow provides a comprehensive solution for automated knowledge management. It addresses the common challenge of processing and making long-form content (like YouTube transcripts or detailed articles) instantly searchable. This specific n8n workflow operates in two phases: ingestion and retrieval. By leveraging the flexibility of the n8n platform, users can automatically feed links into a Google Sheet, and the automation handles the complex extraction, summarization via Google Gemini, and secure storage in another Sheet (acting as the knowledge base). Furthermore, it implements a Retrieval-Augmented Generation (RAG) system, allowing users to query this data instantly via a Telegram bot. This approach makes this one of the most practical n8n templates available for creating a personalized, accessible data store.

How it Works

This automation utilizes two distinct entry points, each defined by a specific n8n trigger, creating a dual-function system.

1. Knowledge Ingestion Path (Google Sheets Trigger)


  1. Trigger: The process starts with the Google Sheets Trigger, monitoring a dedicated input sheet ('Sheet2') for new URLs added by the user.

  2. Filtering: A Filter n8n node ensures only unprocessed rows containing a URL are passed forward (checking if the 'Stored' column is empty).

  3. URL Detection: An If n8n node intelligently checks if the URL is a YouTube link (youtu.be or youtube.com).

  4. Data Extraction: If it is a YouTube link, an HTTP Request n8n node calls an external service (Apify's YouTube Transcript Ninja) to obtain the full transcript. If it is a standard article, a standard HTTP Request n8n node fetches the content, which is then cleaned by the Markdown n8n node.

  5. AI Summarization: Both paths converge into an Information Extractor n8n node, which uses the Google Gemini Chat Model to generate a Title and a concise, refined summary (Article Refined Data).

  6. Storage & Status Update: The extracted data is stored in the main knowledge base sheet ('Sheet1') using an Append row in sheet n8n node. Finally, the status of the original URL in the trigger sheet ('Sheet2') is updated to 'Stored' using an Append or update row n8n node.

2. Data Retrieval Path (Telegram Trigger)


  1. Trigger: The workflow is constantly listening via the Telegram Trigger for incoming user messages.

  2. AI Query: The user request is fed into the AI Agent n8n node, which is configured with the Google Gemini Chat Model.

  3. RAG Tool Use: The AI Agent uses the Get row(s) in sheet in Google Sheets n8n node as a tool. This crucial setup enables the agent to search the existing knowledge base ('Sheet1') dynamically to find the most relevant context for the user's question, ensuring highly accurate retrieval.

  4. Response: The final, contextualized response from the AI Agent is returned to the user via the Send a text message n8n node.

Installation Guide

This n8n workflow requires several credentials for full functionality. Ensure you have access to your n8n instance and the necessary API keys.


  1. Import the n8n workflow JSON: Copy the provided JSON code and import it into your n8n instance using the "New" button and selecting "Import from JSON."

  2. Set up Telegram Credentials: Configure both the Telegram Trigger and the Send a text message n8n node with your Telegram Bot token. The Telegram Trigger must be activated to listen for messages.

  3. Configure Google Gemini (PaLM) API: Add your Gemini API key to the 'Google Gemini(PaLM) API' credentials within n8n. This key powers the Information Extractor and the AI Agent n8n node operations.

  4. Connect Google Sheets: Set up Google Sheets OAuth2 credentials. This is necessary for all Google Sheets n8n node operations (trigger, ingestion, and retrieval tool). Ensure the spreadsheet document is shared with the connected service account.

  5. Configure Apify Integration: The YouTube transcript functionality relies on an external HTTP Request n8n node calling Apify. Replace the placeholder URL in the relevant HTTP Request n8n node with your specific Apify Actor endpoint URL and necessary API parameters.

Node Details

Telegram Trigger: The primary n8n trigger for data retrieval, initializing the RAG search when a user sends a message to the bot.
Google Sheets Trigger: The core n8n trigger for data ingestion, initiating the extraction and summarization process when a new URL is added.
If n8n node: Critical flow control component that directs the data based on URL type (YouTube vs. standard article).
HTTP Request n8n node (Apify): Configured to execute the YouTube Transcript Ninja Actor via API, obtaining the source material for the summarization.
Information Extractor n8n node: An essential LangChain n8n node that uses the Google Gemini Chat Model to extract structured, summarized data (Title and Article Refined Data) from the raw input.
Google Gemini Chat Model n8n node: Supplies the large language model capabilities needed for advanced reasoning and summarization across multiple parts of the n8n workflow.
AI Agent n8n node: The centerpiece of the RAG system. It utilizes the Get row(s) Google Sheets n8n node as a custom tool to dynamically search the stored knowledge before generating an informed response based on the user's Telegram input.
Google Sheets (Append & Update) n8n node: Handles persistent storage, adding the refined summaries to the knowledge base and marking the URLs as processed in the input sheet. This powerful n8n node setup maintains data integrity.

Related n8n Workflows

Free

Nodes: 13 Nodes
Updated: December 26 2025
View all
Created by

Featured*