AI Document Assistant Automation with Telegram, Supabase & Google Gemini

This detailed tutorial demonstrates how to build a Telegram AI assistant that processes PDF documents and answers user queries using Google Gemini and Supabase vector storage, solving time-consuming document searches effectively.
telegramTrigger
agent
lmChatGoogleGemini
+14
Workflow Identifier: 1293
NODES in Use: telegramTrigger, telegram, openWeatherMapTool, agent, lmChatGoogleGemini, toolThink, vectorStoreSupabase, extractFromFile, textSplitterRecursiveCharacterTextSplitter, embeddingsGoogleGemini, defaultDataLoader, set, switch, stickyNote, code, aggregate, splitOut
Automate document searches with n8n and Telegram

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow turns a Telegram chat into an AI helper for answering questions about PDF documents.
It lets users upload PDFs, extracts text, turns that text into vectors, saves them in a searchable database, and answers user questions fast.
The bot cleans answer formatting to show well on Telegram, even splitting long messages.
This saves time and makes answers more accurate without switching apps.


Who Should Use This Workflow

This workflow is good for people who get many PDF files with lots of information.
It helps anyone who wants to quickly find details in legal, business, or contract documents inside Telegram chat.
If you want to save hours reading and searching documents manually, this flow can help.


Tools and Services Used


Beginner Step-by-Step: How to Use This Workflow in n8n

1. Import Workflow File

  1. Download the workflow file from this page by clicking the Download button.
  2. Inside the n8n editor, click on “Import from File.”
  3. Select the downloaded workflow file.

2. Setup Credentials and IDs

  1. Go to Credentials in n8n.
  2. Add Telegram Bot API Key you got from BotFather.
  3. Add Google Gemini API Key (PaLM API).
  4. Add Supabase settings (url, key).
  5. If used, add OpenWeatherMap API Key.
  6. Update any table names, chat IDs, or folder names in nodes if needed.

3. Test the Workflow

  1. Run the workflow manually or send a PDF file to the Telegram bot.
  2. Check if the document processes without error.
  3. Send questions via Telegram chat and verify responses.

4. Activate Workflow for Production

  1. Switch the workflow toggle to active in n8n.
  2. Make sure your n8n instance runs continuously.
  3. Consider self-host n8n for reliable uptime.

Workflow Inputs, Processing, and Outputs

Inputs

  • User uploads PDF files via Telegram chat.
  • User sends text questions about the uploaded documents.

Processing Steps

  • The workflow downloads the PDF file from Telegram.
  • Extracts text from all pages.
  • Splits text into small parts that fit embedding limits.
  • Generates embedding vectors using Google Gemini.
  • Saves vectors and metadata into Supabase.
  • When user asks a question, searches Supabase by similarity.
  • Passes context and question to Gemini chat model for an answer.
  • Formats answer, cleaning HTML tags and splitting long texts.
  • Sends cleaned, chunked answer messages back to Telegram.

Outputs

  • Telegram messages confirming document processing.
  • Clear, structured AI answers to user questions.
  • Supabase stores up-to-date searchable document knowledge.

Edge Cases and Failures to Watch

  • If non-PDF files are uploaded, the text extraction fails and user gets an unsupported file message.
  • Wrong Telegram API or missing bot webhooks block receiving messages.
  • Supabase errors can occur if the vector table or pgvector extension are misconfigured.
  • AI responses with unsupported HTML tags cause Telegram message errors.
  • Missing fallback for failed message sends can lose answers.

Customization Ideas

  • Allow other file types, like DOCX or TXT by adding conversion nodes.
  • Change the chat prompt text to adjust response tone and style.
  • Add multi-user session handling to keep conversations separate.
  • Include extra APIs (stocks, news) to make answers more dynamic.
  • Set up scheduled cleanup to remove old documents or archive vectors.

Pre-Production Checklist

  • Verify Telegram, Google Gemini, and Supabase credentials work in n8n.
  • Upload test PDFs and ask sample questions to confirm flow.
  • Check AI answers for clarity and Telegram formatting.
  • Watch Supabase database updates after uploads.
  • Back up the Supabase database before big changes.

Deployment Guide

Turn the workflow active inside n8n.
Keep the n8n server always running to receive and send messages.
Consider self-host n8n for better control and uptime rather than running on shared platforms.


Summary

✓ Turns Telegram chat into AI document Q&A bot.
✓ Saves time by automating PDF reading and indexing.
✓ Uses Google Gemini and Supabase to make search and answers fast.
✓ Formats messages to fit Telegram limits without errors.
✓ Lets users upload, ask questions, and get complete answers live.
✓ Designed for easy setup inside n8n with clear steps.


Automate document searches with n8n and Telegram

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Download the workflow file from this page, import it inside the n8n editor using Import from File, add required API keys and credentials, then test and activate the workflow.
The workflow uses Telegram Bot API for messages, Google Gemini for AI embeddings and chat, Supabase for vector storage, and optionally OpenWeatherMap for live weather.
The workflow supports PDF files for document text extraction. Other file types are not supported by default and may cause errors.
The workflow cleans AI-generated HTML by removing unsupported tags and splits long messages into chunks to fit Telegram’s character limits.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.