#16050·chatwoot

Telegram album creates a separate conversation per photo

Author: Timur2915Created Sep 28, 2026Updated Sep 29, 2026
Labels📨 channel/telegramBug

Describe the bug

A Telegram user who has no open conversation sends an album (media group) of several photos. Chatwoot creates a separate conversation for each photo. All of them are created in the same second, and automation assigns each one separately.

Real example from our instance: the user's only conversation was resolved. The user then sent 4 photos as an album, with the caption on one of them. Telegram message ids were consecutive (…879–…882), and Chatwoot created 4 conversations with the same created_at, each holding one message.

Telegram delivers each item of a media group as a separate update. For every update, Webhooks::TelegramController enqueues its own job (telegram_controller.rb#L3). The jobs run concurrently, and each calls Telegram::IncomingMessageService#set_conversation (incoming_message_service.rb#L79-L90):

ruby
@conversation = if @inbox.lock_to_single_conversation
                  @contact_inbox.conversations.last
                else
                  @contact_inbox.conversations
                                .where.not(status: :resolved).last
                end
return if @conversation

@conversation = ::Conversation.create!(conversation_params)

This is a check-then-create with no lock. Every job sees "no open conversation" and creates one.

Webhooks::WhatsappEventsJob and Webhooks::InstagramEventsJob already guard against this: they inherit from MutexApplicationJob and wrap processing in with_lock keyed by inbox and sender. Webhooks::TelegramEventsJob is a plain ApplicationJob (telegram_events_job.rb#L1).

To Reproduce

  1. Create a Telegram inbox with "Lock to single conversation" disabled.
  2. From a Telegram account with no open conversation in that inbox (new, or all resolved), send the bot an album of 3–4 photos.
  3. Several conversations are created, one per photo.

The same can happen when a user sends several messages in quick succession.

Expected behavior

All messages of the album (and any messages arriving concurrently from the same user) end up in one conversation. For example, make Webhooks::TelegramEventsJob a MutexApplicationJob and lock on inbox id + Telegram user/chat id, the same way the WhatsApp and Instagram jobs do.

Environment

Kubernetes (self-hosted), Chatwoot v4.18.0. The code is unchanged on develop.

Additional context

Enabling "Lock to single conversation" on the inbox avoids this for contacts that already have a conversation. It doesn't help when a brand-new contact's first message is an album, and it changes conversation lifecycle, so it's not a real fix.