概述
Message Presentation 是 OpenClaw 的共享富消息 UI 契约,让 Agent、CLI 命令、审批流程和插件只需描述一次消息意图,由各 channel 插件渲染为最佳原生形式。核心类型 MessagePresentation 支持文本块、上下文/页脚文本、分隔线、按钮、下拉选择和卡片标题/语气。
核心功能
- 统一消息契约:
MessagePresentation类型包含title、tone(neutral/info/success/warning/danger)、blocks(text/context/divider/buttons/select) - 按钮语义:
value(应用操作值)、url(链接按钮)、webApp(Telegram Mini App)、style(primary/secondary/success/danger) - 优雅降级:不支持富控件的 channel 自动降级为文本,按钮变为标签+URL,select 变为选项列表
- 投递元数据:
ReplyPayloadDelivery.pin支持消息置顶(notify/required选项) - 渠道映射:Discord(Components)、Slack(Block Kit)、Telegram(内联键盘)、Teams(Adaptive Cards)、Feishu(互动卡片)、Mattermost(文本+交互属性)
- 向后兼容:保留
channelData.discord.components、channelData.slack.blocks等旧版字段,但新代码应使用presentation
配置/使用
从 Plugin SDK 导入:
import type { MessagePresentation, ReplyPayloadDelivery }
from "openclaw/plugin-sdk/interactive-runtime";Channel 插件声明渲染能力:
const adapter: ChannelOutboundAdapter = {
presentationCapabilities: { supported: true, buttons: true, selects: true },
deliveryCapabilities: { pin: true },
renderPresentation({ payload, presentation, ctx }) { ... },
async pinDeliveredMessage({ target, messageId, pin }) { ... }
};CLI 发送示例:
openclaw message send --channel slack --target channel:C123 \
--presentation '{"title":"Deploy","tone":"warning","blocks":[...]}'InteractiveReply(旧版)vs MessagePresentation(新版):新版增加 title、tone、context、divider、URL-only 按钮和通用投递元数据。
相关页面
- concepts/plugin-sdk-channel-plugins — Channel 插件构建
- concepts/plugin-sdk-channel-message — Channel 消息生命周期
- messages — 消息处理流水线