Appearance
openclaw message 是 OpenClaw 网关的统一出站命令,用于向 10 个已配置渠道发送消息、发起投票、添加回应、编辑/删除/置顶消息、读取历史以及执行 Discord 频道管理。需要先配置对应渠道插件并确保目标格式正确(如 Discord 用 channel:123,Signal 用 +E.164 或 group:id)。所有操作都受 SecretRef 解析保护:选中渠道/账户的 SecretRef 未解析时命令会安全失败。常见故障场景包括 --target 格式错误、单渠道默认推断不生效、poll 持续时间超限或 Signal 群组回应缺少 --target-author-uuid。
openclaw message 命令怎么配置发消息、投票、回应等操作
单个出站命令,用于发送消息和执行频道动作(Discord/Google Chat/iMessage/Matrix/Mattermost(插件)/Microsoft Teams/Signal/Slack/Telegram/WhatsApp)。
用法
openclaw message <subcommand> [flags]频道选择
--channel:配置了多个频道时必须指定。如果只配置了一个频道,它成为默认值。- 有效值:
discord|googlechat|imessage|matrix|mattermost|msteams|signal|slack|telegram|whatsapp(Mattermost 需要插件)。 - 当使用
--channel或频道前缀目标(如discord:...)时,命令会解析到对应插件;否则加载已配置的频道插件来推断默认频道。
目标格式(--target)
| 渠道 | 格式 |
|---|---|
E.164 号码,群组 JID,或频道/通讯稿 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(插件) | channel:<id>,user:<id>,或 @username;裸 ID 视为频道 |
| Signal | +E.164,group:<id>,signal:+E.164,signal: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:...@thread.tacv2),conversation:<id>,或 user:<aad-object-id> |
名称查找
- 对于支持渠道(Discord/Slack 等),频道名称如
Help或#help会通过目录缓存解析。 - 缓存未命中时,若提供者支持则尝试实时目录查找。
通用标志
--channel <name>--account <id>--target <dest>(发送/投票/读取等操作的目标频道或用户)--targets <name>(可重复;仅用于 broadcast)--json--dry-run--verbose
SecretRef 行为
- 执行操作前,OpenClaw 会解析所支持渠道的 SecretRef。
- 解析范围限定在活跃操作的目标内:
- 设置了
--channel(或从带前缀目标推断)时,限定到频道范围。 - 设置了
--account时,限定到账户范围(频道全局变量 + 选定账户的字段)。 - 省略
--account时,不会强制推用default账户 SecretRef 范围。
- 设置了
- 不相关频道上未解析的 SecretRef 不会阻止有目标的操作。
- 选中频道/账户的 SecretRef 未解析时,命令对该操作安全失败。
操作
核心操作
send(发送消息)
- 支持渠道:WhatsApp/Telegram/Discord/Google Chat/Slack/Mattermost(插件)/Signal/iMessage/Matrix/Microsoft Teams
- 必填:
--target,加上--message、--media或--presentation - 可选:
--media、--presentation、--delivery、--pin、--reply-to、--thread-id、--gif-playback、--force-document、--silent - 共享呈现负载:
--presentation发送语义块(text、context、divider、buttons、select),核心引擎根据渠道声明的能力渲染。参见 消息呈现。 - 通用投递偏好:
--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 频道/通讯稿使用原生@newsletterJID 地址。
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 操作
emoji list(列出 Emoji)
- Discord:
--guild-id - Slack:无额外标志
emoji upload(上传 Emoji)
- 支持渠道: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
角色 / 频道 / 成员 / 语音(Discord)
role info(Discord):--guild-idrole add/role remove(Discord):--guild-id、--user-id、--role-idchannel info(Discord):--targetchannel list(Discord):--guild-idmember info(Discord/Slack):--user-id(Discord 加--guild-id)voice status(Discord):--guild-id、--user-id
活动(Discord)
event list(Discord):--guild-idevent create(Discord):--guild-id、--event-name、--start-time- 可选:
--end-time、--desc、--channel-id、--location、--event-type
- 可选:
管理操作(Discord)
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 回复:
bash
openclaw message send --channel discord \
--target channel:123 --message "hi" --reply-to 456发送带语义按钮的消息:
bash
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"}]}]}'核心引擎会将同样的 --presentation 负载渲染为 Discord 组件、Slack 块、Telegram 内联按钮、Mattermost props、Teams 或飞书卡片,具体取决于渠道能力。参见消息呈现了解完整规约和回退规则。
发送更丰富的呈现负载(Google Chat 示例):
bash
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 投票:
bash
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 分钟后自动关闭):
bash
openclaw message poll --channel telegram \
--target @mychat \
--poll-question "Lunch?" \
--poll-option Pizza --poll-option Sushi \
--poll-duration-seconds 120 --silent发送 Microsoft Teams 主动消息:
bash
openclaw message send --channel msteams \
--target conversation:19:abc@thread.tacv2 --message "hi"创建 Teams 投票:
bash
openclaw message poll --channel msteams \
--target conversation:19:abc@thread.tacv2 \
--poll-question "Lunch?" \
--poll-option Pizza --poll-option Sushi在 Slack 中添加表情回应:
bash
openclaw message react --channel slack \
--target C123 --message-id 456 --emoji "✅"在 Signal 群组中添加回应(需指定目标作者 UUID):
bash
openclaw message react --channel signal \
--target signal:group:abc123 --message-id 1737630212345 \
--emoji "✅" --target-author-uuid 123e4567-e89b-12d3-a456-426614174000通过通用呈现发送 Telegram 内联按钮:
bash
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 按钮(仅私人聊天支持):
bash
openclaw message send --channel telegram --target 123456789 --message "Open app:" \
--presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Launch","webApp":{"url":"https://example.com/app"}}]}]}'旧版 JSON 中的 web_app 仍可解析,但标准字段为 webApp。
通过通用呈现发送 Teams 卡片:
bash
openclaw message send --channel msteams \
--target conversation:19:abc@thread.tacv2 \
--presentation '{"title":"Status update","blocks":[{"type":"text","text":"Build completed"}]}'发送 Telegram 或 WhatsApp 图片为文档以避免压缩:
bash
openclaw message send --channel telegram --target @mychat \
--media ./diagram.png --force-document常见问题
openclaw message send 报错 “channel not configured” 怎么解决
检查是否已为该渠道安装并配置了对应插件。如果只配置了一个渠道,命令会自动选择它;多个渠道时必须带上 --channel 参数。此外,确保渠道插件已启用且 SecretRef 已正确解析。
Telegram 发送图片被严重压缩,怎么禁用压缩
使用 --force-document 标志。所有图片、GIF 和视频都会作为文件(document)发送,Telegram 不会对其压缩。
Signal 群组添加表情回应失败,错误提示 “missing target-author-uuid”
Signal 群组回应必须指定被回应消息的作者的 UUID。使用 --target-author-uuid 参数传入对方的 uuid(可在 Signal 消息元数据中获取)。