投票
适用场景
在以下情况使用本页面:
- 添加或修改投票支持
- 调试从 CLI 或网关发送的投票
支持的频道
- WhatsApp(Web 频道)
- Discord
- MS Teams(Adaptive Cards)
CLI
# WhatsApp
moltbot message poll --target +15555550123 \
--poll-question "今天午餐?" --poll-option "是" --poll-option "否" --poll-option "也许"
moltbot message poll --target [email protected] \
--poll-question "会议时间?" --poll-option "上午10点" --poll-option "下午2点" --poll-option "下午4点" --poll-multi
# Discord
moltbot message poll --channel discord --target channel:123456789 \
--poll-question "零食?" --poll-option "披萨" --poll-option "寿司"
moltbot message poll --channel discord --target channel:123456789 \
--poll-question "计划?" --poll-option "A" --poll-option "B" --poll-duration-hours 48
# MS Teams
moltbot message poll --channel msteams --target conversation:19:[email protected] \
--poll-question "午餐?" --poll-option "披萨" --poll-option "寿司"选项:
--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:Adaptive Card 投票(由 Moltbot 管理)。没有原生投票 API;忽略
durationHours。
Agent 工具(Message)
使用带有 poll 操作的 message 工具(to、pollQuestion、pollOption、可选 pollMulti、pollDurationHours、channel)。
注意:Discord 没有"精确选择 N 个"模式;pollMulti 映射到多选。
Teams 投诉呈现为 Adaptive Cards,需要网关保持在线以在 ~/.moltbot/msteams-polls.json 中记录投票。