#13829: fix(googlechat): detect bot @mentions via user.type when botUser not configured
channel: googlechat
size: S
trusted-contributor
experienced-contributor
Cluster:
WhatsApp and Google Chat Fixes
## Summary
Fixes #12323
Google Chat webhooks send numeric user IDs (e.g. `users/112986094383820258709`) instead of the `users/app` alias for bot @mentions. Without `botUser` explicitly configured, `extractMentionInfo()` failed to recognize these mentions, causing the bot to silently ignore messages where it was @mentioned.
**Root cause:** `extractMentionInfo()` only checked `botTargets` (containing `users/app` and optional `botUser`) and the `normalizeUserId() === "app"` path. Numeric user IDs don't match either check.
**Fix:** When `botUser` is not configured and existing checks fail, fall back to checking `user.type === "BOT"` from the annotation metadata. For multi-bot Space safety, this fallback only triggers when exactly one distinct BOT-type user exists in the annotations — if multiple different bots are mentioned, the ambiguity requires explicit `botUser` configuration.
## Changes
- `extensions/googlechat/src/monitor.ts`: Added BOT user type fallback in `extractMentionInfo()` with distinct-user multi-bot safety guard
- `extensions/googlechat/src/monitor.test.ts`: Added 10 new tests covering all mention detection paths
## Test plan
- [x] `users/app` alias detection still works
- [x] Explicit `botUser` config detection still works
- [x] BOT user type fallback detects mentions when `botUser` not configured
- [x] Multi-bot safety: rejects when multiple distinct BOT users exist
- [x] Explicit `botUser` overrides multi-bot guard
- [x] HUMAN-type mentions don't trigger bot
- [x] Empty and non-USER_MENTION annotations handled correctly
- [x] Same bot mentioned twice (duplicate annotations) still detected
- [x] BOT mention alongside human mentions still detected
- [x] All 14 tests fail before fix, pass after fix
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes Google Chat bot @mention detection when webhooks send numeric user IDs (e.g. `users/112...`) instead of the `users/app` alias and `botUser` is not configured.
It does this by exporting and enhancing `extractMentionInfo()` in `extensions/googlechat/src/monitor.ts` to fall back to `annotation.userMention.user.type === "BOT"` when the existing `users/app` / `botUser` matching fails. To avoid incorrect triggering in multi-bot spaces, the fallback only applies when there is exactly one distinct BOT user in the message annotations. The accompanying tests in `extensions/googlechat/src/monitor.test.ts` cover alias matching, explicit `botUser`, BOT-type fallback, multi-bot guard behavior, and ignoring non-mention annotations.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are localized to mention detection logic and are guarded to avoid multi-bot ambiguity; added unit tests cover the new fallback and existing mention paths. No breaking internal usage was found beyond exporting a helper that is only used within the module and tests.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17256: fix: allow text regex fallback when bot JID not in mentionedJids
by DarlingtonDeveloper · 2026-02-15
77.8%
#7719: fix(slack): thread replies with @mentions dropped in requireMention...
by SocialNerd42069 · 2026-02-03
77.8%
#3837: fix(googlechat): space events response and thread reply context
by rehanchrl · 2026-01-29
77.7%
#11166: fix(whatsapp): detect LID @mentions in self-chat mode
by mcaxtr · 2026-02-07
77.4%
#3727: fix(googlechat): space type detection for modern API
by gustavozirbes · 2026-01-29
77.2%
#11774: fix: add guards for undefined mentionRegexes arrays
by ikvyk · 2026-02-08
76.8%
#20047: fix(googlechat): typing indicator shows 'OpenClaw' instead of agent...
by xinhuagu · 2026-02-18
76.6%
#22611: fix(discord): allow messages from other instance bots in multi-acco...
by dae-sun · 2026-02-21
76.5%
#13430: fix(discord): properly handle bot-sent @everyone mentions
by wassimbensalem · 2026-02-10
76.1%
#17081: fix(telegram): suppress file-size error replies in groups when bot ...
by p697 · 2026-02-15
75.9%