OpenClaw 多平台集成
将 AI 助理集成到多个平台。
🌐 支持的平台
| 平台 | 类型 | 难度 | 文档 |
|---|---|---|---|
| 飞书 | 企业协作 | ⭐⭐ | 文档 |
| 微信 | 社交 | ⭐⭐⭐ | 文档 |
| Telegram | 即时通讯 | ⭐⭐ | 文档 |
| Discord | 社区 | ⭐⭐ | 文档 |
| Slack | 企业协作 | ⭐⭐ | 文档 |
| 钉钉 | 企业协作 | ⭐⭐⭐ | 文档 |
🔧 通用集成步骤
1. 创建应用
每个平台都需要:
- 注册开发者账号
- 创建应用
- 获取凭证(App ID、Secret)
2. 配置权限
- 消息发送权限
- 消息接收权限
- 群组权限(如需要)
3. 配置 OpenClaw
json
{
"channels": {
"platform-name": {
"enabled": true,
"credentials": {
"appId": "xxx",
"appSecret": "xxx"
}
}
}
}4. 测试验证
bash
# 测试通道
openclaw channels test platform-name
# 发送测试消息
openclaw message send --target user:xxx "测试"📱 飞书集成
配置步骤
1. 创建飞书应用
2. 获取凭证
- App ID
- App Secret
- Verification Token
3. 配置权限
消息:发送、接收
群组:机器人4. OpenClaw 配置
json
{
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxx",
"appSecret": "xxxxx",
"connectionMode": "websocket"
}
}
}5. 配置事件订阅
- 接收消息
- 群组消息
- 机器人进入群组
💬 微信集成
方案 1:企业微信
配置步骤
json
{
"channels": {
"wechat-work": {
"enabled": true,
"corpId": "xxxxx",
"agentId": "xxxxx",
"secret": "xxxxx"
}
}
}方案 2:个人微信(需要额外工具)
使用 Wechaty
bash
npm install wechatyjavascript
const { WechatyBuilder } = require('wechaty');
const bot = WechatyBuilder.build();
bot.on('message', async (message) => {
// 转发给 OpenClaw
const response = await openclaw.process(message.text());
await message.say(response);
});
bot.start();✈️ Telegram 集成
配置步骤
1. 创建 Bot
联系 @BotFather:
/newbot
输入 Bot 名称
获取 Token2. OpenClaw 配置
json
{
"channels": {
"telegram": {
"enabled": true,
"token": "bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
}
}
}3. 配置 Webhook(可选)
bash
curl -X POST "https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://your-server:18789/telegram/webhook"🎮 Discord 集成
配置步骤
1. 创建应用
访问:https://discord.com/developers/applications
2. 创建 Bot
- 添加 Bot 用户
- 获取 Token
- 启用 Privileged Gateway Intents
3. 邀请 Bot 到服务器
https://discord.com/api/oauth2/authorize?client_id=XXX&permissions=8&scope=bot4. OpenClaw 配置
json
{
"channels": {
"discord": {
"enabled": true,
"token": "bot-token-here",
"clientId": "client-id-here"
}
}
}💼 Slack 集成
配置步骤
1. 创建应用
2. 配置权限
chat:write
im:read
im:history3. 获取 Token
- Bot User OAuth Token
- 格式:
xoxb-xxx
4. OpenClaw 配置
json
{
"channels": {
"slack": {
"enabled": true,
"token": "xoxb-xxxxx",
"signingSecret": "xxxxx"
}
}
}📊 多平台管理
统一配置
json
{
"channels": {
"feishu": { "enabled": true, ... },
"telegram": { "enabled": true, ... },
"discord": { "enabled": true, ... }
},
"routing": {
"default": "feishu",
"fallback": "telegram"
}
}平台特定配置
javascript
// 根据不同平台调整回复风格
function formatResponse(response, platform) {
switch (platform) {
case 'feishu':
return formatFeishu(response);
case 'telegram':
return formatTelegram(response);
case 'discord':
return formatDiscord(response);
}
}🔄 消息路由
智能路由
javascript
const routingRules = {
// 工作时间用飞书
workHours: 'feishu',
// 下班时间用微信
afterWork: 'wechat',
// 紧急情况用 Telegram
urgent: 'telegram'
};
function routeMessage(message) {
const hour = new Date().getHours();
if (hour >= 9 && hour <= 18) {
return 'feishu';
}
return 'wechat';
}📈 平台对比
| 特性 | 飞书 | 微信 | Telegram | Discord |
|---|---|---|---|---|
| 部署难度 | ⭐⭐ | ⭐⭐⭐ | ⭐⭐ | ⭐⭐ |
| 稳定性 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 功能丰富 | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 适合场景 | 企业 | 个人 | 通用 | 社区 |
提示
选择一个主要平台,逐步扩展到其他平台!
🟢🐉 泡泡龙