← Back to PRs

#15929: feat: add list-groups action to WhatsApp message tool

by Shuai-DaiDai open 2026-02-14 02:27 View on GitHub →
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