时间:2026-03-03 20:03
人气:
作者:admin
最近开始使用 OpenClaw,一个开源的 AI 助手框架,可以让我们在自己的服务器或本地运行 AI 助手,并接入多种消息平台。本文记录了我在安装配置 OpenClaw 并接入 Telegram 和飞书的过程,希望对有同样需求的朋友有所帮助。
OpenClaw 是一个开源的 AI 助手框架,支持:
OpenClaw 基于 Node.js 运行,首先确保你的系统已安装 Node.js 18+:
node -v # 检查版本
npm install -g openclaw@latest
OpenClaw 提供了交互式的配置向导,推荐使用 openclaw onboard 命令进行初始化:
# 运行配置向导(推荐)
openclaw onboard
配置向导会引导你完成以下步骤:
~/.openclaw/workspace)如果你想安装系统服务并自动启动:
# 安装守护进程服务
openclaw onboard --install-daemon
使用以下命令登录各个消息平台:
# 登录各消息渠道(交互式)
openclaw channels login
# 启动网关服务
openclaw gateway --port 18789
如果需要重新配置或修改设置:
# 重新配置
openclaw configure
# 添加新的 agent
openclaw agents add my-agent
# 查看配置路径
openclaw config path
# 查看状态
openclaw status
启动后会生成配置文件 ~/.openclaw/openclaw.json。
OpenClaw 支持多种模型提供商。我配置了 GLM-5 作为主力模型:
编辑 ~/.openclaw/openclaw.json,添加模型配置:
{
"models": {
"providers": {
"unicom": {
"baseUrl": "https://maas-api.ai-yuanjing.com/openapi/compatible-mode/v1",
"apiKey": "your-api-key",
"api": "openai-chat",
"models": [
{
"id": "glm-5",
"name": "GLM 5",
"contextWindow": 128000,
"maxTokens": 4096
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "unicom/glm-5"
}
}
}
}
@BotFather/newbot 创建新 Bot在配置文件中添加 Telegram 配置:
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "your-bot-token"
}
}
}
给你的 Bot 发送消息后,访问以下 URL 获取 Chat ID:
https://api.telegram.org/bot{BOT_TOKEN}/getUpdates
如果需要浏览器自动化功能:
openclaw gateway tokenhttps://open.feishu.cn在飞书应用后台添加以下权限:
im:message - 获取和发送消息im:message:send_as_bot - 以应用身份发消息{
"channels": {
"feishu": {
"enabled": true,
"appId": "your-app-id",
"appSecret": "your-app-secret"
}
}
}
在飞书应用后台配置事件订阅,URL 为:
http://your-server:18789/webhook/feishu
配置完成后,我实现了一个自动新闻推送功能,每 10 分钟抓取美伊冲突新闻并推送到飞书。
const https = require('https');
// 飞书配置
const FEISHU_APP_ID = 'your-app-id';
const FEISHU_APP_SECRET = 'your-app-secret';
const FEISHU_OPEN_ID = 'user-open-id';
// 获取飞书 Token
async function getTenantAccessToken() {
// ... 获取 access_token
}
// 发送消息
async function sendFeishuMessage(message) {
const token = await getTenantAccessToken();
// ... 调用飞书 API 发送消息
}
// 抓取新闻并推送
async function main() {
const news = await fetchNews();
const summary = await summarizeWithAI(news); // 用 GLM-5 总结
await sendFeishuMessage(summary);
}
# Windows 任务计划程序
schtasks /Create /TN "新闻推送" /TR "node push-news.js" /SC MINUTE /MO 10
# 启动网关
openclaw gateway --port 18789
# 查看状态
openclaw status
# 查看配置路径
openclaw config path
# 获取连接码(用于浏览器扩展)
openclaw gateway token
# 安装技能
openclaw skills install skill-name
OpenClaw 是一个功能强大的 AI 助手框架,通过简单的配置就能接入多种消息平台。本文介绍了:
希望这篇博客能帮助你快速上手 OpenClaw。如果有问题,欢迎在评论区留言交流!
https://openclaw.aihttps://github.com/openclaw/openclawhttps://clawhub.com