Skip to content

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

@ISE76R

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions