Repository navigation
Description
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
- Register an internal hook listening for message:sent (via hooks/ directory + openclaw.json → hooks.internal.entries)
- Send a message to a Telegram group or forum topic (bot replies to a user message)
- 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
Labels
Type
Fields
Priority
Activity
Ryce commentedon Mar 22, 2026
Hollychou924 commentedon Mar 22, 2026
fix(hooks): resolve session key fallback for message:sent in group de…
steipete commentedon Apr 25, 2026
Closing this as implemented after Codex review.
Current
mainalready routes Telegram group/forum deliveries with a real session key into the outboundmessage:sentinternal hook path, and the same implementation is already present in releasev2026.4.22.What I checked:
SessionKey: route.sessionKey, so group and forum messages reach dispatch with a concrete session key instead ofundefined. (extensions/telegram/src/bot-message-context.session.ts:330, 8866544ffefb)sessionKeyfrom the resolved route, and tests assert a regular group getsagent:main:telegram:group:-1001234567890while a forum topic getsagent:main:telegram:group:-1001234567890:topic:99. (extensions/telegram/src/bot-message-context.ts:376, 8866544ffefb)sessionKeyForInternalHooks: ctxPayload.SessionKeyindeliveryBaseOptions, so outbound group replies use the same resolved session key. (extensions/telegram/src/bot-message-dispatch.ts:559, 8866544ffefb)emitInternalMessageSentHooktriggerscreateInternalHookEvent("message", "sent", params.sessionKeyForInternalHooks, ...), anddeliverRepliescalls it after a successful send with group metadata. (extensions/telegram/src/bot/delivery.replies.ts:540, 8866544ffefb)message:sentemission when Telegram session hook context is available, includingisGroup/groupId, and separately verify group and forum-topic session keys exist. (extensions/telegram/src/bot/delivery.test.ts:249, 8866544ffefb)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.