n8n

How to Automate Telegram Document Support?

Turn a Telegram chat into a smart helper for your own documents. Users send a PDF, then ask questions, and get clear answers pulled from that file. Useful for teams that need quick facts from manuals, guides, or policy docs.

Messages arrive through a Telegram Trigger and pass a command router that separates normal chat, file uploads, and unsupported content. When a PDF arrives, the flow downloads it, extracts text, splits it into chunks, and creates embeddings with Google Gemini. Those vectors are stored in Supabase and searched later when a question comes in. A Gemini chat model writes the final reply, with safe formatting, message splitting for Telegram limits, and a fallback if formatting fails. Weather lookups with OpenWeatherMap are available on request.

Setup needs Telegram, Google Gemini, Supabase, and optional OpenWeatherMap accounts. Expect faster answers and less manual searching, especially for repeat questions and long documents. Strong fits include customer support handbooks, onboarding guides, or service SOPs where staff need quick, accurate answers in chat.

What are the key features?

  • Telegram Trigger captures messages and files directly from users
  • Command Router splits commands, document uploads, and normal chat to the right path
  • PDF text extraction and recursive splitting prepare clean, searchable chunks
  • Google Gemini embeddings create vector representations for each chunk
  • Supabase Vector Store saves and searches embeddings with the match_documents function
  • AI Agent with Gemini chat model composes final answers in plain language
  • Vector store question tool adds document context only when queries reference the file
  • OpenWeatherMap tool can add real time weather when asked
  • Formatting and chunking nodes deliver responses within Telegram limits with a safe fallback

What are the benefits?

  • Reduce manual lookups from 30 minutes to under 1 minute by asking questions in chat
  • Automate up to 70 percent of repeat document questions with vector search
  • Improve answer consistency by pulling text from the exact source file
  • Handle higher question volume without extra staffing by using chat-based self serve
  • Connect Telegram, Gemini, and Supabase in one flow with no code

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Telegram, Google Gemini, Supabase and OpenWeatherMap. See the Tools Required section above for links to create accounts with these services.
  3. In Telegram, use BotFather to create a bot and copy the bot token.
  4. In n8n, open the Telegram Trigger node and the Telegram nodes, choose Credential to connect with, click Create new credential, paste the bot token, and save. Activate the workflow so Telegram updates can reach n8n.
  5. Create a Google Gemini API key from the provider’s API page. In n8n, open the Google Gemini Chat Model and Embeddings nodes, create new credentials, and paste the API key.
  6. In Supabase, create a project. Enable the pgvector extension and create the user_knowledge_base table and match_documents function as described in your database. Copy the project URL and service role key.
  7. In n8n, open the Supabase Vector Store and Supabase Save Embeddings nodes, create new Supabase credentials with the URL and key, and set table name to user_knowledge_base and query name to match_documents.
  8. Optional: Get an OpenWeatherMap API key. In n8n, open the OpenWeatherMap node, create new credentials, and paste the key.
  9. Confirm model settings: Embeddings node uses text-embedding-004 and the chat model uses gemini-2.5-flash-preview-04-17. Save your changes.
  10. Run a test: Send /start to the bot, upload a small PDF, wait for the processing and embedding messages, then ask a question from the file. Verify rows are added in the Supabase table.
  11. Troubleshoot: If replies are cut off, check the formatting and splitting nodes. If no matches return, confirm the embedding dimension matches your table and the function name is correct. If Telegram messages do not arrive, make sure the workflow is active and the credentials are valid.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Gemini

Sign up

Free tier: $0 via Gemini API; e.g., Gemini 2.5 Flash-Lite free limits 1,000 requests/day (15 RPM, 250k TPM). Paid from $0.10/1M input tokens and $0.40/1M output tokens.

OpenWeatherMap

Sign up

Free access: $0 — 60 API calls/min and 1,000,000 calls / mo for Current Weather, 5 day/3 hour Forecast, Air Pollution, and Geocoding; One Call API 3.0 pay-as-you-call includes first 1,000 calls/day free

Supabase

Sign up

Free: $0 / mo — unlimited API requests; 500 MB database; 5 GB bandwidth; 1 GB storage; 50,000 MAUs.

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Credits:
YouTube video

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.