#15929: feat: add list-groups action to WhatsApp message tool
channel: discord
channel: imessage
channel: signal
channel: whatsapp-web
gateway
agents
stale
size: M
## Problem
Currently, the message tool for WhatsApp only shows groups where the agent has already received/sent messages (active sessions). There's no way to list all WhatsApp groups the account is part of (#15821).
## Solution
Add a new action list-groups to the message tool that returns all WhatsApp groups the account is part of.
## Changes
- **ActiveWebListener**: Add listGroups() method to interface
- **Monitor**: Implement listGroups using Baileys groupFetchAllParticipating()
- **Actions**: Add list-groups to CHANNEL_MESSAGE_ACTION_NAMES
- **Handler**: Handle list-groups action in whatsapp-actions
## Usage
```typescript
message({
action: "list-groups",
channel: "whatsapp"
})
```
## Response
```json
{
"groups": [
{
"id": "120363205057054713@g.us",
"name": "Group Name",
"memberCount": 5,
"isMember": true
}
]
}
```
Fixes #15821
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Adds `list-groups` action to WhatsApp message tool, enabling agents to list all WhatsApp groups an account is part of.
**Changes:**
- Added `listGroups()` method to `ActiveWebListener` interface (optional method)
- Implemented `listGroups` in WhatsApp monitor using Baileys `groupFetchAllParticipating()` API
- Added `list-groups` to `CHANNEL_MESSAGE_ACTION_NAMES` constant
- Added handler for `list-groups` action in `whatsapp-actions.ts`
**Implementation:**
Returns array of group objects with `id`, `name`, `memberCount`, and `isMember` fields. The implementation properly handles errors by returning an empty array and logging failures. The action correctly validates that an active WhatsApp listener exists before attempting to fetch groups.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minor logic improvement recommended
- The implementation is straightforward and follows existing patterns in the codebase. The changes are well-scoped to adding a new action, with proper error handling and validation. One minor logic issue was identified in the `isMember` fallback that should be addressed but doesn't block functionality.
- src/web/inbound/monitor.ts - Review the `isMember` fallback logic on line 413
<sub>Last reviewed commit: 6a83d77</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#7287: feat(whatsapp): expose group admin functions
by balthazar-bot · 2026-02-02
79.3%
#4390: fix(whatsapp): allow media from allowlisted groups without groupAllow…
by Sarang19114 · 2026-01-30
78.9%
#23288: feat(whatsapp): group command gating via commands.allowFrom + sende...
by rodrigoscoelho · 2026-02-22
78.0%
#23579: feat(whatsapp): add sender attribution to inbound message logs
by svan058 · 2026-02-22
76.9%
#17326: fix(whatsapp): group composing indicator, echo prevention, and pres...
by globalcaos · 2026-02-15
76.9%
#11611: feat: separate group-level allowlist from sender-level command auth...
by thisnick · 2026-02-08
76.5%
#4402: fix: store group messages from non-allowlisted senders as pending c...
by adam91holt · 2026-01-30
75.2%
#5665: fix: match group JIDs in groupAllowFrom allowlist
by koala73 · 2026-01-31
74.3%
#20003: feat(whatsapp): follow-up window for group conversations with requi...
by alexmelges · 2026-02-18
73.5%
#8224: feat(whatsapp): extract @mentions into dedicated module
by zurizuriaria · 2026-02-03
73.5%