常用场景
以下是常见的使用场景,每个附带可参考的配置片段。所有配置写入 ~/.openclaw/openclaw.json(JSON5 格式)。
多渠道 AI 助手
一个 Gateway 同时服务 WhatsApp、Telegram、Discord 等渠道。从任何聊天应用发消息,获得同一个 AI Agent 的响应。
openclaw.json
// ~/.openclaw/openclaw.json
{
agents: { defaults: { workspace: "~/.openclaw/workspace" } },
channels: {
whatsapp: {
allowFrom: ["+86138xxxx0000"],
},
telegram: {
enabled: true,
botToken: "123456:ABC-DEF...",
dmPolicy: "pairing",
},
discord: {
enabled: true,
token: "DISCORD_BOT_TOKEN",
},
},
}多 Agent 路由(工作 / 生活分离)
按渠道或帐号将消息路由到不同 Agent,各有独立工作区、人格和会话。适合一台服务器服务多个场景。
openclaw.json
{
agents: {
list: [
{
id: "chat",
name: "日常",
workspace: "~/.openclaw/workspace-chat",
model: "anthropic/claude-sonnet-4-5",
},
{
id: "opus",
name: "深度工作",
workspace: "~/.openclaw/workspace-opus",
model: "anthropic/claude-opus-4-6",
},
],
},
bindings: [
{ agentId: "chat", match: { channel: "whatsapp" } },
{ agentId: "opus", match: { channel: "telegram" } },
],
}Heartbeat 定时任务
配置 Agent 定期自动检查(Heartbeat),可用于每日摘要、提醒、数据监控等周期性任务。
openclaw.json
{
agents: {
defaults: {
heartbeat: {
every: "2h", // 每 2 小时触发一次
target: "whatsapp", // 发送到 WhatsApp
},
},
},
}Cron 定时任务
通过 cron 配置定时执行的自动化任务,支持并发控制和会话保留策略。
openclaw.json
{
cron: {
enabled: true,
maxConcurrentRuns: 2,
sessionRetention: "24h",
},
}Webhook 集成
通过 HTTP Webhook 将外部事件(Gmail、GitHub、自定义服务)接入 Agent 处理。
openclaw.json
{
hooks: {
enabled: true,
token: "shared-secret",
path: "/hooks",
mappings: [
{
match: { path: "gmail" },
action: "agent",
agentId: "main",
deliver: true,
},
],
},
}群聊 Agent
在 WhatsApp / Discord 群中部署 Agent,通过 @提及激活,可配置独立沙箱和工具策略。
openclaw.json
{
agents: {
list: [{
id: "family",
workspace: "~/.openclaw/workspace-family",
groupChat: {
mentionPatterns: ["@family", "@familybot"],
},
sandbox: { mode: "all", scope: "agent" },
tools: {
allow: ["read", "exec"],
deny: ["write", "edit", "apply_patch"],
},
}],
},
bindings: [{
agentId: "family",
match: {
channel: "whatsapp",
peer: { kind: "group", id: "120363...@g.us" },
},
}],
}