87 lines
3.2 KiB
Markdown
Raw Permalink Normal View History

---
summary: "Poll sending via gateway + CLI"
read_when:
- Adding or modifying poll support
- Debugging poll sends from the CLI or gateway
title: "Polls"
---
2026-01-31 21:13:13 +09:00
# Polls
2026-01-13 06:51:20 +00:00
## Supported channels
2026-01-31 21:13:13 +09:00
- Telegram
2026-01-13 06:51:20 +00:00
- WhatsApp (web channel)
- Discord
- MS Teams (Adaptive Cards)
## CLI
```bash
# Telegram
openclaw message poll --channel telegram --target 123456789 \
--poll-question "Ship it?" --poll-option "Yes" --poll-option "No"
openclaw message poll --channel telegram --target -1001234567890:topic:42 \
--poll-question "Pick a time" --poll-option "10am" --poll-option "2pm" \
--poll-duration-seconds 300
# WhatsApp
2026-01-30 03:15:10 +01:00
openclaw message poll --target +15555550123 \
2026-01-09 08:27:17 +01:00
--poll-question "Lunch today?" --poll-option "Yes" --poll-option "No" --poll-option "Maybe"
2026-01-30 03:15:10 +01:00
openclaw message poll --target 123456789@g.us \
2026-01-09 08:27:17 +01:00
--poll-question "Meeting time?" --poll-option "10am" --poll-option "2pm" --poll-option "4pm" --poll-multi
# Discord
2026-01-30 03:15:10 +01:00
openclaw message poll --channel discord --target channel:123456789 \
2026-01-09 08:27:17 +01:00
--poll-question "Snack?" --poll-option "Pizza" --poll-option "Sushi"
2026-01-30 03:15:10 +01:00
openclaw message poll --channel discord --target channel:123456789 \
2026-01-09 08:27:17 +01:00
--poll-question "Plan?" --poll-option "A" --poll-option "B" --poll-duration-hours 48
# MS Teams
2026-01-30 03:15:10 +01:00
openclaw message poll --channel msteams --target conversation:19:abc@thread.tacv2 \
--poll-question "Lunch?" --poll-option "Pizza" --poll-option "Sushi"
```
Options:
2026-01-31 21:13:13 +09:00
- `--channel`: `whatsapp` (default), `telegram`, `discord`, or `msteams`
2026-01-09 08:27:17 +01:00
- `--poll-multi`: allow selecting multiple options
- `--poll-duration-hours`: Discord-only (defaults to 24 when omitted)
- `--poll-duration-seconds`: Telegram-only (5-600 seconds)
- `--poll-anonymous` / `--poll-public`: Telegram-only poll visibility
## Gateway RPC
Method: `poll`
Params:
2026-01-31 21:13:13 +09:00
- `to` (string, required)
- `question` (string, required)
- `options` (string[], required)
- `maxSelections` (number, optional)
- `durationHours` (number, optional)
- `durationSeconds` (number, optional, Telegram-only)
- `isAnonymous` (boolean, optional, Telegram-only)
2026-01-13 06:51:20 +00:00
- `channel` (string, optional, default: `whatsapp`)
- `idempotencyKey` (string, required)
2026-01-13 06:51:20 +00:00
## Channel differences
2026-01-31 21:13:13 +09:00
- Telegram: 2-10 options. Supports forum topics via `threadId` or `:topic:` targets. Uses `durationSeconds` instead of `durationHours`, limited to 5-600 seconds. Supports anonymous and public polls.
- WhatsApp: 2-12 options, `maxSelections` must be within option count, ignores `durationHours`.
- Discord: 2-10 options, `durationHours` clamped to 1-768 hours (default 24). `maxSelections > 1` enables multi-select; Discord does not support a strict selection count.
2026-01-30 03:15:10 +01:00
- MS Teams: Adaptive Card polls (OpenClaw-managed). No native poll API; `durationHours` is ignored.
2026-01-09 06:43:40 +01:00
## Agent tool (Message)
2026-01-31 21:13:13 +09:00
2026-01-13 06:51:20 +00:00
Use the `message` tool with `poll` action (`to`, `pollQuestion`, `pollOption`, optional `pollMulti`, `pollDurationHours`, `channel`).
2026-01-09 08:27:17 +01:00
For Telegram, the tool also accepts `pollDurationSeconds`, `pollAnonymous`, and `pollPublic`.
Use `action: "poll"` for poll creation. Poll fields passed with `action: "send"` are rejected.
2026-01-09 08:27:17 +01:00
Note: Discord has no “pick exactly N” mode; `pollMulti` maps to multi-select.
Teams polls are rendered as Adaptive Cards and require the gateway to stay online
2026-01-30 03:15:10 +01:00
to record votes in `~/.openclaw/msteams-polls.json`.