配置
OpenClaw 通过 ~/.openclaw/openclaw.json 下的 JSON5 文件进行配置。
最小配置 (推荐起点)
Section titled “最小配置 (推荐起点)”{ // "agents" 定义所有代理的默认值 agents: { defaults: { // 代理保存其记忆和技能的位置 workspace: "~/.openclaw/workspace" } }, // "channels" 定义世界如何与 Gateway 对话 channels: { // 示例:启用 Telegram telegram: { enabled: true, botToken: "123:abc...", dmPolicy: "pairing" } }}一个简单的设置,启用 Telegram 和自定义工作区。
{ // 全局设置 agents: { defaults: { workspace: "~/.openclaw/workspace" } }, // 频道配置 channels: { telegram: { enabled: true, botToken: "YOUR_TOKEN", dmPolicy: "pairing" } }}一个更完整的配置,包含多个频道和网络工具。
{ gateway: { port: 18789 }, agents: { defaults: { workspace: "~/.openclaw/workspace", model: { primary: "anthropic/claude-3-5-sonnet" } } }, channels: { whatsapp: { enabled: true, dmPolicy: "allowlist", allowFrom: ["+15551234567"] }, telegram: { enabled: true, botToken: "YOUR_TOKEN", groups: { "*": { requireMention: true } } } }, tools: { web: { search: { enabled: true, provider: "brave" } } }}你不需要总是手动编辑文件。
- 检查配置:
openclaw doctor - 应用更改:
openclaw config apply(重启 Gateway) - 获取值:
openclaw config get channels.telegram.enabled - 设置值:
openclaw config set channels.telegram.enabled true
Gateway 强制执行严格的架构。如果你的配置无效:
- Gateway 将 拒绝启动。
- 运行
openclaw doctor查看错误。 - 手动修复错误或使用
openclaw doctor --fix。