Skip to content

feat: Add WhatsApp poll support#248

Merged
steipete merged 1 commit intoopenclaw:mainfrom
dbhurley:feat/whatsapp-polls
Jan 6, 2026
Merged

feat: Add WhatsApp poll support#248
steipete merged 1 commit intoopenclaw:mainfrom
dbhurley:feat/whatsapp-polls

Conversation

@dbhurley
Copy link
Copy Markdown
Contributor

@dbhurley dbhurley commented Jan 5, 2026

Summary

Implements #123 - Adds the ability to create WhatsApp polls programmatically via CLI and gateway RPC.

Changes

Gateway Protocol (src/gateway/protocol/)

  • Add PollParamsSchema with validation for:
    • to: Recipient JID (required)
    • question: Poll question (required)
    • options: Array of 2-12 options (required)
    • selectableCount: How many options user can select (default: 1)
    • idempotencyKey: For deduplication (required)

ActiveWebListener (src/web/)

  • Add sendPoll(to, poll) method to the interface
  • Implement in inbound.ts using Baileys:
sock.sendMessage(jid, {
  poll: {
    name: poll.question,
    values: poll.options,
    selectableCount: poll.selectableCount ?? 1,
  },
});

Gateway RPC (src/gateway/server-methods/send.ts)

  • Add poll method handler with validation and idempotency

CLI Command (src/commands/poll.ts, src/cli/program.ts)

clawdbot poll --to "+15555550123" -q "Lunch today?" -o "Yes" -o "No" -o "Maybe"
clawdbot poll --to "123456789@g.us" -q "Meeting time?" -o "10am" -o "2pm" -s 2 --json

Testing

  • Validated schema exports and types compile
  • CLI command registered with help text and examples
  • Follows existing patterns from send command

Checklist

  • Gateway RPC method added
  • ActiveWebListener interface extended
  • Baileys poll implementation
  • CLI command with options
  • Validation for 2-12 options
  • Idempotency support
  • --dry-run and --json flags

Closes #123

Implements issue #123 - WhatsApp Poll Support

## Gateway Protocol
- Add `poll` RPC method with params: to, question, options (2-12), selectableCount

## ActiveWebListener
- Add `sendPoll(to, poll)` method to interface
- Implementation uses Baileys poll message type

## CLI Command
- `clawdbot poll --to <jid> -q <question> -o <opt1> -o <opt2> [-s count]`
- Supports --dry-run, --json, --verbose flags
- Validates 2-12 options

## Changes
- src/gateway/protocol/schema.ts: Add PollParamsSchema
- src/gateway/protocol/index.ts: Export validator and types
- src/web/active-listener.ts: Add sendPoll to interface
- src/web/inbound.ts: Implement sendPoll using Baileys
- src/web/outbound.ts: Add sendPollWhatsApp function
- src/gateway/server-methods/send.ts: Add poll handler
- src/commands/poll.ts: New CLI command
- src/cli/program.ts: Register poll command

Closes #123
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 6, 2026

This is very cool, thank you!

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 6, 2026

Follow-up (clean summary; my last comment lost inline code formatting).

Thanks again @dbhurley — I built on this PR and implemented the unified approach (shared poll model + per-provider adapters).

Changes landed locally (commit ea38e257):

  • Shared poll normalization/validation: src/polls.ts
  • CLI: clawdbot poll wired in src/cli/program.ts + implementation in src/commands/poll.ts
  • Gateway RPC: new poll method in src/gateway/server-methods/send.ts (provider whatsapp|discord, idempotency)
  • Protocol schema/validators: src/gateway/protocol/schema.ts, src/gateway/protocol/index.ts
  • WhatsApp implementation: ActiveWebListener.sendPoll + Baileys payload in src/web/inbound.ts, adapter in src/web/outbound.ts
  • Discord implementation: sendPollDiscord now consumes shared poll model in src/discord/send.ts (duration clamped; multiselect mapping)
  • Docs + credits: docs/poll.md and CHANGELOG.md (refs Feature Request: WhatsApp Poll Support #123; thanks)

Verification: pnpm lint + pnpm test.

@steipete steipete merged commit 2737e17 into openclaw:main Jan 6, 2026
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Jan 6, 2026

Follow-up: PR #248 is merged, and the poll feature is now unified across providers.

Post-merge follow-ups on main:

  • Unified poll model + adapters (WhatsApp + Discord): commits 0b27964, 35a2140
  • Docs: docs/poll.md
  • Credits: CHANGELOG + README clawtributors thumbnail list updated to include @dbhurley

Thanks again for the original poll plumbing, @dbhurley.

dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 9, 2026
* gateway: unify exec and tool approval pending state into single ToolApprovalManager

Route legacy exec.approval.request|resolve through canonical ToolApprovalManager
so there is one pending-approval state machine. Add resolveCompat() for legacy
callers that only provide { id, decision } without requestHash. Both legacy and
canonical events emit correctly for exec-origin requests. Anti-stale requestHash
validation remains effective for canonical tool.approval.resolve callers.

* chore: fix import ordering (formatter)

* fix: restrict exec.approval.resolve to exec-only approvals (cross-tool bypass guard)

---------

Co-authored-by: Claude <noreply@anthropic.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Implements issue openclaw#123 - WhatsApp Poll Support

## Gateway Protocol
- Add `poll` RPC method with params: to, question, options (2-12), selectableCount

## ActiveWebListener
- Add `sendPoll(to, poll)` method to interface
- Implementation uses Baileys poll message type

## CLI Command
- `clawdbot poll --to <jid> -q <question> -o <opt1> -o <opt2> [-s count]`
- Supports --dry-run, --json, --verbose flags
- Validates 2-12 options

## Changes
- src/gateway/protocol/schema.ts: Add PollParamsSchema
- src/gateway/protocol/index.ts: Export validator and types
- src/web/active-listener.ts: Add sendPoll to interface
- src/web/inbound.ts: Implement sendPoll using Baileys
- src/web/outbound.ts: Add sendPollWhatsApp function
- src/gateway/server-methods/send.ts: Add poll handler
- src/commands/poll.ts: New CLI command
- src/cli/program.ts: Register poll command

Closes openclaw#123
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Implements issue openclaw#123 - WhatsApp Poll Support

## Gateway Protocol
- Add `poll` RPC method with params: to, question, options (2-12), selectableCount

## ActiveWebListener
- Add `sendPoll(to, poll)` method to interface
- Implementation uses Baileys poll message type

## CLI Command
- `clawdbot poll --to <jid> -q <question> -o <opt1> -o <opt2> [-s count]`
- Supports --dry-run, --json, --verbose flags
- Validates 2-12 options

## Changes
- src/gateway/protocol/schema.ts: Add PollParamsSchema
- src/gateway/protocol/index.ts: Export validator and types
- src/web/active-listener.ts: Add sendPoll to interface
- src/web/inbound.ts: Implement sendPoll using Baileys
- src/web/outbound.ts: Add sendPollWhatsApp function
- src/gateway/server-methods/send.ts: Add poll handler
- src/commands/poll.ts: New CLI command
- src/cli/program.ts: Register poll command

Closes openclaw#123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: WhatsApp Poll Support

2 participants