OpenClaw 实战指南:从零搭建你的 AI 个人助手 原创
如果你想要一个**真正属于自己**的 AI 助手——能管理日程、自动处理邮件、控制智能家居、甚至帮你写代码——OpenClaw 是目前最值得关注的开源方案之一。本文将带你从零开始,搭建一个完整的 OpenClaw 环境,并配置实用的自动化工作流。
一、为什么选择 OpenClaw?
在开始之前,先看看 OpenClaw 与其他 AI 助手框架的对比:
| 特性 | OpenClaw | AutoGPT | LangChain Agents | OpenAI Assistants |
| 开源 | ✅ 完全开源 | ✅ | ✅ | ❌ 闭源 |
| 本地部署 | ✅ | ✅ | ✅ | ❌ |
| 多通道 | ✅ Web/Telegram/Discord/Slack | ❌ | ❌ | ❌ |
| 定时任务 | ✅ 内置 Cron | ❌ | 需额外配置 | ❌ |
| 记忆系统 | ✅ 内置 | ❌ | 需额外配置 | ✅ 有限 |
| 工具系统 | ✅ Skills 插件 | ✅ | ✅ | ✅ 有限 |
| 节点设备 | ✅ iOS/Android/Windows/macOS | ❌ | ❌ | ❌ |
| 安装复杂度 | ⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐ |
**OpenClaw 的核心优势**不在于某个单一功能,而在于**完整性和集成度**——它把 Agent、调度、通道、设备管理整合在一个框架里。
二、快速安装
2.1 Linux 一键安装
curl -fsSL https://openclaw.ai/install.sh | bash
安装完成后,启动 Gateway:
openclaw gateway start
openclaw status
看到 `Runtime: running` 和 `Connectivity probe: ok` 就说明安装成功了。
2.2 macOS 安装
curl -fsSL https://openclaw.ai/install.sh | bash
# 或下载 macOS 原生 App
macOS 用户可以选择**原生 App 模式**(菜单栏运行)或**CLI 模式**。原生 App 的优势在于:
- 系统托盘状态显示
- 通知集成
- 语音唤醒支持
2.3 Windows 安装
推荐使用 **Windows Hub**(原生 WinUI 应用):
- 从 [OpenClaw Releases](https://github.com/openclaw/openclaw/releases) 下载 `OpenClawCompanion-Setup-x64.exe`
- 安装后启动,选择 **Set up locally**(自动创建 WSL Gateway)
- 或选择 **Advanced setup** 连接已有 Gateway
2.4 Docker 部署
docker run -d \
--name openclaw \
-p 18789:18789 \
-v ~/.openclaw:/home/user/.openclaw \
openclaw/openclaw:latest
三、基础配置
3.1 配置模型
OpenClaw 支持多种 LLM 提供商。以配置 DeepSeek 为例:
# 设置 API Key
openclaw config set 'models.providers.deepseek.apiKey' 'sk-your-key-here'
# 设置默认模型
openclaw config set 'agents.defaults.models.default' 'deepseek/deepseek-chat'
支持的提供商包括:
- OpenAI / Anthropic / Google Gemini
- DeepSeek / Qwen / Moonshot
- 任何 OpenAI 兼容接口(vLLM、Ollama、LM Studio 等)
3.2 配置通道
**Telegram 通道:**
openclaw config set 'channels.telegram.accounts[0].botToken' 'your-bot-token'
openclaw config set 'channels.telegram.accounts[0].enabled' true
**Discord 通道:**
openclaw config set 'channels.discord.accounts[0].botToken' 'your-bot-token'
openclaw config set 'channels.discord.accounts[0].enabled' true
3.3 配置心跳(Heartbeat)
心跳机制让 Agent 可以主动检查状态:
# 启用心跳
openclaw config set 'agents.defaults.heartbeat.interval' 1800 # 30分钟
openclaw config set 'agents.defaults.heartbeat.enabled' true
在 `HEARTBEAT.md` 中配置要检查的任务:
# 心跳任务
- 检查邮箱是否有新邮件
- 检查日历是否有即将到来的事件
- 检查服务器状态
四、实战:配置自动化工作流
4.1 定时检查邮件
openclaw cron add \
--name "daily-email-check" \
--schedule '{"kind":"cron","expr":"0 9 * * *","tz":"Asia/Shanghai"}' \
--payload '{"kind":"agentTurn","message":"检查邮箱,汇总今天的重要邮件"}' \
--session-target isolated
4.2 天气提醒
openclaw cron add \
--name "morning-weather" \
--schedule '{"kind":"cron","expr":"30 7 * * *","tz":"Asia/Shanghai"}' \
--payload '{"kind":"agentTurn","message":"查看今天的天气,给出穿衣建议"}' \
--session-target isolated
4.3 周报自动生成
openclaw cron add \
--name "weekly-report" \
--schedule '{"kind":"cron","expr":"0 18 * * 5","tz":"Asia/Shanghai"}' \
--payload '{"kind":"agentTurn","message":"回顾本周的工作,生成周报摘要"}' \
--session-target isolated
4.4 查看和管理定时任务
# 列出所有任务
openclaw cron list
# 查看任务运行历史
openclaw cron runs --id <job-id>
# 删除任务
openclaw cron remove --id <job-id>
五、节点设备配置
OpenClaw 的节点系统允许你将手机、平板、其他电脑作为 Agent 的”感官”。
5.1 连接 Android 节点
- 在 Android 上安装 OpenClaw Companion App
- 打开 App,输入 Gateway 地址和 Token
- 在 Gateway 上审批:
openclaw devices list
openclaw devices approve <request-id>
- 验证连接:
openclaw nodes status
5.2 连接 Windows 节点
Windows Hub 可以注册为节点,提供以下能力:
- **屏幕截图** — Agent 可以查看你的桌面
- **摄像头** — 拍照和录像
- **系统命令** — 在 Windows 上执行脚本
- **通知** — 发送系统通知
5.3 节点命令示例
# 在节点上执行命令
openclaw nodes invoke --node "Windows PC" --command system.run \
--params '{"command":"ipconfig"}'
# 截取节点屏幕
openclaw nodes canvas snapshot --node "Windows PC" --format png
# 发送通知
openclaw nodes notify --node "Windows PC" --title "提醒" --body "会议即将开始"
六、Skills 扩展
Skills 是 OpenClaw 的能力扩展系统。通过安装 Skill,Agent 可以获得新的能力。
6.1 安装 Skill
# 从 ClawHub 搜索
openclaw skillhub search "web search"
# 安装
openclaw skillhub install "web-search"
6.2 常用 Skill 推荐
| Skill | 功能 | 安装命令 |
| web-search | 网络搜索 | `openclaw skillhub install web-search` |
| playwright | 浏览器自动化 | `openclaw skillhub install playwright` |
| telegram | Telegram 机器人 | `openclaw skillhub install telegram` |
| discord | Discord 集成 | `openclaw skillhub install discord` |
| memory-manager | 记忆管理 | `openclaw skillhub install memory-manager` |
| weather | 天气查询 | `openclaw skillhub install weather` |
6.3 创建自定义 Skill
你可以通过 Skill Workshop 创建自己的 Skill:
openclaw skill workshop create \
--name "my-custom-skill" \
--description "自定义技能描述" \
--content "$(cat my-skill.md)"
七、安全最佳实践
7.1 网络配置
✅ 推荐:loopback + SSH Tunnel / Tailscale
❌ 避免:直接暴露 Gateway 到公网
7.2 Token 管理
# 定期轮换 Token
openclaw devices rotate --device <device-id>
# 查看已授权的设备
openclaw devices list
7.3 执行权限控制
# 查看当前审批设置
openclaw approvals get
# 添加允许执行的命令
openclaw approvals allowlist add "/usr/bin/git"
openclaw approvals allowlist add "/usr/bin/curl"
八、常见问题
Q1: Gateway 启动失败?
openclaw doctor --fix
openclaw gateway restart
Q2: 模型调用报错?
# 测试模型连接
openclaw infer model run --model deepseek/deepseek-chat --prompt "hi"
# 检查模型配置
openclaw config get models.providers
Q3: 节点连接不上?
# 检查节点状态
openclaw nodes status
openclaw nodes describe --node <node-id>
# 重新审批
openclaw devices list
openclaw devices approve <request-id>
Q4: 定时任务没触发?
# 检查 Cron 状态
openclaw cron status
# 查看任务运行历史
openclaw cron runs --id <job-id>
九、总结
从零搭建 OpenClaw 只需要几分钟,但它的价值在于**持续使用和优化**:
- ✅ **第一周**:配置基础通道和模型,体验基本对话
- ✅ **第二周**:添加定时任务,实现自动化检查
- ✅ **第三周**:连接节点设备,扩展 Agent 的感知能力
- ✅ **第四周**:安装和创建 Skills,定制专属能力
OpenClaw 不是一个”装完就完事”的工具,而是一个**可以持续进化的个人 AI 基础设施**。投入的时间越多,它就越了解你、越能帮到你。
*本文基于 OpenClaw 2026.6.8 版本编写。*