← Back to PRs

#13789: [Feature] Support reading WhatsApp poll vote results

by netsfera1 open 2026-02-11 01:43 View on GitHub →
docs channel: whatsapp-web stale
Closes #12197 ## Summary Agents can now receive WhatsApp poll votes as messages. When a user votes on a poll sent by the agent, a `[Poll Vote]` message is delivered with the voter and their selections. ## Changes - `src/web/inbound/poll-store.ts` (new): In-memory store for tracking sent polls - `src/web/inbound/send-api.ts`: Add `onPollSent` callback - `src/web/inbound/monitor.ts`: Add `messages.update` handler for poll votes ## How it works 1. When agent sends a poll via `sendPoll()`, it's stored in PollStore 2. When user votes, Baileys emits `messages.update` with encrypted vote data 3. Handler decodes votes using `getAggregateVotesInPollMessage` + stored poll options 4. Vote is formatted as `[Poll Vote] +1234 voted 'Option A' in "Question?"` 5. Message goes through existing debouncer to agent ## Test Plan - [x] Manual: Sent poll → voted → received [Poll Vote] message - [x] Multi-select poll consolidates options - [x] `pnpm build` passes - [x] Lint passes on modified files ## AI Disclosure Built with Claude. Code reviewed and understood. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> adds WhatsApp poll vote tracking by storing sent polls and listening for vote update events - new `PollStore` tracks polls sent via `sendPoll()` with 7-day TTL and cleanup at 100 polls - `messages.update` handler decodes encrypted votes using Baileys' `getAggregateVotesInPollMessage` - vote notifications formatted as `[Poll Vote] +1234 voted 'Option A' in "Question?"` and routed through existing debouncer **Critical issue:** duplicate messages will be sent because `getAggregateVotesInPollMessage` returns cumulative votes (all voters), not just new votes. when a second user votes, the handler sends messages for both voters again. needs vote tracking similar to MS Teams implementation (`extensions/msteams/src/polls-store-memory.ts:19-28`) <h3>Confidence Score: 1/5</h3> - contains a critical logic bug that will cause duplicate poll vote messages in production - the duplicate vote message issue is a fundamental logic error in how `messages.update` events are processed - `getAggregateVotesInPollMessage` returns cumulative results but the handler treats them as new votes, causing exponential message duplication as more users vote - pay close attention to `src/web/inbound/monitor.ts` - the `handleMessagesUpdate` function needs vote deduplication logic <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs