前言

OpenClaw 是一个开源的 AI 助手框架,支持多渠道接入(Telegram、飞书、Discord 等)。本文将介绍如何配置飞书和 Telegram 两个常用渠道。


一、Telegram 配置

1. 创建 Bot

  1. 在 Telegram 中找到 @BotFather
  2. 发送 /newbot 命令
  3. 按提示输入 bot 名称和用户名
  4. 获取 Bot Token

2. 配置 OpenClaw

config.yaml 中添加:

1
2
3
4
5
channels:
telegram:
enabled: true
bot_token: "YOUR_BOT_TOKEN"
webhook_url: "https://your-domain.com/webhook/telegram"

3. 设置 Webhook

1
2
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook" \
-d "url=https://your-domain.com/webhook/telegram"

二、飞书配置

1. 创建应用

  1. 登录飞书开放平台
  2. 创建企业自建应用
  3. 获取 App ID 和 App Secret

2. 配置事件订阅

在应用后台配置事件订阅 URL:

1
https://your-domain.com/webhook/feishu

3. 配置 OpenClaw

1
2
3
4
5
6
channels:
feishu:
enabled: true
app_id: "YOUR_APP_ID"
app_secret: "YOUR_APP_SECRET"
verification_token: "YOUR_VERIFICATION_TOKEN"

三、多渠道同步

消息同步配置

1
2
3
4
5
6
7
8
sync:
enabled: true
channels:
- telegram
- feishu
exclude_patterns:
- "/config"
- "/help"

用户映射

1
2
user_mapping:
strategy: "phone_number" # 或 "email", "username"

四、部署

Docker 部署

1
2
3
4
5
6
7
8
9
10
11
12
13
version: '3'
services:
openclaw:
image: openclaw/openclaw:latest
ports:
- "3000:3000"
environment:
- TELEGRAM_BOT_TOKEN=your_token
- FEISHU_APP_ID=your_app_id
- FEISHU_APP_SECRET=your_app_secret
volumes:
- ./config:/app/config
- ./data:/app/data

启动

1
docker-compose up -d

五、常见问题

Q: Telegram webhook 设置失败?

A: 确保服务器有公网 IP,且 443 端口开放。

Q: 飞书收不到消息?

A: 检查事件订阅 URL 是否正确,以及应用是否有足够的权限。

Q: 多渠道消息不同步?

A: 检查 sync 配置是否正确,以及用户映射策略是否匹配。


总结

配置飞书和 Telegram 两个渠道的核心步骤:

  1. 创建应用/Bot,获取凭证
  2. 配置 Webhook/事件订阅
  3. 在 OpenClaw 中添加渠道配置
  4. 部署并测试

多渠道接入让你可以在不同场景使用最方便的沟通工具,消息历史自动同步,上下文不丢失。


本文详细介绍 OpenClaw 多渠道配置,让你的 AI 助手随时随地响应用户消息。