频道与配对机制(按官方 Channels/Pairing)
为什么这页重要
OpenClaw 的"可用性"来自渠道接入,"可控性"来自配对与路由。 如果只接渠道不做配对策略,团队很快会出现串话、误触发和权限外溢。
参考:
- https://docs.openclaw.ai/channels/index.md
- https://docs.openclaw.ai/channels/pairing.md
- https://docs.openclaw.ai/channels/channel-routing.md
渠道层能力版图
官方目录覆盖:
即时通讯
| 渠道 | 特点 | 适用场景 |
|---|---|---|
| Discord | 社区友好、支持频道和线程 | 开源社区、游戏团队 |
| Telegram | 简单可靠、API 稳定 | 个人助理、小团队 |
| 用户基数大、需 QR 配对 | 客服、企业对接 | |
| Slack | 企业友好、支持 App 集成 | 企业团队协作 |
| Signal | 隐私优先、端到端加密 | 敏感通信 |
企业协作
| 渠道 | 特点 | 适用场景 |
|---|---|---|
| Microsoft Teams | Office 集成、企业标准 | 企业办公 |
| Google Chat | G Suite 集成 | Google 生态团队 |
| Feishu | 国内友好、多语言支持 | 国内企业 |
| Mattermost | 自托管、隐私可控 | 安全敏感场景 |
其他渠道
| 渠道 | 特点 | 适用场景 |
|---|---|---|
| IRC | 轻量、开源社区 | 开源项目 |
| Nostr | 去中心化 | Web3 社区 |
| iMessage | Apple 生态 | 个人使用 |
| Web Chat | 内嵌网页、无依赖 | 客服、产品集成 |
配对与路由实践
1. 按业务域配对
yaml
# 按业务域配对
pairing:
- name: dev-support
channels: [discord-dev, slack-eng]
agent: dev-agent
tools: coding
- name: customer-service
channels: [whatsapp-cs, telegram-cs]
agent: cs-agent
tools: minimal
- name: ops-alerts
channels: [slack-ops, pagerduty]
agent: ops-agent
tools: exec原则:每个业务域或项目线绑定独立会话策略,高风险项目不与低风险项目共享同一执行上下文。
2. 按环境配对
yaml
# 按环境配对
environments:
dev:
channels: [discord-dev]
agent: dev-agent
tools: full
approval: relaxed
staging:
channels: [slack-staging]
agent: staging-agent
tools: coding
approval: standard
prod:
channels: [slack-prod, pagerduty]
agent: prod-agent
tools: minimal
approval: strict原则:dev / stage / prod 分离,生产环境默认只允许低风险查询与审阅类动作。
3. 按角色配对
yaml
# 按角色配对
roles:
developer:
channels: [discord-dev, slack-eng]
agent: dev-agent
tools: coding
approval:
exec: on-miss
product_manager:
channels: [slack-pm]
agent: pm-agent
tools: minimal
approval:
all: off
ops:
channels: [slack-ops, pagerduty]
agent: ops-agent
tools: full
approval:
exec:elevated: always原则:
- 开发者:可触发构建、排障、脚本类能力(受审批策略约束)
- 产品经理:优先只读与流程调度能力
- 运维:单独保留高权限通道
渠道配置示例
Discord 配置
yaml
channels:
discord:
enabled: true
bot_token: ${secrets.discord_bot_token}
application_id: ${secrets.discord_app_id}
# 服务器配置
guilds:
- id: '123456789'
name: My Server
# 频道映射
channel_mapping:
general: dev-agent
support: cs-agent
alerts: ops-agent
# 权限配置
permissions:
admin_roles: [Admin, Moderator]
allowed_channels: [general, support, alerts]Telegram 配置
yaml
channels:
telegram:
enabled: true
bot_token: ${secrets.telegram_bot_token}
# 群组配置
groups:
- id: '-100123456789'
name: Dev Team
agent: dev-agent
# 私聊配置
private:
allowed_users: [123456789, 987654321]
agent: personal-agentSlack 配置
yaml
channels:
slack:
enabled: true
app_token: ${secrets.slack_app_token}
bot_token: ${secrets.slack_bot_token}
# 工作区配置
workspace: my-workspace
# 频道映射
channel_mapping:
C12345678: dev-agent # #dev
C87654321: ops-agent # #ops
C11111111: cs-agent # #support
# 触发配置
trigger:
mention: true # @机器人 触发
direct_message: true # 私聊触发
channel_prefix: 'ai:' # 频道前缀触发路由规则
基于关键词路由
yaml
routing:
rules:
- trigger: 'dev:'
agent: dev-agent
channels: ['*']
- trigger: 'ops:'
agent: ops-agent
channels: [slack-ops, discord-ops]
- trigger: help
agent: support-agent
channels: ['*']基于频道路由
yaml
routing:
by_channel:
discord-dev:
agent: dev-agent
tools: coding
slack-ops:
agent: ops-agent
tools: full
whatsapp-cs:
agent: cs-agent
tools: minimal基于用户路由
yaml
routing:
by_user:
U123456: # Admin user
agent: admin-agent
tools: full
U789012: # Regular user
agent: standard-agent
tools: coding上线检查清单
bash
# 1. 检查渠道状态
openclaw channels list
openclaw channels status --probe
# 2. 检查配对状态
openclaw pairing list
# 3. 测试消息收发
# 通过已配置渠道发送测试消息
# 4. 检查路由规则
openclaw config get routing
# 5. 检查整体状态
openclaw status配对验证清单
markdown
- [ ] 渠道已正确配置并连接
- [ ] 配对状态显示 active
- [ ] 测试消息能收到回复
- [ ] 路由规则按预期生效
- [ ] 权限策略正确应用
- [ ] 审批流程正常工作常见问题排查
问题 1:渠道配对失败
bash
# 检查渠道配置
openclaw channels show <channel-name>
# 重新配对
openclaw channels pair <channel-name> --force
# 查看日志
openclaw logs --filter "channel:<channel-name>"问题 2:消息未触发 Agent
bash
# 检查触发规则
openclaw config get routing
# 检查频道映射
openclaw config get channel_mapping
# 查看会话日志
openclaw logs --filter "session"问题 3:权限问题
bash
# 检查权限配置
openclaw config get permissions
# 检查用户权限
openclaw users show <user-id>
# 安全审计
openclaw security audit常用扩展阅读
- 分组与群消息:
/channels/groups.md、/channels/group-messages.md - 渠道排障:
/channels/troubleshooting.md
