10.8 轮询机制

OpenClaw 支持在多个频道中创建投票,让您可以轻松收集团队或用户的反馈。

支持的频道

  • WhatsApp(web 频道)
  • Discord
  • MS Teams(自适应卡片)

CLI 命令

WhatsApp 投票

# 单选投票
openclaw message poll --target +15555550123 \
  --poll-question "今天午餐吃什么?" \
  --poll-option "是" \
  --poll-option "否" \
  --poll-option "也许"

# 群组投票
openclaw message poll --target 123456789@g.us \
  --poll-question "会议时间?" \
  --poll-option "上午10点" \
  --poll-option "下午2点" \
  --poll-option "下午4点" \
  --poll-multi

Discord 投票

# 基本投票
openclaw message poll --channel discord --target channel:123456789 \
  --poll-question "零食选择?" \
  --poll-option "披萨" \
  --poll-option "寿司"

# 带持续时间的投票
openclaw message poll --channel discord --target channel:123456789 \
  --poll-question "计划?" \
  --poll-option "A方案" \
  --poll-option "B方案" \
  --poll-duration-hours 48

MS Teams 投票

openclaw message poll --channel msteams --target conversation:19:abc@thread.tacv2 \
  --poll-question "午餐?" \
  --poll-option "披萨" \
  --poll-option "寿司"

命令选项

选项 说明
--channel whatsapp(默认)、discordmsteams
--poll-multi 允许选择多个选项
--poll-duration-hours 仅限 Discord(省略时默认为24小时)

Gateway 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 无限制 自适应卡片投票(OpenClaw 管理);无原生投票 API;忽略 durationHours

代理工具(Message)

使用带有 poll 操作的 message 工具(参数:topollQuestionpollOption,可选 pollMultipollDurationHourschannel)。

注意
  • Discord 没有"恰好选择 N 个"模式;pollMulti 映射到多选。
  • Teams 投票呈现为自适应卡片,需要网关保持在线才能在 ~/.openclaw/msteams-polls.json 中记录投票。