#23251: fix(whatsapp): include LID in implicit mention detection for group replies
channel: whatsapp-web
size: XS
Cluster:
WhatsApp and Google Chat Fixes
## Summary
- **Problem:** In WhatsApp groups with \`requireMention: true\`, swipe-replying to the bot's message does not trigger a response. The reply is silently dropped.
- **Why:** WhatsApp migrated to Linked Identity Device (LID) format (\`XXXX@lid\`) for user identities. When a user replies to the bot, the quoted message sender comes back in LID format. The \`applyGroupGating\` function only compared \`selfJid\` (\`@s.whatsapp.net\`) and \`selfE164\` against the reply sender — never the LID format. The comparison always failed.
- **What changed:** (1) Extract \`sock.user.lid\` from the Baileys socket in \`monitor.ts\`. (2) Add \`selfLid\` field to \`WebInboundMessage\` type. (3) Compare \`selfLid\` against \`replySenderJid\` in the \`implicitMention\` check in \`group-gating.ts\`.
- **What did NOT change:** Explicit @mention detection, E164 comparison, direct message handling.
## Change Type (select all)
- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
## Scope (select all touched areas)
- [ ] Gateway / orchestration
- [ ] Skills / tool execution
- [ ] Auth / tokens
- [ ] Memory / storage
- [x] Integrations
- [ ] API / contracts
- [ ] UI / DX
- [ ] CI/CD / infra
## Linked Issue/PR
- Closes #23029
- Related: #11758 (same root cause, explicit @mention variant)
## User-visible / Behavior Changes
- Swipe-replying to the bot in WhatsApp groups now correctly triggers a response when the bot's identity uses LID format
## Security Impact (required)
- New permissions/capabilities? \`No\`
- Secrets/tokens handling changed? \`No\`
- New/changed network calls? \`No\`
- Command/tool execution surface changed? \`No\`
- Data access scope changed? \`No\`
## Repro + Verification
### Steps
1. Configure a WhatsApp group with \`requireMention: true\`
2. Have the bot send a message
3. Swipe-reply to the bot's message without typing the bot's name
### Expected
- Bot responds to the reply (implicit mention detected)
### Actual (before fix)
- Reply silently dropped
## Evidence
The bot's \`creds.json\` contains both identity formats:
\`\`\`json
"me": {
"id": "1XXXXXXXXXX:1@s.whatsapp.net",
"lid": "XXXXXXXXXXXX:1@lid"
}
\`\`\`
The reply context returns the sender in LID format:
\`\`\`json
{ "participant": "XXXXXXXXXXXX@lid" }
\`\`\`
Before fix, only \`selfJid\` (\`@s.whatsapp.net\`) was compared. After fix, \`selfLid\` (\`@lid\`) is also compared.
## Human Verification (required)
- Verified scenarios: LID vs JID comparison logic, regex for stripping device suffix (\`:\d+\`)
- Edge cases checked: \`selfLid\` is null/undefined (gracefully skipped in Boolean check)
- What I did **not** verify: Live WhatsApp group test (no WhatsApp Business account)
## Compatibility / Migration
- Backward compatible? \`Yes\`
- Config/env changes? \`No\`
- Migration needed? \`No\`
## Failure Recovery (if this breaks)
If \`sock.user.lid\` is unavailable, \`selfLid\` is null and the new comparison branch is skipped — identical to pre-fix behavior.
## Risks and Mitigations
Low risk. The LID comparison is additive (new \`||\` branch). If LID format changes in the future, the existing JID/E164 comparisons still work as fallback.
Most Similar PRs
#23046: fix(whatsapp): detect LID JID in implicit reply-to-bot mention check
by hydro13 · 2026-02-21
87.9%
#23059: fix(whatsapp): resolve LID JIDs for reply-to-bot implicit mention d...
by azisseno · 2026-02-21
87.9%
#16655: fix(whatsapp): resolve reply-to sender E.164 for LID JIDs (have bot...
by mascarenhas · 2026-02-15
83.7%
#22106: fix(whatsapp): honor selfChatMode override for group mentions
by sportclaw · 2026-02-20
80.2%
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
80.1%
#2772: fix: search WhatsApp account subdirs for LID mapping files
by impozzible · 2026-01-27
78.8%
#16608: feat(whatsapp): resolve outbound @mentions to clickable WhatsApp me...
by lucasmpramos · 2026-02-14
76.9%
#12069: fix(whatsapp): handle native group @mentions with requireMention
by abhishek0450 · 2026-02-08
76.4%
#4402: fix: store group messages from non-allowlisted senders as pending c...
by adam91holt · 2026-01-30
74.5%
#15786: fix: strip device suffix from selfJid in WhatsApp mention matching
by kenken64 · 2026-02-13
72.5%