Skip to main content
腾讯元宝是 Tencent 的 AI 助手平台。社区维护的 openclaw-plugin-yuanbao 插件通过 WebSocket 将腾讯元宝机器人连接到 OpenClaw,用于私信和群聊。 状态: 私信机器人和群聊已生产就绪。WebSocket 是唯一受支持的连接模式。此插件由腾讯元宝团队作为外部目录条目维护,而不是由 OpenClaw 核心维护;下面的配置/行为细节(安装和通用 CLI 表面之外)来自插件自己的文档,尚未针对 OpenClaw 核心源代码进行验证。

快速开始

需要 OpenClaw 2026.4.10 或更高版本。使用 openclaw --version 检查;使用 openclaw update 升级。
1

使用你的凭证添加腾讯元宝渠道

openclaw channels add --channel yuanbao --token "appKey:appSecret"
--token 使用以冒号分隔的 appKey:appSecret。在腾讯元宝应用中通过你的应用设置创建机器人来获取这些值。
2

重启 Gateway 网关以应用更改

openclaw gateway restart

交互式设置(替代方案)

openclaw channels login --channel yuanbao
按照提示输入你的 App ID 和 App Secret。

访问控制

私信

channels.yuanbao.dm.policy
行为
open(默认)允许所有用户
pairing未知用户会获得配对码;通过 CLI 批准
allowlist只有 allowFrom 中的用户可以聊天
disabled禁用所有私信
批准配对请求:
openclaw pairing list yuanbao
openclaw pairing approve yuanbao <CODE>

群聊

channels.yuanbao.requireMention(默认 true):要求机器人在群组中响应前被 @提及。回复机器人自己的消息会被视为隐式提及。

配置示例

基础设置,开放私信策略:
{
  channels: {
    yuanbao: {
      appKey: "your_app_key",
      appSecret: "your_app_secret",
      dm: {
        policy: "open",
      },
    },
  },
}
将私信限制为特定用户:
{
  channels: {
    yuanbao: {
      appKey: "your_app_key",
      appSecret: "your_app_secret",
      dm: {
        policy: "allowlist",
        allowFrom: ["user_id_1", "user_id_2"],
      },
    },
  },
}
在群组中禁用 @提及要求:
{
  channels: {
    yuanbao: {
      requireMention: false,
    },
  },
}
出站投递调优:
{
  channels: {
    yuanbao: {
      outboundQueueStrategy: "merge-text",
      minChars: 2800, // buffer until this many chars
      maxChars: 3000, // force split above this limit
      idleMs: 5000, // auto-flush after idle timeout (ms)
    },
  },
}
设置 outboundQueueStrategy: "immediate" 可发送每个分块且不缓冲。

常用命令

命令描述
/help显示可用命令
/status显示机器人状态
/new启动新会话
/stop停止当前运行
/restart重启 OpenClaw
/compact压缩会话上下文
腾讯元宝支持原生斜杠菜单;Gateway 网关启动时,命令会自动同步到平台。

故障排查

机器人在群聊中没有响应:
  1. 确认机器人已添加到群组
  2. 确认你 @提及了机器人(默认要求)
  3. 检查日志:openclaw logs --follow
机器人没有收到消息:
  1. 确认机器人已在腾讯元宝应用中创建并获批
  2. 确认 appKeyappSecret 已正确配置
  3. 确认 Gateway 网关正在运行:openclaw gateway status
  4. 检查日志:openclaw logs --follow
机器人发送空回复或回退回复:
  1. 检查 AI 模型是否返回有效内容
  2. 默认回退回复:“暂时无法解答,你可以换个问题问问我哦”
  3. 使用 channels.yuanbao.fallbackReply 自定义
App Secret 泄露:
  1. 在腾讯元宝应用中重置 App Secret
  2. 更新你的配置中的值
  3. 重启 Gateway 网关:openclaw gateway restart

高级配置

多账号

{
  channels: {
    yuanbao: {
      defaultAccount: "main",
      accounts: {
        main: {
          appKey: "key_xxx",
          appSecret: "secret_xxx",
          name: "Primary bot",
        },
        backup: {
          appKey: "key_yyy",
          appSecret: "secret_yyy",
          name: "Backup bot",
          enabled: false,
        },
      },
    },
  },
}
defaultAccount 控制当出站 API 未指定 accountId 时使用哪个账号。

消息限制

  • maxChars:单条消息最大字符数(默认 3000
  • mediaMaxMb:媒体上传/下载限制(默认 20 MB)
  • overflowPolicy:消息超出限制时的行为,"split"(默认)或 "stop"

流式传输

腾讯元宝支持块级流式输出;机器人会在生成时按分块发送文本。
{
  channels: {
    yuanbao: {
      disableBlockStreaming: false, // block streaming enabled (default)
    },
  },
}
设置 disableBlockStreaming: true 可在一条消息中发送完整回复。

群聊历史上下文

{
  channels: {
    yuanbao: {
      historyLimit: 100, // default: 100, set 0 to disable
    },
  },
}
控制为群聊包含在 AI 上下文中的历史消息数量。

回复引用模式

{
  channels: {
    yuanbao: {
      replyToMode: "first", // "off" | "first" | "all" (default: "first")
    },
  },
}
行为
off不引用回复
first每条入站消息只引用第一次回复(默认)
all引用每一次回复

Markdown 提示注入

默认情况下,机器人会注入一条系统提示指令,防止模型将整个回复包裹在 markdown 代码块中。
{
  channels: {
    yuanbao: {
      markdownHintEnabled: true, // default: true
    },
  },
}

调试模式

{
  channels: {
    yuanbao: {
      debugBotIds: ["bot_user_id_1", "bot_user_id_2"],
    },
  },
}
为列出的机器人 ID 启用未清理的日志输出。

多智能体路由

使用 bindings 将腾讯元宝私信或群组路由到不同智能体:
{
  agents: {
    list: [
      { id: "main" },
      { id: "agent-a", workspace: "/home/user/agent-a" },
      { id: "agent-b", workspace: "/home/user/agent-b" },
    ],
  },
  bindings: [
    {
      agentId: "agent-a",
      match: {
        channel: "yuanbao",
        peer: { kind: "direct", id: "user_xxx" },
      },
    },
    {
      agentId: "agent-b",
      match: {
        channel: "yuanbao",
        peer: { kind: "group", id: "group_zzz" },
      },
    },
  ],
}
  • match.channel"yuanbao"
  • match.peer.kind"direct"(私信)或 "group"(群聊)
  • match.peer.id:用户 ID 或群组代码

配置参考

完整配置:Gateway 配置
设置描述默认值
channels.yuanbao.enabled启用/禁用该渠道true
channels.yuanbao.defaultAccount出站路由的默认账号default
channels.yuanbao.accounts.<id>.appKeyApp Key(签名 + ticket 生成)-
channels.yuanbao.accounts.<id>.appSecretApp Secret(签名)-
channels.yuanbao.accounts.<id>.token预签名 token(跳过自动 ticket 签名)-
channels.yuanbao.accounts.<id>.name账号显示名称-
channels.yuanbao.accounts.<id>.enabled启用/禁用特定账号true
channels.yuanbao.dm.policy私信策略open
channels.yuanbao.dm.allowFrom私信允许列表(用户 ID 列表)-
channels.yuanbao.requireMention要求群组中 @提及true
channels.yuanbao.overflowPolicy长消息处理(splitstopsplit
channels.yuanbao.replyToMode群组回复引用策略(offfirstallfirst
channels.yuanbao.outboundQueueStrategy出站策略(merge-textimmediatemerge-text
channels.yuanbao.minCharsMerge-text:触发发送的最小字符数2800
channels.yuanbao.maxCharsMerge-text:每条消息最大字符数3000
channels.yuanbao.idleMsMerge-text:自动刷新前的空闲超时(ms)5000
channels.yuanbao.mediaMaxMb媒体大小限制(MB)20
channels.yuanbao.historyLimit群聊历史上下文条目100
channels.yuanbao.disableBlockStreaming禁用块级流式输出false
channels.yuanbao.fallbackReply模型未返回内容时的回退回复暂时无法解答,你可以换个问题问问我哦
channels.yuanbao.markdownHintEnabled注入 markdown 防包裹指令true
channels.yuanbao.debugBotIds调试允许列表机器人 ID(未清理日志)[]

支持的消息类型

**接收:**文本、图片、文件、音频/语音、视频、贴纸/自定义表情、自定义元素(链接卡片)。 **发送:**文本(markdown)、图片、文件、音频、视频、贴纸。 **线程和回复:**引用回复(可通过 replyToMode 配置);平台不支持线程回复。

相关