AI Document Assistant via Telegram + Supabase
Configured with Agent, Aggregate, Document Default Data Loader, Embeddings Google Gemini, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- AI & models
- Integration
- Trigger
- Messaging
- Files / media
- Transform
- Data store
- Routing
- Code
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| Google Gemini Chat Model | AI & models | LM Chat Google Gemini | See node parameters |
| OpenWeatherMap | Integration | Open Weather Map Tool | See node parameters |
| AI Agent | AI & models | Agent | See node parameters |
| Telegram Trigger | Trigger | Telegram Trigger | See node parameters |
| Telegram | Messaging | Telegram | See node parameters |
| Think | AI & models | Tool Think | See node parameters |
| Embeddings Google Gemini | AI & models | Embeddings Google Gemini | See node parameters |
| Default Data Loader | Files / media | Document Default Data Loader | See node parameters |
| Recursive Character Text Splitter | Transform | Text Splitter Recursive Character Text Splitter | See node parameters |
| Extract from File | Transform | Extract From File | |
| Answer questions with a vector store | AI & models | Tool Vector Store | See node parameters |
| Supabase Vector Store | Data store | Vector Store Supabase | See node parameters |
| Telegram - Embedding Complete | Messaging | Telegram | See node parameters |
| Supabase - Save Embeddings | Data store | Vector Store Supabase | See node parameters |
| Command Router | Routing | Switch | See node parameters |
| Telegram - Download file | Messaging | Telegram | file |
| Aggregate | Transform | Aggregate | See node parameters |
| Fallback- No formatting | Messaging | Telegram | See node parameters |
| Split Out | Transform | Split Out | See node parameters |
| Simple Memory | Data store | Memory Buffer Window | See node parameters |
| Handle formatting and split | Code | Code | See node parameters |
| Manual Mapping | Transform | Edit Fields | See node parameters |
| Unsupported message | Messaging | Telegram | See node parameters |
| Send processing document message | Messaging | Telegram | See node parameters |
| Send embedding Started message | Messaging | Telegram | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
googlePalmApiopenWeatherMapApisupabaseApitelegramApi
Workflow notes
Sticky Note10
✅ Scenario 2 – Document Upload and Embedding
Flow for downloading a document sent via Telegram, extracting its text, generating embeddings, and inserting them into Supabase Vector Store.
Sticky Note11
✅ Scenario 1 – Chatbot Interaction
Flow for handling user messages sent to the bot. Includes accessing weather data, answering questions based on user-uploaded documents, and running code using a code execution tool.
Aggregate
This is used to flag the end of progress—no real aggregation.
Fallback- No formatting
This is used if, even after HTML formatting,g Telegram wasn't able to process the text, so we send it without formatting.
Handle formatting and split
This is used to prevent Markdown issues in Telegram while sending messages.
🤖 Telegram AI Assistant for Your Documents (n8n + Supabase + Gemini)
🤖 Telegram AI Assistant for Your Documents (n8n + Supabase + Gemini)
This project transforms a standard Telegram bot into your dedicated AI assistant – designed to understand and answer questions based on your own documents. It seamlessly integrates the power of Google Gemini for advanced language capabilities and Supabase's vector database for efficient, intelligent document retrieval. Built entirely within the no-code platform n8n, it allows you to deploy a sophisticated document chatbot without writing a single line of code.
Simply upload any PDF document to the bot, and instantly gain the ability to chat with it, querying its contents as if it were a knowledgeable expert on your uploaded files.
📹 Watch the Bot in Action
▶️ Click the image above to watch a live demo on YouTube.
This video provides a live demonstration of the bot's core features and how it interacts. See a quick walkthrough of its capabilities and user flow.
✨ Ignite Your Workflow: Use Cases
This project empowers two core interactions:
1. Conversational AI Interface (User Inquiry → Telegram Bot → Intelligent Answers)
- Users pose questions directly to the Telegram bot.
- The bot generates relevant, informative answers using the cutting-edge capabilities of the Google Gemini LLM.
- Leveraging a powerful vector search mechanism, it can pull specific, contextual information from previously uploaded documents to provide highly relevant and informed responses.
- (Optional) Augment answers with real-time data, like current weather information.
2. Effortless Document Integration (User Upload PDF → Processing → Searchable Knowledge)
- Users upload a PDF document directly to the bot.
- The workflow automatically parses the document content, converts it into numerical representations called embeddings using Gemini's embedding models.
- These embeddings, alongside the document's text content, are then securely stored in a dedicated Supabase vector table, creating a searchable knowledge base.
- Immediately after successful processing, the document becomes part of the bot's memory, enabling users to ask questions about its contents via the standard chat interface.
🧠 Core Intelligence Features
- ✅ Pure No-Code: Developed and managed entirely within the intuitive n8n automation platform.
- 📄 Seamless PDF Integration: Easily upload and process PDF documents to expand the bot's knowledge.
- 🧠 Powered by Google Gemini: Utilizes Gemini for both generating document embeddings and formulating intelligent conversational responses.
- 🗂 Vector Database Memory (Supabase): Employs Supabase as a robust vector database for storing and efficiently searching document embeddings, providing the bot with long-term memory about your content.
- ⚡️ Rapid & Private Retrieval: The vector search allows for swift identification and retrieval of the most relevant document snippets based on the user's query. This approach enhances response speed and significantly improves data privacy, as the original document content remains securely stored in your Supabase instance, and only the user's query and the retrieved relevant chunks are sent to the LLM for generating a response.
- 🧹 Intelligent HTML Post-processing: Cleans the LLM's responses by removing HTML tags not supported by Telegram while preserving essential formatting and correctly escaping special characters in the text content.
- 📤 Adaptive Message Chunking: Splits lengthy AI-generated answers into multiple messages that adhere to Telegram's 4096-character limit, ensuring the full response is delivered cleanly.
- 🌦️ Dynamic Weather Data: (Optional) Integrates with OpenWeatherMap to provide current weather information upon request.
- 📝 Note on Usage: This workflow is designed primarily for personal, single-user scenarios. It processes each message independently and does not include multi-user session management, making it unsuitable for public deployment where different users require separate conversational contexts. For a session-based Telegram bot implemented in Python, you may refer to this project, which is a multi-model telegram bot: https://github.com/mohamadghaffari/gemini-tel-bot.
🛠 Getting Started: Setup
1. Deploy the Workflow in n8n
- Click the "Use this workflow" button on the n8n template page.
- This will open the workflow directly in your n8n instance, ready for configuration.
2. Connect Your Services: Configure Credentials
Create API credentials for the following services within your n8n instance:
| Service | Purpose | |------------------|------------------------------------| | Telegram API | Receiving user messages & sending replies | | Google Gemini | Generating embeddings & LLM responses | | Supabase | Storing & searching document vectors | | OpenWeatherMap | (Optional) Fetching weather data |
3. Prepare Your Supabase Knowledge Base
Set up a vector-enabled table in your Supabase project to store your document embeddings. Execute the following SQL commands in your Supabase SQL Editor:
-- Enable the pgvector extension to work with embedding vectors
create extension vector;
-- Create a table to store your documents and their embeddings
create table user_knowledge_base (
id bigserial primary key,
content text, -- Stores the text chunk from the document
metadata jsonb, -- Stores document information (e.g., filename, page number)
embedding vector(768) -- Stores the vector representation (embedding) generated by Gemini. Adjust dimension if using a different model.
);
-- Create a function to perform vector similarity search against your documents
create function match_documents (
query_embedding vector(768),
match_count int default null,
filter jsonb DEFAULT '{}'
) returns table (
id bigint,
content text,
metadata jsonb,
similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
return query
select
id,
content,
metadata,
-- Calculate cosine similarity: 1 - cosine distance (using the '<=>' operator provided by pgvector)
1 - (user_knowledge_base.embedding <=> query_embedding) as similarity
from user_knowledge_base
where metadata @> filter -- Optional: filter results based on metadata
order by user_knowledge_base.embedding <=> query_embedding -- Order by similarity (closest first)
limit match_count; -- Limit the number of results
end;
$$;
This sets up the necessary table and a function to perform vector similarity searches, allowing you to find document chunks most similar to a user's query.
📚 Integrated Technologies
This project brings together powerful tools:
- n8n – The central hub for workflow automation and integration.
- Telegram Bot API – The communication layer for user interaction.
- Supabase + pgvector Extension – Provides a scalable database with powerful vector search capabilities.
- Google Gemini API – The intelligence engine for embeddings and text generation.
- OpenWeatherMap API – (Optional) For adding real-time weather features.
AI Document Assistant via Telegram + Supabase
AI Document Assistant via Telegram + Supabase
Purpose and structure
This folder contains the AI Document Assistant via Telegram + Supabase workflow. Its executable nodes use agent, aggregate, code, documentDefaultDataLoader, embeddingsGoogleGemini, extractFromFile, lmChatGoogleGemini, memoryBufferWindow, openWeatherMapTool, set, splitOut, switch, telegram, telegramTrigger, textSplitterRecursiveCharacterTextSplitter, toolThink, toolVectorStore, vectorStoreSupabase. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
Telegram Trigger
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Telegram/1539_Telegram_Splitout_Automation_Triggered.json MIT; preserve source notices.