投票

支持的 Channel

  • WhatsApp(web channel)
  • Discord
  • MS Teams(Adaptive Cards)

CLI

# WhatsApp
openclaw message poll --target +15555550123 \
  --poll-question "Lunch today?" --poll-option "Yes" --poll-option "No" --poll-option "Maybe"
openclaw message poll --target [email protected] \
  --poll-question "Meeting time?" --poll-option "10am" --poll-option "2pm" --poll-option "4pm" --poll-multi

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

# MS Teams
openclaw message poll --channel msteams --target conversation:19:[email protected] \
  --poll-question "Lunch?" --poll-option "Pizza" --poll-option "Sushi"

选项说明:

  • --channel:可选 whatsapp(默认)、discordmsteams
  • --poll-multi:允许选择多个选项
  • --poll-duration-hours:仅 Discord 支持(省略时默认为 24 小时)

Gateway RPC

方法:poll

参数:

  • to(string,必填)
  • question(string,必填)
  • options(string[],必填)
  • maxSelections(number,可选)
  • durationHours(number,可选)
  • channel(string,可选,默认:whatsapp
  • idempotencyKey(string,必填)

Channel 差异

  • WhatsApp:支持 2-12 个选项,maxSelections 必须在选项数量范围内,忽略 durationHours
  • Discord:支持 2-10 个选项,durationHours 限制在 1-768 小时之间(默认 24 小时)。maxSelections > 1 会启用多选模式;Discord 不支持严格的选择数量限制。
  • MS Teams:使用 Adaptive Card 投票(由 OpenClaw 管理)。没有原生投票 API;忽略 durationHours

Agent 工具(Message)

使用 message 工具,设置 poll 动作(参数包括 topollQuestionpollOption,可选参数有 pollMultipollDurationHourschannel)。

注意:Discord 没有”精确选择 N 个”的模式;pollMulti 对应多选模式。 Teams 投票会渲染为 Adaptive Cards,需要 Gateway 保持在线状态, 以便将投票结果记录到 ~/.openclaw/msteams-polls.json