配置 openclaw 每个channel使用不同的agent和工作区,实现一个实例多个agent

官方文档:https://docs.openclaw.ai/zh-CN/concepts/multi-agent

这里以QQ、飞书、telegram三个渠道为例

首先在命令行执行创建agentid和工作区的命令

1
2
3
4
# agentId:qq  工作目录:~/.openclaw/workspaces/qq
openclaw agents add qq --workspace ~/.openclaw/workspaces/qq
# agentId:feishu  工作目录:~/.openclaw/workspaces/feishu
openclaw agents add feishu --workspace ~/.openclaw/workspaces/feishu

然后开始修改配置

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
  "models": { //这里基本上不用动
    "mode": "replace",
    "providers": {
      "apiprovider": {
        "baseUrl": "https://api.example.ai/v1",
        "apiKey": "sk-",
        "auth": "api-key",
        "api": "openai-completions",
        "authHeader": true,
        "models": [
          {
            "id": "kimi-k2.5",
            "name": "kimi-k2.5",
            "api": "openai-completions",
            "reasoning": false
          },
          {
            "id": "glm-4.7",
            "name": "glm-4.7",
            "api": "openai-completions",
            "reasoning": false
          },
          {
            "id": "minimax-m2.5",
            "name": "minimax-m2.5",
            "api": "openai-completions",
            "reasoning": false
          }
        ]
      }
    }
  },
  "agents": {
    "list": [ //执行了命令行这里就会自动写好
      { // 只需要这几配置项就够了,其他可以删了
        "id": "feishu",
        "name": "飞书",
        "workspace": "/root/.openclaw/workspaces/feishu",
        "model": {
          "primary": "apiprovider/kimi-k2.5"
        }
      },
      {
        "id": "qqbot",
        "name": "qq机器人",
        "workspace": "/root/.openclaw/workspaces/qq",
        "model": {
          "primary": "apiprovider/glm-4.7"
        }
      },
      {
        "id": "telegram",
        "name": "电报",
        "workspace": "/root/.openclaw/workspace",
        "model": {
          "primary": "apiprovider/minimax-m2.5"
        }
      }
    ]
  },
  "bindings": [ // 这里是关键,一定要看准
    {
      "agentId": "feishu",
      "match": {
        "channel": "feishu"
      }
    },
    {
      "agentId": "qqbot",
      "match": {
        "channel": "qqbot"
      }
    },
    {
      "agentId": "telegram",
      "match": {
        "channel": "telegram"
      }
    }
  ],
  "channels": {
    "telegram": {
      "enabled": true,
      "dmPolicy": "pairing",
      "botToken": "",
      },
      "groupPolicy": "open",
      "streaming": "partial"
    },
    "feishu": {
      "enabled": true,
      "appId": "cli_a93afb7d24f89cb1",
      "appSecret": "",
      "connectionMode": "websocket",
      "domain": "feishu",
      "groupPolicy": "open",
      "streaming": true
    },
    "qqbot": {
      "enabled": true,
      "appId": "",
      "clientSecret": ""
    }
  },
  "plugins": {
    "allow": [
      "feishu-openclaw-plugin",
      "telegram",
      "openclaw-qqbot"
    ],
    "entries": {
      "openclaw-qqbot": {
        "enabled": true
      },
      "feishu-openclaw-plugin": {
        "enabled": true
      },
      "feishu": { // 如果使用了飞书官方的插件,一定要禁用openclaw的,同时将这个放在最后
        "enabled": false
      }
  }
}

就到这里,自己能看懂就行~