Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database
๐ค๐จ Telegram AI Assistant with Multi-File Media Group Handling, Smart File Processing & PostgreSQL Integration
> AI-powered Telegram bot for text, voice, video, documents & media โ with database-driven grouping and Telegram-safe formatting.
๐ Description
This n8n template creates a next-generation Telegram AI assistant ๐ง ๐ฌ capable of handling text messages, media files, and documents with advanced processing, PostgreSQL integration, and AI-powered responses.
It is designed to solve Telegramโs media group challenge ๐ฆ โ when multiple files are sent together, they are stored, processed, and combined into one coherent AI-generated reply.
โจ Key Features ๐ Multi-file media group management with PostgreSQL: media_group media_queue chat_histories ๐ Document parsing for CSV, HTML, ICS, JSON, ODS, PDF (with AI fallback), RTF, TXT, XML, and spreadsheets. ๐ค Voice & video transcription for AI analysis. ๐ผ๏ธ Image, audio, and video description for richer AI context. ๐ก๏ธ Telegram-safe MarkdownV2 formatting with auto-splitting for messages over 4096 chars. โ ๏ธ Error fallback for unsupported file types.
๐ก Acknowledgment
A huge thank you to Ezema Gingsley Chibuzo ๐ for the inspiration of the first version of this workflow:
Create a Multi-Modal Telegram Support Bot with GPT-4 and Supabase RAG
Your pioneering work laid the foundation for this improved, database-powered multi-modal assistant ๐
๐ท Tags
telegram ai-assistant postgresql multi-file media-group
file-processing voice-transcription document-parser pdf-extraction
markdown-formatting n8n-template
๐ผ Use Case Use this template if you need an AI-powered Telegram bot that can: ๐ฆ Handle multiple files sent in a single message (albums, multiple PDFs, etc.). ๐งพ Extract & analyze content from many file formats. ๐๏ธ Transcribe voice and video messages. ๐๏ธ Maintain chat memory for contextual AI answers. ๐ก๏ธ Avoid Telegram formatting errors and length limit issues.
This workflow automates the full chain: Receive โ Process โ AI Analysis โ Telegram-safe Reply.
๐ฌ Example User Interactions
๐ Multiple PDFs with a caption** โ AI extracts and summarizes all PDFs in one combined reply.
๐ค Voice message** โ AI transcribes and replies with a contextual answer.
๐ CSV or spreadsheet file** โ AI parses and summarizes the data.
๐ผ๏ธ Multiple images** โ AI describes each image and replies in a single message.
๐ Required Credentials
Telegram Bot API** (Bot Token)
PostgreSQL** (Connection credentials)
AI Provider API** (OpenAI, Google Gemini, or compatible LLM)
โ๏ธ Setup Instructions ๐๏ธ Create the PostgreSQL tables (Gray section SQL): media_group media_queue chat_histories ๐ Configure the Telegram Trigger with your bot token. ๐ค Connect your AI provider credentials. ๐๏ธ Set up PostgreSQL credentials in the database nodes. โถ๏ธ Deploy the workflow in n8n. ๐ฏ Start sending messages and files to your bot.
๐ Extra Notes
โ
Green section ensures only one trigger per media group.
๐ Yellow section guarantees captions and files are stored in the correct sequence.
โจ Purple section formats AI output to be Telegram-safe and split if needed.
๐ง AI prompt is not fixed, allowing full customization.
๐ก Need Assistance?
If youโd like help customizing or extending this workflow, feel free to reach out:
๐ง Email: johnsilva11031@gmail.com
๐ LinkedIn: John Alejandro Silva Rodrรญguez
Related Templates
Demo Workflow - How to use workflowStaticData()
This workflow demonstrates how to use the workflowStaticData() function to set any type of variable that will persist wi...
Bulk Automated Google Drive Files Sharing and Direct Download Link Generation
This N8N workflow automates the process of sharing files from Google Drive. It includes OAuth2 authentication, batch pro...
USDT And TRC20 Wallet Tracker API Workflow for n8n
Overview This n8n workflow is specifically designed to monitor USDT TRC20 transactions within a specified wallet. It u...
๐ Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments