摘要:OpenClaw 是一款开源的多通道 AI 助手网关,支持 Telegram、Discord、Slack、WhatsApp 等数十种消息通道。本文将从实际操作出发,系统梳理 OpenClaw 的 CLI 命令体系,帮助读者快速上手并深入掌握各项功能。
版本 :openclaw@2026.5.6
关键词:OpenClaw, CLI, AI助手, 多通道, 命令行操作

目录
- [前言:什么是 OpenClaw](#前言:什么是 OpenClaw)
- 安装与初始化
- 核心概念速览
- [Gateway 网关管理实操](#Gateway 网关管理实操)
- 通道配置实战
- [Agent 管理与会话操作](#Agent 管理与会话操作)
- 模型与鉴权配置
- 插件与技能管理
- 定时任务与流程自动化
- 设备配对与节点控制
- 运维诊断与故障排查
- 实用工作流示例
- 附录:命令速查表
一、前言:什么是 OpenClaw
1.1 项目简介
OpenClaw 是一个基于 WebSocket Gateway 的本地 AI 助手运行时,它的核心设计理念是:
- 多通道接入:一个 AI 可以同时连接 WhatsApp、Telegram、Discord、Slack 等多个平台
- 多 Agent 隔离:不同场景的对话可以分配给不同的 AI "大脑"
- 插件化扩展:通过插件系统支持各种模型提供商和工具
- 本地优先:数据保存在本地,支持局域网配对和远程控制
1.2 适用场景
| 场景 | 说明 |
|---|---|
| 个人 AI 助手 | 统一接管多个聊天应用的消息 |
| 团队协作 | Slack/Discord 群的智能客服 |
| 自动化工作流 | 定时任务、消息转发、Webhook 集成 |
| 开发测试 | 快速验证 AI 应用的多通道表现 |
二、安装与初始化
2.1 安装 OpenClaw
前置要求:Node.js 22.14.0 或更高版本
bash
# 使用 npm 全局安装
npm install -g openclaw@latest
# 或使用 pnpm(推荐,更快更省空间)
pnpm add -g openclaw@latest
# 或使用 bun
bun add -g openclaw@latest
验证安装:
bash
openclaw --version
# 输出: 2026.5.6
2.2 首次初始化
方式一:交互式引导(推荐新手)
bash
# 完整交互式引导
openclaw onboard
# 快速模式(最少提问)
openclaw onboard --flow quickstart
# 安装后台服务
openclaw onboard --install-daemon
方式二:非交互式自动化部署
bash
# 使用 OpenAI API Key
openclaw onboard --non-interactive \
--auth-choice openai-api-key \
--secret-input-mode ref \
--accept-risk
# 使用 Claude CLI OAuth
openclaw onboard --non-interactive \
--auth-choice openai-codex \
--accept-risk
# 连接到远程 Gateway
openclaw onboard --mode remote \
--remote-url wss://gateway.example.com:18789 \
--remote-token <your-token>
2.3 目录结构解析
初始化完成后,OpenClaw 会在用户目录创建以下结构:
~/.openclaw/
├── openclaw.json # 主配置文件(JSON5 格式)
├── .env # 环境变量
├── workspace/ # 默认 Agent 工作区
│ ├── AGENTS.md # 主提示词注入
│ ├── SOUL.md # 人格定义
│ └── IDENTITY.md # 身份配置
├── agents/ # 多 Agent 配置
│ ├── main/
│ │ ├── agent/
│ │ │ └── auth-profiles.json
│ │ └── sessions/
│ └── work/ # 其他 Agent
├── credentials/ # 通道凭据持久化
│ └── whatsapp/
└── skills/ # 全局共享技能
三、核心概念速览
在深入实操前,先理解几个核心概念:
3.1 Agent(代理)
Agent 是一个独立的 AI "大脑",拥有:
- 独立的工作目录(workspace)
- 独立的模型配置和鉴权
- 独立的会话存储
默认 Agent :main(保留 ID,不可删除)
3.2 Channel(通道)
消息接入的渠道,如:
- 即时通讯:Telegram、Discord、WhatsApp、Slack
- 国内平台:微信(WeChat)、QQ、飞书(Feishu)
- 企业应用:Microsoft Teams、Google Chat
3.3 Binding(绑定)
将入站消息路由到特定 Agent 的规则,按优先级匹配:
peer > parentPeer > guildId+roles > guildId > teamId > accountId > 通道级 > 默认 Agent
3.4 Gateway(网关)
WebSocket 服务端,负责:
- 接收各通道的消息推送
- 协调 Agent 处理对话
- 管理会话状态
四、Gateway 网关管理实操
4.1 前台启动 Gateway
bash
# 基本启动
openclaw gateway
# 指定端口和绑定地址
openclaw gateway --port 18789 --bind lan
# 启用 Token 认证(对外暴露时必需)
openclaw gateway --bind lan --auth token --token <secure-token>
# 使用 Tailscale 暴露(推荐远程访问)
openclaw gateway --bind tailnet --tailscale serve
# 完整调试模式
openclaw gateway --verbose --cli-backend-logs --ws-log compact
4.2 后台服务管理
bash
# 安装为系统服务
openclaw gateway install --port 18789 --token <token>
# 服务控制
openclaw gateway start
openclaw gateway stop
openclaw gateway restart
# 查看状态
openclaw gateway status
openclaw gateway status --deep # 深度扫描系统服务
# 卸载服务
openclaw gateway uninstall
4.3 Gateway 健康检查
bash
# 基础健康检查
openclaw gateway health
# 指定 URL 探测
openclaw gateway health --url wss://gateway.example.com:18789
# 发现局域网内的 Gateway
openclaw gateway discover --timeout 4000
# 调试探测
openclaw gateway probe --json
五、通道配置实战
5.1 通道状态查看
bash
# 列出已配置通道
openclaw channels list
openclaw channels list --json
# 通道健康状态
openclaw channels status
openclaw channels status --probe # 实时探测每个账号
# 通道能力查询
openclaw channels capabilities --channel discord
5.2 Telegram 配置实战
bash
# 从 BotFather 获取 Token 后添加
openclaw channels add --channel telegram \
--token "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
# 多账号配置
openclaw channels add --channel telegram \
--account alerts \
--name "Alerts Bot" \
--token "$TELEGRAM_BOT_TOKEN"
# 登录状态检查
openclaw channels status --probe --channel telegram
5.3 Discord 配置实战
bash
# Bot Token 方式
openclaw channels add --channel discord \
--token "$DISCORD_BOT_TOKEN"
# 多服务器/多账号管理
openclaw channels add --channel discord \
--account work \
--name "Work Server Bot" \
--token "$DISCORD_WORK_BOT_TOKEN"
5.4 WhatsApp 扫码登录
bash
# 首次登录(会显示二维码)
openclaw channels login --channel whatsapp --account personal
# 多账号配置
openclaw channels login --channel whatsapp --account biz
# 登出
openclaw channels logout --channel whatsapp --account personal
5.5 飞书(Feishu)配置
bash
openclaw channels add --channel feishu \
--app-id "cli_xxxxxx" \
--app-secret "$FEISHU_APP_SECRET"
5.6 消息发送实战
bash
# 发送文本消息
openclaw message send --channel telegram \
--target @myusername \
--message "Hello from OpenClaw!"
# 发送带附件的消息
openclaw message send --channel discord \
--target channel:123456789 \
--message "Check this out:" \
--media ./screenshot.png
# 发送投票(Discord)
openclaw message poll --channel discord \
--target channel:123456789 \
--poll-question "Where to eat?" \
--poll-option Pizza \
--poll-option Sushi \
--poll-option Burger \
--poll-multi
# 发送投票(Telegram)
openclaw message poll --channel telegram \
--target @mygroup \
--poll-question "Meeting time?" \
--poll-option "10:00 AM" \
--poll-option "2:00 PM" \
--poll-duration-seconds 3600
六、Agent 管理与会话操作
6.1 查看 Agent 列表
bash
# 列出所有 Agent
openclaw agents list
openclaw agents list --bindings # 显示绑定关系
openclaw agents list --json
6.2 创建新 Agent
bash
# 交互式创建
openclaw agents add coding
# 非交互式完整配置
openclaw agents add work \
--workspace ~/.openclaw/workspace-work \
--model anthropic/claude-sonnet-4-6 \
--agent-dir ~/.openclaw/agents/work/agent \
--bind telegram:ops \
--bind discord:guild-a \
--non-interactive
6.3 绑定管理
bash
# 添加绑定
openclaw agents bind --agent work --bind telegram:ops
openclaw agents bind --agent work --bind discord:guild-a
# 查看绑定
openclaw agents bindings --agent work
# 移除绑定
openclaw agents unbind --agent work --bind telegram:ops
openclaw agents unbind --agent work --all # 移除所有绑定
6.4 发送消息给 Agent
bash
# 基础对话
openclaw agent --message "总结今天的邮件"
# 指定 Agent
openclaw agent --agent ops --message "检查系统状态"
# 指定会话继续对话
openclaw agent --session-id 1234 --message "继续刚才的讨论"
# 控制思考深度
openclaw agent -m "分析这个方案" --thinking high
# 投递到特定通道
openclaw agent --agent ops \
--message "生成报告" \
--deliver \
--reply-channel slack \
--reply-to "#reports"
6.5 会话管理
bash
# 列出会话
openclaw sessions
openclaw sessions --agent work
openclaw sessions --active 120 # 近2小时活跃的会话
openclaw sessions --limit 25
# 会话清理
openclaw sessions cleanup --dry-run
openclaw sessions cleanup --enforce
openclaw sessions cleanup --fix-missing # 修复缺失文件的记录
openclaw sessions cleanup --fix-dm-scope # 修复 DM 范围变更后的孤立会话
# 导出会话轨迹(用于分析或分享)
openclaw sessions export-trajectory \
--session-key "agent:main:telegram:direct:123" \
--output ./my-session-export
6.6 承诺管理(Commitments)
Agent 会推断需要后续跟进的任务:
bash
# 查看待处理的承诺
openclaw commitments
# 查看所有状态
openclaw commitments --all
# 按 Agent 筛选
openclaw commitments --agent work
# 忽略某个承诺
openclaw commitments dismiss cm_abc123
七、模型与鉴权配置
7.1 模型管理
bash
# 查看当前模型状态
openclaw models status
openclaw models status --check # 检查过期/缺失状态
# 列出可用模型
openclaw models list
openclaw models list --provider openai
openclaw models list --all
# 设置默认模型
openclaw models set anthropic/claude-sonnet-4-6
openclaw models set openai/gpt-5.4
# 设置图像生成模型
openclaw models set-image openai/gpt-image-1
7.2 模型别名管理
bash
# 列出别名
openclaw models aliases list
# 添加别名
openclaw models aliases add fast openai/gpt-5.4
openclaw models aliases add smart anthropic/claude-opus-4-6
# 删除别名
openclaw models aliases remove fast
7.3 模型回退链
bash
# 管理主模型失败时的回退链
openclaw models fallbacks list
openclaw models fallbacks add openai/gpt-5.4
openclaw models fallbacks remove openai/gpt-5.4
openclaw models fallbacks clear
# 图像模型回退
openclaw models image-fallbacks list
openclaw models image-fallbacks add openai/gpt-image-1
7.4 鉴权配置
bash
# 列出已保存的鉴权配置
openclaw models auth list
openclaw models auth list --provider openai --json
# 交互式添加鉴权
openclaw models auth add
# 提供商登录
openclaw models auth login --provider openai
openclaw models auth login --provider anthropic --method claude-cli --set-default
# GitHub Copilot 特殊 OAuth
openclaw models auth login-github-copilot --yes
# 手动设置 Token
openclaw models auth setup-token --provider anthropic --yes
openclaw models auth paste-token --provider moonshot \
--profile-id moonshot:manual \
--expires-in 90d
# 管理鉴权优先级(针对特定 Agent)
openclaw models auth order get --provider openai --agent main --json
openclaw models auth order set --provider openai --agent main profile-a profile-b
openclaw models auth order clear --provider openai --agent main
7.5 模型扫描
bash
# 自动扫描并配置推荐模型
openclaw models scan \
--min-params 7 \
--max-age-days 365 \
--provider openai \
--max-candidates 20 \
--timeout 8000 \
--concurrency 4 \
--set-default \
--set-image \
--yes
八、插件与技能管理
8.1 插件管理
bash
# 列出插件
openclaw plugins list
openclaw plugins list --enabled --verbose
# 查看插件详情
openclaw plugins inspect <plugin-id>
openclaw plugins info <plugin-id>
# 从 ClawHub 安装
openclaw plugins install <plugin-id>
openclaw plugins install brave
openclaw plugins install "brave@latest"
# 从本地安装
openclaw plugins install ./local-plugin.tgz
# 启用/禁用
openclaw plugins enable <plugin-id>
openclaw plugins disable <plugin-id>
# 更新
openclaw plugins update <plugin-id>
openclaw plugins update --all
# 卸载
openclaw plugins uninstall <plugin-id>
# 诊断
openclaw plugins doctor
8.2 技能(Skills)管理
bash
# 列出技能
openclaw skills list
openclaw skills list --eligible # 显示可使用的技能
# 搜索技能市场
openclaw skills search "memory"
openclaw skills search "memory" --limit 20 --json
# 安装技能
openclaw skills install <skill-slug>
openclaw skills install memory-manager --version 1.2.3
# 更新
openclaw skills update <skill-slug>
openclaw skills update --all
# 查看详情
openclaw skills info <skill-name>
# 检查依赖
openclaw skills check
8.3 钩子(Hooks)管理
bash
# 列出钩子
openclaw hooks list
openclaw hooks list --eligible
# 启用/禁用
openclaw hooks enable <hook-name>
openclaw hooks disable <hook-name>
# 检查
openclaw hooks check
九、定时任务与流程自动化
9.1 Cron 定时任务
bash
# 查看状态
openclaw cron status
# 列出任务
openclaw cron list --all
openclaw cron list --agent work # 按 Agent 筛选
# 查看单个任务详情
openclaw cron show <job-id>
# 添加 Cron 任务(每天 7 点早报)
openclaw cron add \
--name "Morning Brief" \
--cron "0 7 * * *" \
--session isolated \
--message "总结昨晚到现在的更新" \
--announce \
--channel slack \
--to "channel:C1234567890" \
--light-context
# 添加一次性任务
openclaw cron add \
--name "One-time Alert" \
--at "2026-05-01T12:00" \
--tz "Asia/Shanghai" \
--message "会议提醒" \
--channel telegram \
--to "@me"
# 添加周期性任务
openclaw cron add \
--name "Heartbeat" \
--every "10m" \
--system-event "ping"
# 编辑任务
openclaw cron edit <job-id> --no-deliver
openclaw cron edit <job-id> --light-context
openclaw cron edit <job-id> --agent ops
# 启停控制
openclaw cron enable <job-id>
openclaw cron disable <job-id>
# 删除任务
openclaw cron rm <job-id>
# 手动触发
openclaw cron run <job-id>
openclaw cron run <job-id> --due # 仅在到期时运行
# 查看运行历史
openclaw cron runs --id <job-id> --limit 50
9.2 后台任务管理
bash
# 列出后台任务
openclaw tasks list
openclaw tasks list --runtime subagent # 按类型筛选
openclaw tasks list --status running # 按状态筛选
# 查看任务详情
openclaw tasks show <task-id>
openclaw tasks show <run-id>
openclaw tasks show <session-key>
# 设置通知策略
openclaw tasks notify <id> done_only # 仅完成时通知
openclaw tasks notify <id> state_changes # 状态变化时通知
openclaw tasks notify <id> silent # 静默
# 取消任务
openclaw tasks cancel <id>
# 审计任务
openclaw tasks audit
openclaw tasks audit --severity error
openclaw tasks audit --code stale_running
# 任务维护
openclaw tasks maintenance --dry-run
openclaw tasks maintenance --apply
# 任务流(TaskFlow)管理
openclaw tasks flow list
openclaw tasks flow list --status running
openclaw tasks flow show <flow-id>
openclaw tasks flow cancel <flow-id>
十、设备配对与节点控制
10.1 生成配对二维码
bash
# 本地 Gateway 配对
openclaw qr
# 远程 Gateway 配对
openclaw qr --remote
# 指定 URL
openclaw qr --url wss://gateway.example.com:18789 --token <token>
# 仅输出设置码
openclaw qr --setup-code-only --no-ascii
# JSON 输出
openclaw qr --json
10.2 节点管理
bash
# 列出已配对节点
openclaw nodes list
openclaw nodes list --connected
# 查看节点详情
openclaw nodes describe --node my-phone
# 查看待批准请求
openclaw nodes pending
# 批准/拒绝配对请求
openclaw nodes approve <request-id>
openclaw nodes reject <request-id>
# 重命名节点
openclaw nodes rename --node my-phone --name "iPhone 15 Pro"
# 调用节点命令
openclaw nodes invoke --node my-phone \
--command system.info \
--params '{"foo":1}'
# 发送通知到节点(仅 macOS)
openclaw nodes notify --node macbook \
--title "Alert" \
--body "CPU spike detected" \
--sound default
10.3 相机控制
bash
# 列出相机
openclaw nodes camera list --node phone
# 拍照
openclaw nodes camera snap --node phone \
--facing back \
--quality 0.9 \
--max-width 1200
# 前置摄像头拍照
openclaw nodes camera snap --node phone \
--facing front \
--delay-ms 500
# 录制视频片段
openclaw nodes camera clip --node phone \
--facing back \
--duration 10s \
--no-audio
10.4 Canvas 控制(屏幕共享)
bash
# 截取 Canvas 快照
openclaw nodes canvas snapshot --node mac \
--format png \
--max-width 1600 \
--quality 0.8
# 在节点上显示网页
openclaw nodes canvas present --node mac \
--target https://example.com \
--x 0 --y 0 \
--width 1280 --height 800
# 隐藏 Canvas
openclaw nodes canvas hide --node mac
# 导航到 URL
openclaw nodes canvas navigate https://example.com --node mac
# 执行 JavaScript
openclaw nodes canvas eval --js "document.title" --node mac
# A2UI 推送
openclaw nodes canvas a2ui push --node mac --text "Hello"
openclaw nodes canvas a2ui reset --node mac
10.5 屏幕录制与位置
bash
# 屏幕录制
openclaw nodes screen record --node mac \
--screen 0 \
--duration 30s \
--fps 24 \
--out ./recording.mp4
# 获取位置
openclaw nodes location get --node phone \
--accuracy precise \
--max-age 60000
十一、运维诊断与故障排查
11.1 健康检查
bash
# 快速状态检查
openclaw status
openclaw status --json
# 完整诊断
openclaw status --all
# 深度探测(包括各通道连接状态)
openclaw status --deep
# 显示模型用量
openclaw status --usage
11.2 Gateway 健康
bash
openclaw health
openclaw health --verbose
openclaw health --json
11.3 Doctor 诊断修复
bash
# 基础诊断
openclaw doctor
# 深度扫描
openclaw doctor --deep
# 自动修复
openclaw doctor --fix
openclaw doctor --fix --force # 强制修复(覆盖自定义配置)
# 非交互模式
openclaw doctor --yes --non-interactive
# 生成 Gateway Token
openclaw doctor --generate-gateway-token
11.4 日志查看
bash
# 查看 Gateway 日志
openclaw logs
openclaw logs --follow --interval 500
openclaw logs --limit 200
openclaw logs --local-time --plain
# 通道日志
openclaw channels logs --channel all --lines 200
openclaw channels logs --channel discord --json
11.5 安全审计
bash
# 安全审计
openclaw security audit
openclaw security audit --deep
openclaw security audit --fix
# 密钥审计
openclaw secrets audit
openclaw secrets audit --check
# 配置密钥重载
openclaw secrets reload
# 执行策略查看(新增)
openclaw exec-policy show
openclaw exec-policy preset cautious # 应用谨慎策略
openclaw exec-policy set --security allowlist --ask on-miss
11.6 沙箱管理
bash
# 列出沙箱
openclaw sandbox list
openclaw sandbox list --browser --json
# 重建沙箱
openclaw sandbox recreate --all
openclaw sandbox recreate --session <key>
openclaw sandbox recreate --agent work --browser
# 解释沙箱配置
openclaw sandbox explain --agent work --session main --json
十二、实用工作流示例
12.1 开发环境快速搭建
bash
# 1. 克隆源码
git clone https://github.com/openclaw/openclaw.git
cd openclaw
# 2. 安装依赖
pnpm install
# 3. 构建 UI
pnpm ui:build
# 4. 构建项目
pnpm build
# 5. 开发模式运行
pnpm dev onboard
pnpm gateway:watch # 自动重启的 Gateway
12.2 生产环境部署
bash
# 1. 安装 OpenClaw
npm install -g openclaw@latest
# 2. 初始化配置
openclaw onboard --install-daemon
# 3. 配置 Telegram
export TELEGRAM_BOT_TOKEN="your-bot-token"
openclaw channels add --channel telegram --token "$TELEGRAM_BOT_TOKEN"
# 4. 配置 Discord
export DISCORD_BOT_TOKEN="your-bot-token"
openclaw channels add --channel discord --token "$DISCORD_BOT_TOKEN"
# 5. 创建专用 Agent
openclaw agents add support \
--workspace ~/.openclaw/workspace-support \
--model anthropic/claude-sonnet-4-6 \
--bind telegram:default \
--bind discord:default \
--non-interactive
# 6. 验证状态
openclaw status --deep
openclaw channels status --probe
12.3 定时早报工作流
bash
# 1. 创建早报任务
openclaw cron add \
--name "Daily Morning Brief" \
--cron "0 7 * * 1-5" \
--tz "Asia/Shanghai" \
--session isolated \
--message "请总结昨晚到今天早上的重要更新和待办事项" \
--announce \
--channel slack \
--to "channel:C1234567890" \
--light-context
# 2. 查看任务列表
openclaw cron list
# 3. 手动测试运行
openclaw cron run <job-id>
# 4. 查看运行历史
openclaw cron runs --id <job-id> --limit 10
12.4 多 Agent 协作工作流
bash
# 场景:技术支持团队,不同问题分配给不同 Agent
# 1. 创建技术 Agent
openclaw agents add tech \
--workspace ~/.openclaw/workspace-tech \
--model anthropic/claude-opus-4-6 \
--non-interactive
# 2. 创建业务 Agent
openclaw agents add business \
--workspace ~/.openclaw/workspace-business \
--model openai/gpt-5.4 \
--non-interactive
# 3. 绑定到不同通道/账号
openclaw agents bind --agent tech --bind telegram:tech-support
openclaw agents bind --agent business --bind telegram:sales
# 4. 为特定群组路由
# 在配置文件中添加精确绑定规则
12.5 故障排查工作流
bash
# 1. 发现问题
openclaw status --deep
# 2. 查看日志
openclaw logs --follow &
# 3. 检查通道
openclaw channels status --probe
# 4. 诊断修复
openclaw doctor --deep
openclaw doctor --fix --force
# 5. 重启 Gateway
openclaw gateway restart
# 6. 验证修复
openclaw health --verbose
十三、附录:命令速查表
13.1 核心命令速查
| 命令 | 用途 | 常用选项 |
|---|---|---|
openclaw onboard |
初始化引导 | --install-daemon, --flow quickstart |
openclaw doctor |
诊断修复 | --fix, --deep, --force |
openclaw status |
状态查看 | --deep, --usage, --json |
openclaw gateway |
网关管理 | --port, --bind, --tailscale |
openclaw agent |
Agent 对话 | --agent, --thinking, --deliver |
openclaw agents |
Agent 管理 | list, add, bind, unbind |
openclaw sessions |
会话管理 | cleanup, export-trajectory |
openclaw channels |
通道管理 | add, remove, status |
openclaw message |
消息发送 | send, poll, react |
openclaw models |
模型管理 | set, scan, auth |
openclaw plugins |
插件管理 | install, update, enable |
openclaw cron |
定时任务 | add, edit, run |
openclaw tasks |
后台任务 | list, audit, cancel |
openclaw nodes |
节点控制 | camera, canvas, screen |
openclaw crestodian |
修复助手 | -m, --yes |
13.2 全局选项
| 选项 | 说明 |
|---|---|
--dev |
使用开发配置(~/.openclaw-dev) |
--profile <name> |
使用指定 Profile |
--no-color |
关闭颜色输出 |
--json |
JSON 格式输出 |
--plain |
纯文本输出 |
13.3 环境变量速查
| 变量 | 用途 |
|---|---|
OPENCLAW_GATEWAY_TOKEN |
Gateway 认证 Token |
OPENCLAW_STATE_DIR |
状态目录(默认 ~/.openclaw) |
OPENCLAW_CONFIG_PATH |
配置文件路径 |
OPENAI_API_KEY |
OpenAI API Key |
ANTHROPIC_API_KEY |
Anthropic API Key |
TELEGRAM_BOT_TOKEN |
Telegram Bot Token |
DISCORD_BOT_TOKEN |
Discord Bot Token |
13.4 配置文件示例
json5
// ~/.openclaw/openclaw.json
{
agent: {
model: "anthropic/claude-sonnet-4-6",
default: "main",
},
agents: {
list: [
{ id: "main", name: "Main", default: true },
{ id: "work", name: "Work", workspace: "~/.openclaw/workspace-work" },
],
},
bindings: [
{ agentId: "work", match: { channel: "slack", accountId: "work" } },
],
gateway: {
port: 18789,
bind: "lan",
auth: "token",
},
channels: {
telegram: {
default: {
token: { ref: { source: "env", id: "TELEGRAM_BOT_TOKEN" } },
},
},
},
}
结语
OpenClaw 是一个功能强大且灵活的 AI 助手网关,本文档涵盖了从基础安装到高级配置的完整操作指南。建议读者:
- 新手:从第二章的安装与初始化开始,逐步体验各通道接入
- 开发者:重点关注 Gateway 管理、多 Agent 配置和插件开发
- 运维人员:深入了解诊断命令、日志分析和故障排查
更多高级用法和 API 细节,请参考 OpenClaw 官方文档。