OpenClaw 可以在出站 Matrix m.room.message 事件中附加规范化的 MessagePresentation 元数据,存储在 com.openclaw.presentation 字段下。

普通 Matrix 客户端继续渲染纯文本 body,OpenClaw 感知客户端可读取结构化元数据并渲染原生 UI(按钮、选择框、上下文行、分隔符)。

事件内容格式

{
  "msgtype": "m.text",
  "body": "Select model\n\n- DeepSeek: /model deepseek/deepseek-chat",
  "com.openclaw.presentation": {
    "version": 1,
    "type": "message.presentation",
    "title": "Select model",
    "tone": "info",
    "blocks": [
      {
        "type": "select",
        "placeholder": "Choose model",
        "options": [
          { "label": "DeepSeek", "value": "/model deepseek/deepseek-chat" }
        ]
      }
    ]
  }
}

支持的 Block 类型

  • buttons:按钮组
  • select:下拉选择
  • context:上下文行
  • divider:分隔符

客户端应将未知字段和未知 block 类型视为忽略,而非导致整条消息渲染失败。

降级行为

OpenClaw 始终将可读纯文本渲染到 body。结构化元数据是附加的,不得要求基本 Matrix 互操作性。

交互方式

此元数据不添加 Matrix 回调语义。按钮和选择选项的值是降级交互载荷(通常是 slash 命令或文本命令)。支持交互的 Matrix 客户端可将选中值作为普通消息发回房间。

与审批元数据的关系

  • com.openclaw.presentation:通用富消息展示
  • com.openclaw.approval:审批提示(含安全敏感状态)

两者同时存在时,客户端应优先使用专用审批渲染器。

媒体消息

回复包含多个媒体 URL 时,OpenClaw 每个 URL 发送一个 Matrix 事件,展示元数据仅附加到第一个媒体事件。

相关链接