---
summary: "通过网关 + CLI 发送投票"
read_when:
  - 添加或修改投票支持
  - 调试来自 CLI 或网关的投票发送
---
# 投票


## 支持的频道
- WhatsApp（网页频道）
- Discord
- MS Teams（自适应卡片）

## CLI

```bash
# WhatsApp
openclaw-cn message poll --target +15555550123 \
  --poll-question "Lunch today?" --poll-option "Yes" --poll-option "No" --poll-option "Maybe"
openclaw-cn message poll --target 123456789@g.us \
  --poll-question "Meeting time?" --poll-option "10am" --poll-option "2pm" --poll-option "4pm" --poll-multi

# Discord
openclaw-cn message poll --channel discord --target channel:123456789 \
  --poll-question "Snack?" --poll-option "Pizza" --poll-option "Sushi"
openclaw-cn message poll --channel discord --target channel:123456789 \
  --poll-question "Plan?" --poll-option "A" --poll-option "B" --poll-duration-hours 48

# MS Teams
openclaw-cn message poll --channel msteams --target conversation:19:abc@thread.tacv2 \
  --poll-question "Lunch?" --poll-option "Pizza" --poll-option "Sushi"
```

选项：
- `--channel`：`whatsapp`（默认）、`discord` 或 `msteams`
- `--poll-multi`：允许多选
- `--poll-duration-hours`：仅 Discord（省略时默认为 24）

## 网关 RPC

方法：`poll`

参数：
- `to`（字符串，必需）
- `question`（字符串，必需）
- `options`（字符串数组，必需）
- `maxSelections`（数字，可选）
- `durationHours`（数字，可选）
- `channel`（字符串，可选，默认：`whatsapp`）
- `idempotencyKey`（字符串，必需）

## 频道差异
- WhatsApp：2-12 个选项，`maxSelections` 必须在选项数量范围内，忽略 `durationHours`。
- Discord：2-10 个选项，`durationHours` 限制在 1-768 小时（默认 24）。`maxSelections > 1` 启用多选；Discord 不支持严格的选项数量。
- MS Teams：自适应卡片投票（Clawdbot 管理）。无原生投票 API；`durationHours` 被忽略。

## 代理工具（消息）
使用 `message` 工具的 `poll` 操作（`to`、`pollQuestion`、`pollOption`、可选 `pollMulti`、`pollDurationHours`、`channel`）。

注意：Discord 没有 "精确选择 N 个" 模式；`pollMulti` 映射到多选。
Teams 投票渲染为自适应卡片，需要网关保持在线
以在 `~/.openclaw/msteams-polls.json` 中记录投票。
