Skip to main content
Set one config knob and a Telegram media album — several photos or files sent together — becomes one multimodal agent turn instead of one turn per part. A user taps three receipt photos, hits Send once, and the agent sees all three attachments in a single turn — so it can compare them.

Quick Start

1

Enable album coalescing

Set media_group_window_ms on BotConfig.metadata to switch coalescing on. 0 (the default) keeps every album part as its own turn.
2

Tune the album size cap

Add media_group_max to bound how many attachments buffer per album before a forced flush. The default (10) covers a full Telegram album.

How It Works

Telegram delivers each album part as its own update sharing one media_group_id. The coalescer buffers the parts and flushes them once, after a short window of silence. Exactly one caller per group receives the MergedAlbum; sibling handle_message calls return None because their media was folded into the owner’s turn. A standalone (non-album) message has no media_group_id, so it returns its own parts immediately — no debounce added.

Configuration Options

Both knobs live on BotConfig.metadata (passthrough — there are no dedicated BotConfig fields).
The feature is disabled by default (media_group_window_ms=0). Existing deployments are unchanged until you set the knob.

Common Patterns

Compare several images in one turn:
Split very large albums into multiple turns by lowering the cap:

Best Practices

1200 ms covers Telegram’s typical inter-part gap. Raise it only if slow phones trickle parts across more than a second.
The default (10) fits a full Telegram album. Lower it only when you have a specific latency or memory target — doing so splits a single album across multiple turns.
Clean deployments stay byte-for-byte unchanged until you set media_group_window_ms. Enabling it never affects existing behaviour for other message types.
Single-photo messages have no media_group_id, so they return immediately with no added debounce — album coalescing only touches multi-part albums.

Messaging Bots

Inbound photos and documents handed to the agent’s vision capability.

Telegram Durable Approval

Another Telegram-specific gateway feature — durable Allow/Deny buttons.