[Bug]: WhatsApp reply-to-bot detection fails — device suffix mismatch breaks _message_is_reply_to_bot
Summary
The _message_is_reply_to_bot() method in gateway/platforms/whatsapp.py consistently returns False for WhatsApp group messages, even when the user explicitly replies (quotes) a bot message. This makes the reply-to-bot admission shortcut unusable on WhatsApp.
Impact: Users in groups with require_mention: true cannot trigger the bot by replying to its messages — they must always @mention the bot, which is impossible for voice/audio messages since WhatsApp voice notes cannot include text mentions.
Root Cause
The bridge sends botIds with the device suffix included (:N → normalized to @N):
// bridge.js line ~244-247
const botIds = Array.from(new Set([
normalizeWhatsAppId(sock.user?.id), // "5511999999999@10@s.whatsapp.net"
normalizeWhatsAppId(sock.user?.lid), // "99999999999999@10@lid"
].filter(Boolean)));
However, the quotedParticipant from Baileys contextInfo (extracted at bridge.js line ~321) arrives without the device suffix:
quotedParticipant: "5511999999999@s.whatsapp.net" // no @10
botIds: {"5511999999999@10@s.whatsapp.net", "99999999999999@10@lid"}
Since _message_is_reply_to_bot() does a strict set membership check:
def _message_is_reply_to_bot(self, data: Dict[str, Any]) -> bool:
quoted_participant = self._normalize_whatsapp_id(data.get("quotedParticipant"))
if not quoted_participant:
return False
return quoted_participant in self._bot_ids_from_message(data)
The match always fails: "5511999999999@s.whatsapp.net" in {"5511999999999@10@s.whatsapp.net", "99999999999999@10@lid"} → False.
Environment
- Platform: WhatsApp (Baileys bridge, multi-device)
- Hermes version: Observed May 2026
- Affected: All WhatsApp groups with
require_mention: true
Reproduction
- Configure
whatsapp.require_mention: true in config.yaml
- Join a WhatsApp group with the bot
- Have the bot send any message in the group
- Reply (quote) the bots message with a text reply
- Expected: Bot processes the reply without needing @mention
- Actual: Bot silently ignores the message —
_message_is_reply_to_bot returns False
Fix
In gateway/platforms/whatsapp.py, modify _bot_ids_from_message() to also generate ID variants without the device suffix:
def _bot_ids_from_message(self, data: Dict[str, Any]) -> set[str]:
bot_ids = set()
for candidate in data.get("botIds") or []:
normalized = self._normalize_whatsapp_id(candidate)
if normalized:
bot_ids.add(normalized)
# Also add without the device suffix (e.g., "5511999999999@10@s.whatsapp.net" -> "5511999999999@s.whatsapp.net")
parts = normalized.split("@")
if len(parts) > 2:
bot_ids.add(f"{parts[0]}@{parts[-1]}")
return bot_ids
This is safe for both multi-device and non-multi-device:
- Multi-device:
5511999999999@10@s.whatsapp.net → adds alias 5511999999999@s.whatsapp.net
- Legacy:
5511999999999@s.whatsapp.net → len(parts) is 2 → no alias added, original behavior preserved
Workaround
- Disable
require_mention globally (not recommended for noisy groups)
- Use
free_response_chats with the specific group JID (allows all messages, not just replies)
- Users must @mention the bot (impossible for voice messages)
Type of Change
Files Changed
gateway/platforms/whatsapp.py — _bot_ids_from_message() — 3 lines added
[Bug]: WhatsApp reply-to-bot detection fails — device suffix mismatch breaks _message_is_reply_to_bot
Summary
The
_message_is_reply_to_bot()method ingateway/platforms/whatsapp.pyconsistently returnsFalsefor WhatsApp group messages, even when the user explicitly replies (quotes) a bot message. This makes the reply-to-bot admission shortcut unusable on WhatsApp.Impact: Users in groups with
require_mention: truecannot trigger the bot by replying to its messages — they must always @mention the bot, which is impossible for voice/audio messages since WhatsApp voice notes cannot include text mentions.Root Cause
The bridge sends
botIdswith the device suffix included (:N→ normalized to@N):However, the
quotedParticipantfrom BaileyscontextInfo(extracted at bridge.js line ~321) arrives without the device suffix:Since
_message_is_reply_to_bot()does a strict set membership check:The match always fails:
"5511999999999@s.whatsapp.net" in {"5511999999999@10@s.whatsapp.net", "99999999999999@10@lid"}→False.Environment
require_mention: trueReproduction
whatsapp.require_mention: truein config.yaml_message_is_reply_to_botreturnsFalseFix
In
gateway/platforms/whatsapp.py, modify_bot_ids_from_message()to also generate ID variants without the device suffix:This is safe for both multi-device and non-multi-device:
5511999999999@10@s.whatsapp.net→ adds alias5511999999999@s.whatsapp.net5511999999999@s.whatsapp.net→len(parts)is 2 → no alias added, original behavior preservedWorkaround
require_mentionglobally (not recommended for noisy groups)free_response_chatswith the specific group JID (allows all messages, not just replies)Type of Change
Files Changed
gateway/platforms/whatsapp.py—_bot_ids_from_message()— 3 lines added