Skip to content

[Bug]: message:sent internal hook not firing for Telegram group deliveries (missing sessionKey) #52390

Closed

Description

@ISE76R

Bug type

Behavior bug (incorrect output/state without crash)

Summary

Description

The message:sent internal hook event is never emitted when a bot delivers a message to a Telegram group (including forum topic chats). The message:received and message:preprocessed events fire correctly for the same conversations.

Steps to reproduce

  1. Register an internal hook listening for message:sent (via hooks/ directory + openclaw.json → hooks.internal.entries)
  2. Send a message to a Telegram group or forum topic (bot replies to a user message)
  3. Observe that message:sent never fires; message:received works fine

Root Cause

In deliver.ts → createMessageSentEmitter, the session key is resolved as:

sessionKeyForInternalHooks = params.mirror?.sessionKey ?? params.session?.key

When delivering to a Telegram group, both params.mirror?.sessionKey and params.session?.key are undefined. Without a valid session key, the emitter silently skips generating the message:sent event.

Expected behavior

[[[In deliver.ts → createMessageSentEmitter, the session key is resolved as:

sessionKeyForInternalHooks = params.mirror?.sessionKey ?? params.session?.key

When delivering to a Telegram group, both params.mirror?.sessionKey and params.session?.key are undefined. Without a valid session key, the emitter silently skips generating the message:sent event.](message:sent should fire for all outbound messages regardless of delivery target (DM, group, forum topic). If sessionKey is unavailable, the event should still be emitted with alternative identifiers (e.g., conversationId, chatId).)](message:sent should fire for all outbound messages regardless of delivery target (DM, group, forum topic). If sessionKey is unavailable, the event should still be emitted with alternative identifiers (e.g., conversationId, chatId).)](message:sent should fire for all outbound messages regardless of delivery target (DM, group, forum topic). If sessionKey is unavailable, the event should still be emitted with alternative identifiers (e.g., conversationId, chatId).)

Actual behavior

Workaround

Using send.sh scripts in cron jobs to manually duplicate messages to other platforms. No workaround exists for real-time bot replies in group chats.

OpenClaw version

• OpenClaw version: 2026.3.12

Operating system

ubuntu

Install method

No response

Model

claude opus

Provider / routing chain

Telegram (group/forum topics) → OpenClaw Gateway → deliver.ts → internal hooks

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

OpenClaw version: 2026.3.12
• Channel: Telegram (group + forum topics)
• Hook type: internal (hooks.internal.entries)

Additional information

Workaround

Using send.sh scripts in cron jobs to manually duplicate messages to other platforms. No workaround exists for real-time bot replies in group chats.

Activity

  1. added
    bug
    on Mar 22, 2026
  2. added
    bug:behavior
    on Mar 22, 2026
  3. Ryce commented on Mar 22, 2026

    @Ryce
  4. Hollychou924 commented on Mar 22, 2026

    @Hollychou924
  5. steipete commented on Apr 25, 2026

    @steipete
    Contributor

    Closing this as implemented after Codex review.

    Current main already routes Telegram group/forum deliveries with a real session key into the outbound message:sent internal hook path, and the same implementation is already present in release v2026.4.22.

    What I checked:

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review notes: reviewed against 8866544ffefb; fix evidence: release v2026.4.22, commit 00bd2cf7a376.

  6. locked as resolved and limited conversation to collaborators on Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbug:behavior

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions