OpenClaw 是一个强大的 AI 助手框架,支持多种消息平台(WhatsApp、Telegram、飞书等)、自定义工具和自动化工作流。本文将带你从零开始,在 10 分钟内完成 OpenClaw 的部署和配置。

什么是 OpenClaw?

OpenClaw 是一个开源的 AI 助手运行时,核心特点:

  • 多平台支持 - WhatsApp、Telegram、飞书、Discord 等
  • 工具扩展 - 文件操作、网页搜索、浏览器自动化等
  • 本地部署 - 数据完全掌控,支持私有模型
  • 技能系统 - 模块化扩展,自定义工作流

系统要求

  • Node.js: 24+ 推荐(22 LTS 也支持)
  • 系统: macOS、Linux 或 Windows(WSL2)
  • 内存: 最低 1GB,推荐 2GB+
  • 存储: 约 500MB(不含模型)

检查 Node 版本:

1
2
node --version
# 应显示 v22.16+ 或 v24+

快速安装

方式一:安装脚本(推荐)

macOS / Linux:

1
curl -fsSL https://openclaw.ai/install.sh | bash

Windows (PowerShell):

1
iwr -useb https://openclaw.ai/install.ps1 | iex

安装脚本会自动:

  1. 检测并安装合适的 Node.js 版本
  2. 安装 OpenClaw CLI
  3. 启动配置向导

方式二:npm 手动安装

如果已管理 Node.js 环境:

1
2
npm install -g openclaw@latest
openclaw onboard --install-daemon

注意: 如果遇到 sharp 构建错误(macOS 常见),使用:

1
2
3
4
5
6
7
8
9
10
11
12
13
SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g openclaw@latest
```bash

### 方式三:Docker 部署

适合服务器或隔离环境:

```bash
docker run -d \
--name openclaw \
-p 18789:18789 \
-v openclaw-data:/root/.openclaw \
openclaw/openclaw:latest

访问 http://localhost:18789 查看控制面板。

初始化配置

安装完成后,运行配置向导:

1
openclaw onboard --install-daemon

向导会引导你完成:

  1. 选择 AI 模型 - 支持 OpenAI、Anthropic、智谱、通义千问等
  2. 配置认证 - 输入 API Key
  3. 选择渠道 - WhatsApp、Telegram、飞书等(可跳过)
  4. 安装服务 - 将 Gateway 注册为系统服务

模型推荐

提供商 模型 特点
智谱 AI glm-4 中文优秀,性价比高
通义千问 qwen-plus 长文本处理好
OpenAI gpt-4o 综合能力最强
Anthropic claude-3.5 代码能力强

启动和验证

检查服务状态

1
openclaw gateway status

正常输出应显示服务运行中。

打开控制面板

1
openclaw dashboard

或访问 http://127.0.0.1:18789/

在控制面板中,你可以:

  • 直接对话测试
  • 查看会话历史
  • 配置模型和渠道
  • 管理技能和工具

发送测试消息

如果配置了渠道(如飞书):

1
2
3
openclaw message send \
--target "用户 ID" \
--message "Hello from OpenClaw"

配置渠道(可选)

飞书(Feishu)

  1. 创建飞书应用:https://open.feishu.cn/app
  2. 获取 App ID 和 App Secret
  3. 配置回调 URL:https://你的域名/openclaw/feishu
  4. 添加到配置文件:
1
openclaw config edit

添加配置:

1
2
3
4
channels:
feishu:
appId: cli_xxxxxxxxxxxxx
appSecret: xxxxxxxxxxxxxxx

WhatsApp

  1. 运行:openclaw channels whatsapp setup
  2. 扫描二维码绑定
  3. 完成配置

Telegram

  1. 联系 @BotFather 创建机器人
  2. 获取 Token
  3. 配置:openclaw channels telegram add <token>

使用技能

OpenClaw 支持技能扩展,例如:

查看可用技能

1
ls ~/.openclaw/workspace/skills/

使用技能对话

直接在聊天中说明需求:

  • “帮我写一篇技术博客” → 使用 hexo-blogger 技能
  • “检查天气” → 使用 weather 技能
  • “搜索 GitHub issues” → 使用 gh-issues 技能

创建自定义技能

参考官方文档:技能创建指南

常用命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 查看状态
openclaw status
openclaw gateway status

# 重启服务
openclaw gateway restart

# 查看日志
openclaw gateway logs

# 更新版本
openclaw update

# 打开配置
openclaw config edit

# 查看帮助
openclaw --help

故障排查

Gateway 无法启动

1
2
3
4
5
6
7
8
# 查看详细日志
openclaw gateway logs --follow

# 检查端口占用
lsof -i :18789

# 手动前台运行测试
openclaw gateway --port 18789

模型调用失败

  1. 检查 API Key 是否正确
  2. 验证网络连接
  3. 查看配额限制
1
2
# 测试模型连接
openclaw models test <model-name>

渠道消息不响应

  1. 检查渠道是否启用
  2. 验证回调 URL 配置
  3. 查看渠道日志

进阶配置

自定义工作目录

1
export OPENCLAW_HOME=/path/to/your/workspace

配置文件位置

  • 配置: ~/.openclaw/config.json
  • 工作区: ~/.openclaw/workspace/
  • 日志: ~/.openclaw/logs/

环境变量

变量 说明
OPENCLAW_HOME 自定义根目录
OPENCLAW_STATE_DIR 状态目录
OPENCLAW_CONFIG_PATH 配置文件路径

下一步


参考信息:

  • 当前版本:OpenClaw 2026.3.13
  • Node.js 版本:v24.10.0
  • 文档更新日期:2026-03-21