什么是 Channel
Channel 是连接 CodeBanana 与外部即时通信工具的桥梁。 配置 Bot 后,你可以直接从 Slack 或 Telegram 等平台向项目 Agent 发送消息,并接收回复。 这样,你可以在不同沟通环境中灵活使用 Agent。支持的平台
Agent 可以连接到多个即时通信平台,包括:- 飞书
- Telegram
- Slack
- Discord
- 钉钉
- 企业微信

创建 Bot
要启用 Channel,需要创建并配置 Bot:- 点击头像 → IM Setting → Add Bot
- 选择目标即时通信平台
- 提供所需凭证(例如 ID 和 Secret)
- 正确配置后:
- 状态显示为 Connected
- 配置无效时显示为 Disconnected
1
打开 IM Setting

2
添加新 Bot

3
创建成功

将 Bot 绑定到项目
创建 Bot 后,需要将其关联到具体项目:- 选择 Bot 并将其绑定到项目
- 每个项目只能绑定一个 Bot
- 每个 Bot 只能绑定到一个项目
1
打开 Channel 配置

2
绑定 Bot

工作方式
连接后:- 从外部平台发送的消息会被转发给项目 Team Agent
- Agent 使用相同的项目上下文处理请求
- 回复会返回外部平台
即时通信集成指南
飞书(Lark)
飞书(Lark)
设置
在开发者控制台中创建应用:- 登录 https://open.feishu.cn/app
- 创建企业自建应用
- 配置名称、描述和头像
- 记录 App ID 和 App Secret
权限
添加以下权限:im:message:send_as_botim:message:readonly
事件订阅
- 使用长连接模式
- 订阅:
im.message.receive_v1
在 CodeBanana 中配置
- 前往 Personal Center → IM Settings
- 输入 App ID 和 App Secret
Telegram
Telegram
企业微信
企业微信
设置
- 登录 https://work.weixin.qq.com/wework_admin/frame#/manageTools
- 前往安全与管理 → 管理工具

- 配置名称、Logo 和可见范围(全部)→ Save
消息配置
- 编辑机器人 → 点击通过 API 模式创建

- 选择长连接模式,并获取 Bot ID 和 Secret

- 返回 CodeBanana:
- 前往 IM Setting
- 添加新 Bot
- 按照下图进行配置并点击 Save

- [重要] 关联 CodeBanana 项目后才能使用 IM Channel

QQ
设置
- 访问 https://q.qq.com/#/
- 进入 OpenClaw Bot 创建入口
- 通过二维码登录
- 创建 Bot 并获取:
- App ID
- App Secret
在 CodeBanana 中配置
- 在 IM Settings 中添加凭证
钉钉
钉钉
设置
- 打开 https://open-dev.dingtalk.com
- 创建 OpenClaw Bot 应用
- 记录:
- Client ID
- Client Secret
在 CodeBanana 中配置
- 在 IM Settings 中输入凭证
Slack
Slack
设置
从官方控制台创建 Slack App:- 访问 https://api.slack.com/apps
- 点击 Create New App → From scratch
- App Name:例如 CB
- Development Slack Workspace:选择你的工作区
- 点击 Create App
Socket Mode(必需)
启用长连接模式:- 前往 Settings → Socket Mode
- 开启 Enable Socket Mode
- 创建 Token(例如
openclaw-socket)- 权限:
connections:write (auto-assigned)
- 权限:
- 点击 Generate,并复制 App-Level Token(
xapp-...)
Bot 权限
配置 Bot 能力:- 前往 Features → OAuth & Permissions
- 在 Bot Token Scopes → Add an OAuth Scope 下添加:
app_mentions:read— 读取 @mentionchat:write— 发送消息channels:history— 读取公开频道groups:history— 读取私有频道im:history— 读取私信mpim:history— 读取群组私信files:write— 上传文件/图片
安装与 Token
- 点击 Install to Workspace → Allow
- 复制 Bot User OAuth Token(
xoxb-...)
xapp-...→ App Token(Socket Mode/连接)xoxb-...→ Bot Token(发送消息)
App Home 配置
- 前往 Features → App Home
- 在 Show Tabs 下启用:
- Messages Tab(允许用户向 Bot 发送私信)
事件订阅
启用基于事件的消息处理:- 前往 Features → Event Subscriptions
- 开启 Enable Events
- 在 Subscribe to bot events 下添加:
app_mention— 在频道中提及 Bot 时触发message.im— 私信message.channels— 公开频道message.groups— 私有频道
- 点击 Save Changes
在 CodeBanana 中配置
- 前往 Personal Center → IM Settings
- 配置两个 Token:
- App Token(
xapp-...) - Bot Token(
xoxb-...)
- App Token(
Discord
Discord
创建 Bot
通过 Developer Portal 设置 Bot:- 访问 https://discord.com/developers/applications
- 点击 New Application → 输入名称(例如
OpenClaw Bot)→ Create - 前往 Bot → Add Bot → Yes, do it!
- 点击 Reset Token → 复制 Bot Token(只显示一次)
- 格式示例:
MTk5OTk5OTkyNzY4OTk4NzYxNg...
必需的 Intent(关键)
启用特权 Intent:- 滚动到 Privileged Gateway Intents
- 全部启用:
Message Content Intent(读取消息内容)Server Members IntentPresence Intent
- 点击 Save Changes
邀请 Bot 加入服务器
生成邀请链接:- 前往 OAuth2 → URL Generator
botapplications.commands(用于 Slash Command)
Read Messages / View ChannelsSend MessagesRead Message HistoryEmbed LinksAdd Reactions (optional)- 复制生成的 URL → 在浏览器中打开
- 选择服务器 → Authorize
在 CodeBanana 中配置
- 前往 Personal Center → IM Settings
- 粘贴 Bot Token

