OpenClaw AI 网关与多渠道机器人

精选 OpenClaw 常用指令与核心速查备忘单,涵盖高频用法、配置参数与实用技巧。 OpenClaw is a self-hosted AI gateway that bridges WhatsApp, Telegram, Discord, iMessage, and more to AI coding agents.

#🚀 入门指引

#快速安装与配置 (Quick Setup)

  1. Install
# macOS / Linux / WSL2
curl -fsSL https://openclaw.ai/install.sh | bash
# or via npm
npm install -g openclaw@latest
  1. Onboard & install service
openclaw onboard --install-daemon
  1. Verify the gateway
openclaw gateway status
  1. Open dashboard
openclaw dashboard
# Local default: http://127.0.0.1:18789/

#入门介绍

Self-hosted, MIT licensed, multi-channel

#源码编译安装 (Alternative Install)

# From source
git clone https://github.com/openclaw/openclaw.git
cd openclaw && pnpm install && pnpm build
pnpm link --global

#验证安装环境 (Verify Install)

openclaw --version  # confirm CLI available
openclaw doctor     # health check + fixes
openclaw status     # channels + gateway status

#全局命令行参数 (Global Flags)

参数
--dev Dev profile, port 19001
--profile <name> Named isolated profile
--container <name> Run inside a container
--log-level <l> Log level (silent…trace)
--no-color Disable ANSI colors

#Gateway 网关服务 (Gateway)

#服务管理 (Service Management)

# Install as system service
openclaw gateway install
# Start / stop / restart
openclaw gateway start
openclaw gateway stop
openclaw gateway restart
# Uninstall service
openclaw gateway uninstall

Status & health

openclaw gateway status       # service status + probe
openclaw gateway status --deep
openclaw gateway status --json
openclaw health               # fetch health from gateway
openclaw logs --follow        # tail gateway logs

#启动参数选项 (Startup Options)

openclaw gateway run             # foreground
openclaw gateway run --port 19001
openclaw gateway run --强制执行     # kill existing listener
openclaw gateway run --verbose   # verbose to stdout
openclaw gateway run --bind lan  # bind to LAN
openclaw gateway run --auth token --token <t>

#热重载模式 (Hot Reload Modes)

gateway.reload.mode Behavior
hybrid (default) Hot-apply safe changes, restart when needed
hot Apply only hot-safe changes
restart Restart on any reload-必填 change
off No config reload

#远程访问配置 (Remote Access)

# SSH tunnel (recommended fallback)
ssh -N -L 18789:127.0.0.1:18789 user@host
# then connect to ws://127.0.0.1:18789

# Tailscale (preferred for always-on)
openclaw gateway run --tailscale serve

#兼容 OpenAI 的 API 端点

Endpoint Purpose
GET /v1/models List agents as models
POST /v1/chat/completions Chat with agent
POST /v1/responses Agent-native response
POST /v1/embeddings Embedding pipeline

All endpoints run on the main gateway port.

#Channels 消息渠道 (Channels)

#连接渠道 (Connect Channels)

# List + status
openclaw channels list
openclaw channels status
openclaw channels status --probe

# Login (QR/OAuth flow)
openclaw channels login --channel whatsapp
openclaw channels login --channel telegram

# Add with token (non-interactive)
openclaw channels add \
  --channel telegram --token <BOT_TOKEN>

# Logout / remove
openclaw channels logout --channel whatsapp
openclaw channels remove --channel telegram

# Logs + capabilities
openclaw channels logs
openclaw channels capabilities

Resolve contact IDs

openclaw directory self --channel telegram
openclaw directory peers list --channel slack
openclaw directory groups list --channel discord

#官方支持渠道 (Supported Channels)

Built-in

Channel Notes
WhatsApp QR pairing via Baileys
Telegram Bot API — fastest to set up
Discord Bot API + Gateway, DMs + servers
BlueBubbles iMessage via macOS server
Signal Via signal-cli
Slack Bolt SDK workspace apps
Google Chat HTTP webhook
IRC Classic IRC, DMs + channels
QQ Bot QQ Bot API
WebChat Built-in browser chat UI

Via plugin (openclaw plugins install)

  • Matrix
  • Mattermost
  • Microsoft Teams
  • LINE
  • Nextcloud Talk
  • Feishu / Lark
  • Nostr
  • Synology Chat
  • Twitch
  • WeChat
  • Zalo / Zalo Personal
  • Voice Call (Plivo/Twilio)

#消息收发 (Messaging)

#发送消息 (Send Messages)

# Basic text
openclaw message send \
  --target +15555550123 --message "Hello"

# Telegram by username
openclaw message send \
  --channel telegram --target @user \
  --message "Hello"

# Discord channel
openclaw message send \
  --channel discord --target channel:123 \
  --message "Hello"

# With media
openclaw message send \
  --target +15555550123 \
  --media photo.jpg --message "Look"

# Silent (no notification)
openclaw message send \
  --target +15555550123 \
  --message "Quiet" --silent

# Reply to a message
openclaw message send \
  --target +15555550123 \
  --message "Reply" --reply-to <msg-id>

#读取消息 (Read Messages)

openclaw message read \
  --channel whatsapp --target +15555550123

openclaw message read \
  --channel discord --target channel:123 \
  --limit 20 --json

#消息高级操作 (Message Actions)

# Broadcast to multiple targets
openclaw message broadcast \
  --message "Alert" --targets @u1 @u2

# React to a message
openclaw message react \
  --channel discord --target 123 \
  --message-id 456 --emoji "✅"

# Pin / unpin
openclaw message pin \
  --channel discord --target 123 \
  --message-id 456

# Edit / delete
openclaw message edit --message-id 456
openclaw message delete --message-id 456

#Agents 代理与会话 (Agents & Sessions)

#运行 AI Agent (Run Agent)

# New session
openclaw agent \
  --to +15555550123 --message "Hello"

# Named agent
openclaw agent \
  --agent ops --message "Status"

# With thinking level
openclaw agent \
  --to +15555550123 \
  --message "Analyze" --thinking high

# Deliver reply back to channel
openclaw agent \
  --to +15555550123 \
  --message "Summary" --deliver

# Cross-channel delivery
openclaw agent \
  --agent ops --message "Report" \
  --deliver \
  --reply-channel slack \
  --reply-to "#reports"

# JSON output + verbose
openclaw agent \
  --to +15555550123 \
  --message "Trace" --verbose on --json

#管理 Agents (Manage Agents)

openclaw agents list
openclaw agents list --bindings
openclaw agents add work
openclaw agents delete work
openclaw agents bind
openclaw agents unbind
openclaw agents bindings
openclaw agents set-identity \
  --agent work --name "Work Bot"

#会话会话控制 (Sessions)

openclaw sessions              # all sessions
openclaw sessions --agent work
openclaw sessions --all-agents
openclaw sessions --active 120 # last 2h
openclaw sessions --json
openclaw sessions cleanup

#路由匹配优先级 (Routing Priority)

Priority Match type
1 (highest) peer — exact DM/group/channel ID
2 parentPeer — thread inheritance
3 guildId + roles (Discord)
4 guildId (Discord)
5 teamId (Slack)
6 accountId match for channel
7 accountId: "*" channel fallback
8 (lowest) Default agent

#模型配置 (Models)

#配置 AI 模型 (Configure Models)

# Set primary model
openclaw models set anthropic/claude-sonnet-4-6

# Set image model
openclaw models set-image openai/dall-e-3

# List models
openclaw models list            # configured
openclaw models list --all      # full catalog
openclaw models list --provider anthropic

# Status (auth + model overview)
openclaw models status
openclaw models status --check  # exit 1 if missing

# Aliases
openclaw models aliases list
openclaw models aliases add Sonnet \
  anthropic/claude-sonnet-4-6
openclaw models aliases remove Sonnet

# Fallback chains
openclaw models fallbacks list
openclaw models fallbacks add anthropic/claude-haiku-4-5
openclaw models fallbacks clear

#聊天内快捷切换 /model

/model             # interactive picker
/model list        # numbered model list
/model 3           # select by number
/model openai/gpt-4o
/model status      # auth + provider details

Switch takes effect on the next agent run.

#模型自动扫描 (Model Scan)

# Scan free models (metadata only)
openclaw models scan --no-probe

# Full scan with capability probe
openclaw models scan \
  --min-params 7 --max-age-days 30

# Auto-set best free model
openclaw models scan \
  --set-default --yes

Requires OPENROUTER_API_KEY for probing.

#配置与环境变量 (Config & Environment)

#配置查看与修改 (Config Commands)

# Show config file path
openclaw config file

# Get a value
openclaw config get gateway.port
openclaw config get channels.telegram.botToken

# Set a value
openclaw config set gateway.port 19001
openclaw config set \
  agents.defaults.model.primary \
  anthropic/claude-sonnet-4-6

# Unset a value
openclaw config unset gateway.port

# Validate config
openclaw config validate

# Print JSON schema
openclaw config schema

# Interactive guided setup
openclaw configure

#核心环境变量 (Environment Variables)

Variable Description
OPENCLAW_GATEWAY_PORT Gateway port
OPENCLAW_GATEWAY_TOKEN Auth token
OPENCLAW_GATEWAY_PASSWORD Auth password
OPENCLAW_CONFIG_PATH Config file path
OPENCLAW_STATE_DIR State directory
OPENCLAW_PROFILE Active profile name
OPENCLAW_CONTAINER Default container name

#默认存储路径 (Default Paths)

Path Description
~/.openclaw/openclaw.json Main config
~/.openclaw/ State directory
~/.openclaw/workspace Agent workspace
~/.openclaw/agents/<id>/agent Agent auth + models
~/.openclaw/agents/<id>/sessions Session store
~/.openclaw/credentials/ Channel credentials
~/.openclaw/skills/ Shared skills

#记忆与备份恢复 (Memory & Backup)

openclaw memory status
openclaw memory status --deep   # probe embedding
openclaw memory index --强制执行   # full reindex
openclaw memory search "notes"
openclaw memory search \
  --query "deploy" --max-results 20
openclaw memory status --json

#备份与数据恢复 (Backup & Restore)

# Create backup archive
openclaw backup create

# Verify backup integrity
openclaw backup verify backup.tar.gz

Backs up: config, credentials, sessions, workspaces.

#重置与版本更新 (Reset & Update)

# Reset config + state (keeps CLI)
openclaw reset

# Update to latest
openclaw update
openclaw update --channel beta
openclaw update --channel dev
openclaw update --dry-run

# Full uninstall
openclaw uninstall

#插件与 Skill 扩展 (Plugins & Skills)

#插件管理命令 (Plugin Commands)

# Discover + inspect
openclaw plugins list
openclaw plugins inspect <name>
openclaw plugins marketplace

# Install (path / npm / clawhub)
openclaw plugins install clawhub:mattermost
openclaw plugins install ./my-plugin
openclaw plugins install @org/pkg@latest

# Enable / disable
openclaw plugins enable <name>
openclaw plugins disable <name>

# Update + uninstall
openclaw plugins update
openclaw plugins uninstall <name>

# Diagnose load issues
openclaw plugins doctor

#Skill 技能管理 (Skill Commands)

openclaw skills list
openclaw skills check      # readiness check
openclaw skills info <name>
openclaw skills search "browser"
openclaw skills install clawhub:browser
openclaw skills update

#Hook 钩子函数 (Hook Commands)

openclaw hooks list
openclaw hooks info <name>
openclaw hooks check
openclaw hooks enable <name>
openclaw hooks disable <name>

#运维与监控维护 (Ops & Maintenance)

#健康检查与诊断 (Health & Diagnostics)

# Quick health checks
openclaw health               # gateway health
openclaw doctor               # check + suggest fixes
openclaw doctor --fix         # apply safe fixes
openclaw status               # channels + sessions
openclaw logs --follow        # tail log file

# Channel readiness
openclaw channels status --probe

# Gateway probe (full)
openclaw gateway probe
openclaw gateway status --deep --json

# Security audit
openclaw security audit
openclaw security audit --deep
openclaw security audit --fix
openclaw security audit --json

#Cron 定时任务 (Cron Jobs)

openclaw cron list
openclaw cron status

# Add job (every / cron / at)
openclaw cron add \
  --name "daily" \
  --every 24h \
  --message "Daily summary" \
  --agent main --announce

openclaw cron add \
  --cron "0 9 * * *" \
  --message "Morning brief" \
  --tz America/New_York

openclaw cron enable <id>
openclaw cron disable <id>
openclaw cron edit <id>
openclaw cron rm <id>
openclaw cron run <id>   # debug: run now
openclaw cron runs       # run history

#Nodes (iOS/Android)

# List + status
openclaw nodes list
openclaw nodes status

# Pairing
openclaw qr                        # iOS QR code
openclaw nodes pending
openclaw nodes approve --node <id>
openclaw nodes reject  --node <id>

# Media capture
openclaw nodes camera snap --node <id>
openclaw nodes canvas  --node <id>
openclaw nodes screen  --node <id>
openclaw nodes location --node <id>

# Invoke + notify
openclaw nodes invoke \
  --node <id> \
  --command system.which \
  --params '{"name":"uname"}'
openclaw nodes notify \
  --node <id> --message "Hello"

#安全防护与权限 (Security Controls)

# DM pairing
openclaw pairing list
openclaw pairing approve <code>

# Exec approvals
openclaw approvals get
openclaw approvals allowlist
openclaw approvals set --file approvals.json

# Device tokens
openclaw devices list
openclaw devices revoke --role admin
openclaw devices rotate --role admin

#多 Agent 配置示例 (Multi-agent Config)

{
  "agents": {
    "list": [
      {
        "id": "chat",
        "workspace": "~/.openclaw/workspace-chat",
        "model": "anthropic/claude-sonnet-4-6"
      },
      {
        "id": "work",
        "workspace": "~/.openclaw/workspace-work",
        "model": "anthropic/claude-opus-4-6"
      }
    ]
  },
  "bindings": [
    { "agentId": "chat", "match": { "channel": "whatsapp" } },
    { "agentId": "work", "match": { "channel": "telegram" } }
  ],
  "channels": {
    "whatsapp": { "dmPolicy": "pairing" },
    "telegram": { "accounts": { "default": { "botToken": "TOKEN" } } }
  },
  "gateway": { "port": 18789, "bind": "loopback" }
}

Config lives at ~/.openclaw/openclaw.json (JSON5 format)

#🔗 参考资源