Skip to content
Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database logo

Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database

Verified

Processes Telegram media groups with Gemini AI and PostgreSQL storage.

n8nAI & LLMIntermediate👁 794 views
Open template
Updated 2026-06-15

What this workflow does

This n8n workflow ingests multi-file Telegram messages, stores them in Postgres for grouping, and uses Google Gemini to produce a single coherent response.

It is intended for developers and teams building Telegram bots that require reliable media handling, database-backed context, and AI-generated replies.

Who is this for?

Telegram bot developers, AI product teams, and support/content teams that manage media-heavy conversations and need structured storage of chat history.

What problem it solves

Telegram sends media groups as separate updates, making it hard to process multiple files together and maintain context; without database memory, AI responses lose continuity across sessions.

What it automates

Customer support media intake

Users send photos of receipts or documents in one message; the workflow groups them, runs Gemini analysis, stores results in Postgres, and replies with a single formatted answer.

Content moderation queue

Moderators forward batches of images or videos; the bot processes the entire group with Gemini, logs decisions in PostgreSQL, and returns a summary without hitting Telegram message limits.

Research assistant archive

Researchers drop multiple PDFs and voice notes; files are combined into one Gemini prompt, chat memory is saved per user in Postgres, and a clean HTML-formatted report is returned.

How the workflow works

The 8 nodes in this automation, in order.

  1. 1Postgrespostgres
  2. 2Telegramtelegram
  3. 3Codecode
  4. 4HTMLhtml
  5. 5AI Agent@n8n/n8n-nodes-langchain.agent
  6. 6Google Gemini Chat Model@n8n/n8n-nodes-langchain.lmChatGoogleGemini
  7. 7Postgres Chat Memory@n8n/n8n-nodes-langchain.memoryPostgresChat
  8. 8Google Gemini@n8n/n8n-nodes-langchain.googleGemini

Apps & integrations used

PostgresTelegramHTMLAI AgentGoogle Gemini Chat ModelPostgres Chat MemoryGoogle Gemini

How to set up Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database

  1. 1Import the JSON workflow into n8n
  2. 2Add Telegram Bot API credentials and connect the Telegram trigger node
  3. 3Create a Postgres database and add credentials to the Postgres and Postgres Chat Memory nodes
  4. 4Add Google Gemini API key to the Google Gemini Chat Model and AI Agent nodes
  5. 5Activate the workflow and send a test media group to your Telegram bot
  6. 6Verify that grouped files appear as one record in the Postgres table

How to customize this workflow

  • Replace Google Gemini with another supported chat model node
  • Add an HTML node to change response formatting or add buttons
  • Extend Postgres schema to store additional metadata fields
  • Insert a filter node to skip certain file types before the AI Agent

Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database: pros & cons

Pros

  • +Solves Telegram media-group splitting automatically
  • +Uses Postgres for persistent per-user chat memory
  • +Returns Telegram-safe formatted replies via HTML node
  • +Combines multiple files into a single coherent Gemini response

Cons

  • Requires separate API keys for Telegram and Gemini
  • Postgres setup needed for memory feature to work
  • Intermediate complexity due to multiple AI and DB nodes
Did you find this helpful?

Frequently asked questions

It receives text, voice, video, documents and media groups via Telegram, groups files together, processes them with Gemini AI, stores conversation history in Postgres, and returns a single formatted reply.

User reviews

Verified reviews from the community shape this listing's rating.

Loading reviews…

Sign in to review

Promote Process Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database

Add this badge to your website, or share the tool.

DFeatured on DhanasviProcess Multiple Media Files in Telegram with Gemini AI & PostgreSQL Database 0