本文档总结在 OpenClaw 中配置「两个 Telegram Bot + 两个独立 Agent」(主助手 + 学习教练牛马)的架构、踩坑与解决方案。适用于需要同一 Gateway 下跑多个 Telegram 账号、且每个账号对应不同人设/能力的场景。
一、目标架构
两个 Telegram Bot
- 原 Bot(第一个 token):通用助手,对应 Agent main,身份来自主工作区(如 Samantha)。
- 牛马 Bot(第二个 token):只做学习辅导,对应 Agent niuma_teacher,身份为 Niuma Teacher,用费曼学习法、记录学习情况与薄弱点。
路由关系
- Telegram 账号
default→ Agentmain - Telegram 账号
niuma→ Agentniuma_teacher
二、核心概念(架构速览)
2.1 Channel 与 Account
- OpenClaw 的 Channel 由插件注册,例如 Telegram 插件只注册一个 channel id:
telegram。 - 多 Bot = 多 Account:同一 channel 下可以有多个账号,配置在
channels.telegram.accounts里,每个 key 是一个 accountId(如default、niuma)。 - 重要:一旦存在
channels.telegram.accounts,Gateway 只会为这些 accountId 各起一个连接;顶层channels.telegram.botToken不会单独再起一个「默认」连接。
2.2 Agent 与 Bindings
- Agent:在
agents.list里定义,有id、identity、model、workspace、agentDir、skills等。 - Binding:在顶层
bindings里定义,格式为{ agentId, match: { channel, accountId? } },表示「某 channel 的某 account 用哪个 agent」。
2.3 身份与工作区
- Identity:可来自配置里
agents.list[].identity.name,或 Agent 工作区下的IDENTITY.md。 - agentDir:该 agent 的专属目录,默认
~/.openclaw/agents/,用于 SOUL.md、IDENTITY.md、auth 等。/agent - workspace:对话/文件操作使用的工作目录。
三、配置形态(最终参考)
详见原文 JSON 配置示例。
四、踩坑与解决
4.1 Gateway 启动失败:unknown channel id: telegram-niuma
原因:在 channels 下用了自定义 key telegram-niuma。OpenClaw 只认插件注册的 channel id。
解决:改为在 channels.telegram.accounts 下加账号。
4.2 只有一个 Bot 能连
原因:没有把两个 bot 都写进 accounts。
解决:两个 bot 都放进 accounts。
4.3 牛马 Bot 说自己是「Samantha」
原因:路由错误或 accountId 大小写不匹配。
解决:为 niuma_teacher 显式设置独立的 workspace 和 agentDir。
五、检查清单
- 两个 bot 的 token 分别写在 accounts
- agents.list 中有 main 和 niuma_teacher
- bindings 配置正确
- niuma_teacher 有独立的 agentDir 和人设文件
文档基于 2026-02 的 OpenClaw 使用与排错过程整理。


















