投票

支援的頻道

  • Telegram
  • WhatsApp(網頁頻道)
  • Discord
  • MS Teams(Adaptive Cards)

CLI

# 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
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"

選項:

  • --channelwhatsapp(預設)、telegramdiscordmsteams
  • --poll-multi:允許選擇多個選項
  • --poll-duration-hours:僅限 Discord(省略時預設為 24)
  • --poll-duration-seconds:僅限 Telegram(5-600 秒)
  • --poll-anonymous / --poll-public:僅限 Telegram 的投票可見度

Gateway RPC

方法:poll

參數:

  • to(string,必填)
  • question(string,必填)
  • options(string[],必填)
  • maxSelections(number,選填)
  • durationHours(number,選填)
  • durationSeconds(number,選填,僅限 Telegram)
  • isAnonymous(boolean,選填,僅限 Telegram)
  • channel(string,選填,預設:whatsapp
  • idempotencyKey(string,必填)

頻道差異

  • Telegram:2-10 個選項。支援透過 threadId:topic: 目標的論壇主題。使用 durationSeconds 而非 durationHours,限制在 5-600 秒。支援匿名和公開投票。
  • WhatsApp:2-12 個選項,maxSelections 必須在選項數量範圍內,忽略 durationHours
  • Discord:2-10 個選項,durationHours 限制在 1-768 小時(預設 24)。maxSelections > 1 啟用多選;Discord 不支援嚴格的選擇數量限制。
  • MS Teams:Adaptive Card 投票(由 OpenClaw 管理)。沒有原生投票 API;durationHours 會被忽略。

代理工具(Message)

使用 message 工具搭配 poll 動作(topollQuestionpollOption,選用 pollMultipollDurationHourschannel)。

Telegram 另外接受 pollDurationSecondspollAnonymouspollPublic

建立投票請使用 action: "poll"。在 action: "send" 中傳遞投票欄位會被拒絕。

注意:Discord 沒有「恰好選 N 個」的模式;pollMulti 對應到多選。 Teams 投票以 Adaptive Cards 呈現,需要 Gateway 保持在線以在 ~/.openclaw/msteams-polls.json 中記錄投票結果。