侧边栏壁纸
博主头像
码农小札

行动起来,活在当下

  • 累计撰写 3 篇文章
  • 累计创建 2 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录
AI

openclaw入门

OpenClaw 入门教程

第一章:初识 OpenClaw

1.1 什么是 OpenClaw

OpenClaw(中文版:openclaw-cn)是一款现代化的自动化助手平台,它将多种消息渠道、AI助手和自动化工具集成在一起。你可以把它理解为:

  • 🤖 你的个人AI助理

  • 📱 多渠道消息管理器

  • ⚡ 自动化任务执行器

  • 🔧 可扩展的平台

1.2 核心组件

┌─────────────────────────────────────┐
│            网关 Gateway             │ ← 核心服务,处理所有通信
├─────────────────────────────────────┤
│           智能体 Agent             │ ← AI助手,执行各种任务
├─────────────────────────────────────┤
│           渠道 Channels            │ ← 消息平台(WhatsApp、Telegram等)
├─────────────────────────────────────┤
│            技能 Skills             │ ← 扩展功能模块
└─────────────────────────────────────┘

第二章:快速开始

2.1 安装验证

# 检查是否安装成功
openclaw-cn --version
# 应显示类似:🦞 Clawdbot-CN 2026.1.31

# 查看帮助
openclaw-cn --help

2.2 三分钟快速体验

  1. 初始化配置

    openclaw-cn onboard

    (或者:openclaw-cn setup

  2. 启动网关

    openclaw-cn gateway run
  3. 测试智能体

    openclaw-cn agent --to +123 --message "你好,测试一下"

第三章:基础操作

3.1 网关管理(重点)

网关是OpenClaw的核心,需要先启动网关才能使用其他功能。

# 方式1:前台运行(适合调试)
openclaw-cn gateway run

# 方式2:后台服务(推荐日常使用)
openclaw-cn gateway install
openclaw-cn gateway start
openclaw-cn gateway status

# 方式3:开发模式(隔离环境)
openclaw-cn --dev gateway run

3.2 消息发送

# 基本格式
openclaw-cn message send --target 目标 --message "消息内容"

# 具体示例
openclaw-cn message send --target +8613812345678 --message "你好,这是一条测试消息"

# 带媒体文件
openclaw-cn message send --target +8613812345678 --message "请看图片" --media photo.jpg

# 指定渠道(如Telegram)
openclaw-cn message send --channel telegram --target @username --message "Hello from Telegram"

3.3 使用智能体

# 简单对话
openclaw-cn agent --to +123 --message "今天天气怎么样"

# 使用不同思考级别
openclaw-cn agent --to +123 --message "分析这个数据" --thinking high

# 直接发送回复到渠道
openclaw-cn agent --to +123 --message "生成报告" --deliver

第四章:渠道配置

4.1 配置 WhatsApp

# 登录WhatsApp(会显示二维码)
openclaw-cn channels login --verbose

# 验证连接
openclaw-cn status

4.2 配置 Telegram

  1. 通过 @BotFather 创建机器人,获取token

  2. 配置到OpenClaw

  3. 向机器人发送消息开始使用

4.3 查看和管理渠道

# 查看所有渠道状态
openclaw-cn status

# 列出可用渠道
openclaw-cn channels list

# 移除渠道
openclaw-cn channels remove whatsapp

第五章:实用场景

5.1 日常提醒

# 设置早上提醒
openclaw-cn cron add --name "morning-reminder" --schedule "0 8 * * *" \
  --command "openclaw-cn message send --target +123 --message '⏰ 早上好,别忘了今日会议!'"

5.2 信息汇总

# 让智能体帮你汇总新闻
openclaw-cn agent --to +123 --message "帮我汇总今天的重要科技新闻"

5.3 自动化工作流

# 结合多个命令实现自动化
# 1. 获取天气
# 2. 整理日程
# 3. 发送每日简报
openclaw-cn agent --to +123 --message "请为我准备今天的每日简报,包含天气、新闻和日程提醒" --deliver

第六章:故障排除

6.1 网关启动问题

# 端口被占用
openclaw-cn gateway --force run

# 查看详细日志
openclaw-cn gateway --verbose run

# 检查网关健康
openclaw-cn gateway health

6.2 渠道连接问题

# 运行健康检查
openclaw-cn doctor

# 查看日志
openclaw-cn logs

# 重启服务
openclaw-cn gateway restart

6.3 智能体问题

# 开启详细日志
openclaw-cn agent --to +123 --message "测试" --verbose on

# 重置配置
openclaw-cn configure

第七章:进阶功能

7.1 技能系统

# 查看可用技能
openclaw-cn skills list

# 技能详情
openclaw-cn skills info BlueBubbles

7.2 定时任务

# 管理定时任务
openclaw-cn cron list
openclaw-cn cron add --name "定时任务名称" --schedule "时间表达式" --command "执行的命令"
openclaw-cn cron remove 任务名称

7.3 网络搜索(需要配置)

# 配置网络搜索API
openclaw-cn configure --section web

# 之后就可以让智能体搜索信息
openclaw-cn agent --to +123 --message "搜索今日热点新闻"

第八章:常用命令速查

功能

命令

示例

初始化

openclaw-cn onboard

新用户必做

启动网关

openclaw-cn gateway start

日常启动

发送消息

openclaw-cn message send --target +123 --message "Hi"

基本操作

智能体对话

openclaw-cn agent --to +123 --message "帮我..."

AI助手

健康检查

openclaw-cn doctor

诊断问题

查看状态

openclaw-cn status

检查连接

查看日志

openclaw-cn logs

排查错误

第九章:最佳实践

9.1 日常使用建议

  1. 先启动网关:网关必须先运行才能使用其他功能

  2. 测试再生产:使用 --dev 模式进行测试

  3. 备份配置:定期备份 %APPDATA%\openclaw-cn\ 文件夹

  4. 版本更新:定期检查更新:npm update -g openclaw-cn

9.2 安全建议

  • 不要将API密钥泄露

  • 配置合适的访问权限

  • 定期更新软件版本

  • 使用强密码

第十章:资源和支持


开始你的第一个项目

项目1:早安提醒系统

# 1. 创建定时任务
openclaw-cn cron add --name "good-morning" --schedule "0 8 * * *" \
  --command "openclaw-cn agent --to +123 --message '早上好!请为我准备今日简报' --deliver"

# 2. 查看任务列表
openclaw-cn cron list

# 3. 立即测试
openclaw-cn cron run good-morning

项目2:信息聚合助手

# 创建智能对话任务
openclaw-cn agent --to +123 --message "请帮我完成以下任务:\n1. 检查我的日程\n2. 汇总重要邮件\n3. 分析新闻热点\n完成后发送汇总报告给我"

结束语

OpenClaw 就像你的数字管家,帮你处理各种日常任务。从简单的消息发送到复杂的自动化工作流,它都能胜任。

第一步openclaw-cn onboard 第二步openclaw-cn gateway start 第三步openclaw-cn message send --target +123 --message "Hello World!"

开启你的自动化之旅吧!


0

评论区