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
- Telegram Bot API: Receives user messages.
- Google Gemini (PaLM) API: Makes text embeddings and chat answers.
- Supabase Database: Stores document vectors and does similarity search.
- n8n Automation: Orchestrates workflows.
- OpenWeatherMap API (Optional): Adds live weather data.
Beginner Step-by-Step: How to Use This Workflow in n8n
1. Import Workflow File
- Download the workflow file from this page by clicking the Download button.
- Inside the n8n editor, click on “Import from File.”
- Select the downloaded workflow file.
2. Setup Credentials and IDs
- Go to Credentials in n8n.
- Add Telegram Bot API Key you got from BotFather.
- Add Google Gemini API Key (PaLM API).
- Add Supabase settings (url, key).
- If used, add OpenWeatherMap API Key.
- Update any table names, chat IDs, or folder names in nodes if needed.
3. Test the Workflow
- Run the workflow manually or send a PDF file to the Telegram bot.
- Check if the document processes without error.
- Send questions via Telegram chat and verify responses.
4. Activate Workflow for Production
- Switch the workflow toggle to active in n8n.
- Make sure your n8n instance runs continuously.
- 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.

