Skip to content

訊息

用於發送訊息和頻道動作的單一出站指令 (Discord/Google Chat/iMessage/Matrix/Mattermost (plugin)/Microsoft Teams/Signal/Slack/Telegram/WhatsApp)。

openclaw message <subcommand> [flags]

頻道選擇:

  • --channel 如果設定了多個頻道則為必填。
  • 如果僅設定一個頻道,它將成為預設值。
  • 值: discord|googlechat|imessage|matrix|mattermost|msteams|signal|slack|telegram|whatsapp (Mattermost 需要 plugin)
  • openclaw message 當存在 --channel 或帶有頻道前綴的目標時,會將選定的頻道解析為其所屬的插件;否則,它會載入設定的頻道插件以進行預設頻道推斷。

目標格式 (--target):

  • WhatsApp:E.164、群組 JID,或 WhatsApp 頻道/電子報 JID (...@newsletter)
  • Telegram:聊天 ID、@username,或論壇主題目標 (-1001234567890:topic:42--thread-id 42)
  • Discord:channel:<id>user:<id> (或 <@id> 提及;原始數字 ID 被視為頻道)
  • Google Chat:spaces/<spaceId>users/<userId>
  • Slack:channel:<id>user:<id> (接受原始頻道 ID)
  • Mattermost (plugin):channel:<id>user:<id>@username (純 ID 被視為頻道)
  • Signal:+E.164group:<id>signal:+E.164signal:group:<id>username:<name>/u:<name>
  • iMessage:handle、chat_id:<id>chat_guid:<guid>chat_identifier:<id>
  • Matrix:@user:server!room:server#alias:server
  • Microsoft Teams:對話 ID (19:[email protected]) 或 conversation:<id>user:<aad-object-id>

名稱查詢:

  • 對於支援的提供商 (Discord/Slack/etc),諸如 Help#help 等頻道名稱會透過目錄快取解析。
  • 如果快取未命中,當供應商支援時,OpenClaw 將嘗試即時目錄查詢。
  • --channel <name>
  • --account <id>
  • --target <dest> (用於傳送/輪詢/讀取等操作的目標頻道或使用者)
  • --targets <name> (重複;僅限廣播)
  • --json
  • --dry-run
  • --verbose
  • openclaw message 會在執行選定的動作之前解析支援的頻道 SecretRefs。
  • 解析範圍在可能時會限定在目前啟用的動作目標:
    • 當設定了 --channel 時為頻道範圍 (或從帶有前綴的目標推斷,例如 discord:...)
    • 當設定了 --account 時為帳號範圍 (頻道全域變數 + 選定的帳號介面)
    • 當省略 --account 時,OpenClaw 不會強制執行 default 帳號 SecretRef 範圍
  • 無關頻道上未解析的 SecretRef 不會阻擋目標訊息動作。
  • 如果選定的頻道/帳號 SecretRef 未解析,該動作的指令將會以失敗封閉(fail closed)方式處理。
  • send

    • 頻道:WhatsApp/Telegram/Discord/Google Chat/Slack/Mattermost (plugin)/Signal/iMessage/Matrix/Microsoft Teams
    • 必要:--target,加上 --message--media--presentation
    • 選用:--media--presentation--delivery--pin--reply-to--thread-id--gif-playback--force-document--silent
    • 共享的展示格式:--presentation 會發送語意區塊(textcontextdividerbuttonsselect),核心會透過所選頻道宣稱的功能來進行渲染。請參閱 訊息展示
    • 通用傳送偏好設定:--delivery 接受傳送提示,例如 { "pin": true }--pin 是當頻道支援時釘選傳送的簡寫。
    • Telegram + WhatsApp:--force-document (將圖片、GIF 和影片作為文件發送,以避免頻道壓縮)
    • 僅限 Telegram:--thread-id (論壇主題 ID)
    • 僅限 Slack:--thread-id(執行緒時間戳;--reply-to 使用相同欄位)
    • Telegram + Discord:--silent
    • 僅限 WhatsApp:--gif-playback;WhatsApp 頻道/電子報以其原生的 @newsletter JID 定址。
  • poll

    • 頻道:WhatsApp/Telegram/Discord/Matrix/Microsoft Teams
    • 必填:--target--poll-question--poll-option(可重複)
    • 選填:--poll-multi
    • 僅限 Discord:--poll-duration-hours--silent--message
    • 僅限 Telegram:--poll-duration-seconds(5-600)、--silent--poll-anonymous / --poll-public--thread-id
  • react

    • 頻道:Discord/Google Chat/Matrix/Nextcloud Talk/Signal/Slack/Telegram/WhatsApp
    • 必填:--message-id--target
    • 選填:--emoji--remove--participant--from-me--target-author--target-author-uuid
    • 注意:--remove 需要 --emoji(在支援的情況下省略 --emoji 以清除自己的反應;請參閱 /tools/reactions)
    • 僅限 WhatsApp:--participant--from-me
    • Signal 群組反應:必填 --target-author--target-author-uuid
    • Nextcloud Talk:僅限新增反應;--remove 會因明確的錯誤訊息而被拒絕(請參閱 /tools/reactions)
  • reactions

    • 頻道:Discord/Google Chat/Slack/Matrix
    • 必填:--message-id--target
    • 選填:--limit
  • read

    • 頻道:Discord/Slack/Matrix
    • 必填:--target
    • 選填:--limit--message-id--before--after
    • 僅限 Slack:--message-id 用於讀取特定的 Slack 訊息時間戳;結合 --thread-id 以讀取特定的執行緒回覆。
    • 僅限 Discord:--around
  • edit

    • 頻道:Discord/Slack/Matrix
    • 必填:--message-id--message--target
  • delete

    • 頻道:Discord/Slack/Telegram/Matrix
    • 必填:--message-id--target
  • pin / unpin

    • 頻道:Discord/Slack/Matrix
    • 必填:--message-id--target
  • pins (清單)

    • 頻道:Discord/Slack/Matrix
    • 必填:--target
  • permissions

    • 頻道:Discord/Matrix
    • 必填:--target
    • 僅限 Matrix:當 Matrix 加密已啟用且允許驗證動作時可用
  • search

    • 頻道:Discord
    • 必填:--guild-id--query
    • 選填:--channel-id--channel-ids(可重複)、--author-id--author-ids(可重複)、--limit
  • thread create

    • 頻道:Discord
    • 必填:--thread-name--target(頻道 ID)
    • 選填:--message-id--message--auto-archive-min
  • thread list

    • 頻道:Discord
    • 必填:--guild-id
    • 選填:--channel-id--include-archived--before--limit
  • thread reply

    • 頻道:Discord
    • 必填:--target(串流 ID)、--message
    • 選填:--media--reply-to
  • emoji list

    • Discord:--guild-id
    • Slack:無額外標誌
  • emoji upload

    • 頻道:Discord
    • 必填:--guild-id--emoji-name--media
    • 選填:--role-ids(可重複)
  • sticker send

    • 頻道:Discord
    • 必填:--target--sticker-id(可重複)
    • 選填:--message
  • sticker upload

    • 頻道:Discord
    • 必填:--guild-id--sticker-name--sticker-desc--sticker-tags--media
  • role info (Discord):--guild-id
  • role add / role remove (Discord):--guild-id--user-id--role-id
  • channel info (Discord):--target
  • channel list (Discord):--guild-id
  • member info (Discord/Slack):--user-id (+ Discord 的 --guild-id)
  • voice status (Discord):--guild-id--user-id
  • event list (Discord):--guild-id
  • event create (Discord):--guild-id--event-name--start-time
    • 可選:--end-time--desc--channel-id--location--event-type
  • timeout--guild-id--user-id (可選 --duration-min--until;省略兩者以清除逾時)
  • kick--guild-id--user-id (+ --reason)
  • ban--guild-id--user-id (+ --delete-days--reason)
    • timeout 也支援 --reason
  • broadcast
    • 頻道:任何已配置的頻道;使用 --channel all 以目標設定所有提供者
    • 必填:--targets <target...>
    • 可選:--message--media--dry-run

發送 Discord 回覆:

openclaw message send --channel discord \
--target channel:123 --message "hi" --reply-to 456

發送包含語意按鈕的訊息:

openclaw message send --channel discord \
--target channel:123 --message "Choose:" \
--presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Approve","value":"approve","style":"success"},{"label":"Decline","value":"decline","style":"danger"}]}]}'

Core 會根據頻道功能,將相同的 presentation 載荷渲染為 Discord 組件、Slack 區塊、Telegram 行內按鈕、Mattermost 屬性,或 Teams/飛書卡片。請參閱 訊息呈現 以了解完整合約與後援規則。

發送更豐富的呈現載荷:

Terminal window
openclaw message send --channel googlechat --target spaces/AAA... \
--message "Choose:" \
--presentation '{"title":"Deploy approval","tone":"warning","blocks":[{"type":"text","text":"Choose a path"},{"type":"buttons","buttons":[{"label":"Approve","value":"approve"},{"label":"Decline","value":"decline"}]}]}'

建立 Discord 投票:

openclaw message poll --channel discord \
--target channel:123 \
--poll-question "Snack?" \
--poll-option Pizza --poll-option Sushi \
--poll-multi --poll-duration-hours 48

建立 Telegram 投票 (2 分鐘後自動關閉):

openclaw message poll --channel telegram \
--target @mychat \
--poll-question "Lunch?" \
--poll-option Pizza --poll-option Sushi \
--poll-duration-seconds 120 --silent

發送 Teams 主動訊息:

openclaw message send --channel msteams \
--target conversation:19:[email protected] --message "hi"

建立 Teams 投票:

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

在 Slack 中反應:

openclaw message react --channel slack \
--target C123 --message-id 456 --emoji "✅"

在 Signal 群組中反應:

openclaw message react --channel signal \
--target signal:group:abc123 --message-id 1737630212345 \
--emoji "✅" --target-author-uuid 123e4567-e89b-12d3-a456-426614174000

透過通用展示方式傳送 Telegram 內聯按鈕:

openclaw message send --channel telegram --target @mychat --message "Choose:" \
--presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Yes","value":"cmd:yes"},{"label":"No","value":"cmd:no"}]}]}'

透過通用展示方式傳送 Telegram Mini App 按鈕:

openclaw message send --channel telegram --target 123456789 --message "Open app:" \
--presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Launch","webApp":{"url":"https://example.com/app"}}]}]}'

Telegram 網頁應用程式按鈕僅在使用者與機器人之間的私人聊天中受支援。使用 web_app 的舊版 JSON 載荷仍可解析,但 webApp 是標準的展示欄位。

透過通用展示方式傳送 Teams 卡片:

Terminal window
openclaw message send --channel msteams \
--target conversation:19:[email protected] \
--presentation '{"title":"Status update","blocks":[{"type":"text","text":"Build completed"}]}'

將 Telegram 或 WhatsApp 圖片作為文件傳送以避免壓縮:

Terminal window
openclaw message send --channel telegram --target @mychat \
--media ./diagram.png --force-document