OpenClaw消息渠道集成:让消息无处不在
运营AI需要监控,需要通知,需要和用户互动。消息渠道就是Agent的「感官系统」——没有它,Agent就是个聋子哑巴。这篇告诉你怎么让它开口说话。
支持的消息渠道
- 📱 飞书:国内企业协作首选
- 💬 Discord:社区运营神器
- ✈️ Telegram:国际用户触达
- 🔗 Webhook:对接任意系统
- 📧 Email:传统但可靠
飞书集成
配置
# openclaw.config.json
{
"channels": {
"feishu": {
"app_id": "cli_xxxxx",
"app_secret": "secret_xxxxx",
"default_chat": "oc_xxx"
}
}
}
发送消息
# 发送文本
message send --platform feishu \
--target "oc_xxx" \
--message "任务完成!"
# 发送富文本卡片
message send --platform feishu \
--target "oc_xxx" \
--message '{"tag":"card",...}'
Discord集成
配置Bot
# 1. 创建Discord应用
https://discord.com/developers/applications
# 2. 添加Bot到服务器
OAuth2 -> Install -> bot scope
# 3. 获取Token
# 4. 配置OpenClaw
{
"channels": {
"discord": {
"bot_token": "xxx",
"default_channel": "123456789"
}
}
}
发送消息
# 发送文本
message send --platform discord \
--channel "123456789" \
--message "今日热点速递 📰"
# 发送嵌入消息
message send --platform discord \
--channel "123456789" \
--message '{
"embeds": [{
"title": "AI新闻日报",
"description": "今日AI圈发生了什么",
"color": "5813783"
}]
}'
消息模板
# 每日分享模板
每日AI工具推荐 📦
🔍 今日发现:{tool_name}
{short_description}
👉 {link}
# 踩坑故事模板
🎣 踩坑实录
{title}
{story_content}
# 更多案例:{link}
Telegram集成
配置
# 1. @BotFather 创建机器人
# 2. 获取API Token
# 3. 配置
{
"channels": {
"telegram": {
"bot_token": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
"chat_id": "user_id or channel_id"
}
}
}
发送
message send --platform telegram \
--chat_id "123456789" \
--message "Hello from OpenClaw!"
Webhook集成
通用Webhook
# 发送POST请求
{
"channels": {
"webhook": {
"enabled": true
}
}
}
# 发送数据
message send --platform webhook \
--url "https://your-server.com/hook" \
--data '{"event": "task_complete", "data": {...}}'
企业微信Webhook
# 通过wecom_mcp
wecom_mcp call contact getContact '{}'
定时通知配置
每日日报推送
{
"name": "daily-digest",
"schedule": {"kind": "cron", "expr": "0 8 * * *"},
"delivery": {
"mode": "announce",
"channel": "feishu",
"to": "oc_xxx"
}
}
多渠道同时推送
{
"name": "breaking-news",
"delivery": [
{"channel": "feishu", "to": "oc_xxx"},
{"channel": "discord", "to": "123456"},
{"channel": "telegram", "to": "789012"}
]
}
消息模板管理
# 模板目录
templates/
├── discord/
│ ├── daily_share.txt
│ ├── hot_news.txt
│ └── story.txt
├── feishu/
│ ├── report.txt
│ └── alert.txt
└── telegram/
└── notify.txt
最佳实践
- 消息精简:控制在合理长度
- 适当分隔:不同类型消息用不同渠道
- 频率控制:避免刷屏打扰用户
- 错误处理:发送失败记录日志