将 OpenClaw 配置为个人 AI 助手的完整指南,以 WhatsApp 专用号码为例。

安全须知

Agent 可能会:

  • 在你的机器上运行命令(取决于工具策略)
  • 读写工作区文件
  • 通过 WhatsApp/Telegram/Discord 等发送消息

保守起步:

  • 始终设置 channels.whatsapp.allowFrom(不要对外开放)
  • 使用专用 WhatsApp 号码
  • 初期禁用 Heartbeat:agents.defaults.heartbeat.every: "0m"

推荐的双手机方案

你的手机(个人 WhatsApp)→ 助手手机(专用 WhatsApp)→ 你的 Mac(OpenClaw)

5 分钟快速启动

# 1. 配对 WhatsApp Web(扫描 QR 码)
openclaw channels login
 
# 2. 启动 Gateway
openclaw gateway --port 18789

最小配置(~/.openclaw/openclaw.json):

{
  gateway: { mode: "local" },
  channels: { whatsapp: { allowFrom: ["+15555550123"] } },
}

工作区配置

OpenClaw 默认使用 ~/.openclaw/workspace 作为 Agent 工作区,自动创建:

  • AGENTS.md、SOUL.md、TOOLS.md、IDENTITY.md、USER.md、HEARTBEAT.md
openclaw setup

推荐配置示例

{
  agents: {
    defaults: {
      model: { primary: "anthropic/claude-opus-4-6" },
      workspace: "~/.openclaw/workspace",
      thinkingDefault: "high",
      timeoutSeconds: 1800,
      heartbeat: { every: "0m" },  // 初期禁用
    },
  },
  channels: {
    whatsapp: {
      allowFrom: ["+15555550123"],
      groups: { "*": { requireMention: true } },
    },
  },
  session: {
    scope: "per-sender",
    resetTriggers: ["/new", "/reset"],
    reset: { mode: "daily", atHour: 4, idleMinutes: 10080 },
  },
}

Heartbeat(主动模式)

默认每 30 分钟运行一次,提示词: Read HEARTBEAT.md if it exists. Follow it strictly. If nothing needs attention, reply HEARTBEAT_OK.

  • HEARTBEAT.md 为空时自动跳过
  • Agent 回复 HEARTBEAT_OK 时抑制外发投递

媒体收发

入站模板变量:{{MediaPath}}、{{MediaUrl}}、{{Transcript}}

出站格式(每行独立):

MEDIA:https://example.com/screenshot.png

运维命令

openclaw status          # 本地状态快照
openclaw status --all    # 完整诊断
openclaw status --deep   # 实时 Gateway 健康探测
openclaw health --json   # Gateway 健康快照

日志位于 /tmp/openclaw/(默认:openclaw-YYYY-MM-DD.log)

相关链接

  • start-quickstart — 快速启动
  • docs/gateway/heartbeat — Heartbeat 详细配置