-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
[Bug]: WhatsApp Group Mention Detection #11758
Description
Summary
WhatsApp group mention detection (requireMention) fails even when the bot is correctly mentioned using WhatsApp's native @ mention feature.
Environment
- OpenClaw Version: 2026.2.6-3 (85ed6c7)
- OS: Linux 6.8.0-94-generic (x64)
- Node: v22.22.0
- Channel: WhatsApp (whatsapp-web.js)
Configuration
{
"channels": {
"whatsapp": {
"groupPolicy": "open",
"groups": {
"<GROUP_ID>@[g.us](http://g.us/)": {
"requireMention": true
}
}
}
}
}Steps to Reproduce
- Configure a WhatsApp group with requireMention: true
- Send a message in the group using WhatsApp's native @ mention feature to tag the bot
- Check the debug logs
Expected Behavior
When the bot is mentioned, wasMentioned should be true and the bot should process the message.
Actual Behavior
Even when correctly mentioned, wasMentioned remains false and the message is ignored.
Debug Logs
{
"conversationId": "<GROUP_ID>@[g.us](http://g.us/)",
"wasMentioned": false, // ← BUG: Should be true
"from": "<GROUP_ID>@[g.us](http://g.us/)",
"body": "@<USER_LID> Test 2",
"bodyClean": "@<USER_LID> test 2",
"mentionedJids": ["<USER_LID>@lid"],
"normalizedMentionedJids": ["+49XXXXXXXXX"], // ← Correctly normalized
"selfJid": "<PHONE>:[[email protected]](mailto:[email protected])",
"selfJidBare": "<PHONE>:[[email protected]](mailto:[email protected])",
"selfE164": "+49XXXXXXXXX", // ← Matches normalized mention
"resolvedSelfE164": "+49XXXXXXXXX"
}Root Cause Analysis
The mention normalization works correctly:
- mentionedJids contains the raw WhatsApp mention format: <USER_LID>@lid
- normalizedMentionedJids correctly converts it to the E.164 phone format
- selfE164 matches the normalized mention
However, the wasMentioned flag is not set to true. This suggests the mention-matching logic is comparing the wrong fields:
Hypothesis: The code likely compares mentionedJids (format: <USER_LID>@lid) with selfJid (format: :[email protected]) instead of comparing normalizedMentionedJids with selfE164.
Suggested Fix
The mention detection should check if selfE164 or resolvedSelfE164 is present in normalizedMentionedJids array.
Pseudo-code:
const wasMentioned = normalizedMentionedJids.includes(selfE164) ||
normalizedMentionedJids.includes(resolvedSelfE164);Workaround
Set requireMention: false for groups where this feature is needed.
Impact
- requireMention feature is completely non-functional for WhatsApp groups
- Bots cannot be configured to only respond when explicitly mentioned in busy groups
- Increases noise and API usage in group chats
Additional Context
Tested with native WhatsApp @ mentions (using contact picker in WhatsApp mobile/web). The mention appears correctly in the message body and is parsed into mentionedJids, but the matching fails.
Log search hint: "group mention debug" in gateway logs