openclaw - 💡(How to fix) Fix [Feature]: Expose messageId in message_sent plugin hook (toPluginMessageSentEvent) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#55468Fetched 2026-04-08 01:39:11
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

The message_sent plugin hook does not expose the native messageId returned by the channel (WhatsApp/Telegram) after sending a message. The value exists internally in the canonical object but is filtered out by toPluginMessageSentEvent() before reaching plugins.

Root Cause

The message_sent plugin hook does not expose the native messageId returned by the channel (WhatsApp/Telegram) after sending a message. The value exists internally in the canonical object but is filtered out by toPluginMessageSentEvent() before reaching plugins.

Fix Action

Workaround

We currently patch the compiled code manually:

# In toPluginMessageSentEvent, add messageId to the returned object
sed -i 's/success: canonical.success,/success: canonical.success, messageId: canonical.messageId,/' dist/hook-runtime-*.js

This works but must be reapplied on every OpenClaw update.

Code Example

// toPluginMessageSentEvent returns:
{
  to: canonical.to,
  content: canonical.content,
  success: canonical.success,
  // messageId is NOT included
}

---

{
  to: canonical.to,
  content: canonical.content,
  success: canonical.success,
  messageId: canonical.messageId,  // ← native channel message ID
}

---

# In toPluginMessageSentEvent, add messageId to the returned object
sed -i 's/success: canonical.success,/success: canonical.success, messageId: canonical.messageId,/' dist/hook-runtime-*.js
RAW_BUFFERClick to expand / collapse

Summary

The message_sent plugin hook does not expose the native messageId returned by the channel (WhatsApp/Telegram) after sending a message. The value exists internally in the canonical object but is filtered out by toPluginMessageSentEvent() before reaching plugins.

Current behavior

// toPluginMessageSentEvent returns:
{
  to: canonical.to,
  content: canonical.content,
  success: canonical.success,
  // messageId is NOT included
}

Expected behavior

{
  to: canonical.to,
  content: canonical.content,
  success: canonical.success,
  messageId: canonical.messageId,  // ← native channel message ID
}

Use case

Plugins that archive messages (e.g., a message-archive plugin that saves all inbound/outbound to PostgreSQL) need the native message ID to:

  • Track messages by their WhatsApp/Telegram ID
  • Correlate outbound messages with inbound replies
  • Avoid generating synthetic IDs

Workaround

We currently patch the compiled code manually:

# In toPluginMessageSentEvent, add messageId to the returned object
sed -i 's/success: canonical.success,/success: canonical.success, messageId: canonical.messageId,/' dist/hook-runtime-*.js

This works but must be reapplied on every OpenClaw update.

Environment

  • OpenClaw 2026.3.23-2
  • Affected files: multiple chunks containing toPluginMessageSentEvent (auth-profiles-.js, discord-.js, model-selection-.js, reply-.js, hook-runtime-*.js)

extent analysis

Fix Plan

To fix the issue, we need to modify the toPluginMessageSentEvent function to include the messageId in the returned object. Here are the steps:

  • Locate the toPluginMessageSentEvent function in the affected files (e.g., hook-runtime-*.js).
  • Update the function to include the messageId property:
function toPluginMessageSentEvent(canonical) {
  return {
    to: canonical.to,
    content: canonical.content,
    success: canonical.success,
    messageId: canonical.messageId, // Add this line
  };
}
  • Alternatively, you can use object destructuring and the spread operator to make the code more concise:
function toPluginMessageSentEvent({ to, content, success, messageId }) {
  return { to, content, success, messageId };
}
  • Apply the changes to all affected files.

Verification

To verify that the fix worked, you can:

  • Check the output of the toPluginMessageSentEvent function to ensure it includes the messageId property.
  • Test the message-archive plugin to confirm it can now access the native message ID.

Extra Tips

  • To avoid manual patching on every OpenClaw update, consider submitting a pull request to the OpenClaw repository with the proposed fix.
  • If you're using a version control system, make sure to commit the changes and update the affected files accordingly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

{
  to: canonical.to,
  content: canonical.content,
  success: canonical.success,
  messageId: canonical.messageId,  // ← native channel message ID
}

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]: Expose messageId in message_sent plugin hook (toPluginMessageSentEvent) [1 participants]