不是你去找信息,而是信息来找你——Webhook 就是那个"送货上门"的机制。
Webhook Integration 是一种事件驱动的通信模式,允许外部系统在特定事件发生时主动向 OpenClaw Agent 推送通知。与轮询(Polling)不同,Webhook 是实时的、被动的——有事才叫你。
| 特性 | Webhook | Polling |
|---|---|---|
| 实时性 | ✅ 实时推送 | ❌ 有延迟 |
| 资源消耗 | ✅ 低(有事件才触发) | ❌ 高(持续轮询) |
| 实现复杂度 | 中等 | 简单 |
| 适用场景 | 事件驱动 | 状态检查 |
// Cron 任务的 Webhook 投递配置
{
"delivery": {
"mode": "webhook",
"to": "https://your-server.com/webhook"
}
}
// 完整的 Cron Job 配置
{
"name": "daily-report-webhook",
"schedule": { "kind": "cron", "expr": "0 8 * * *" },
"payload": { "kind": "agentTurn", "message": "生成日报" },
"delivery": {
"mode": "webhook",
"to": "https://api.example.com/report"
}
}
外部系统 OpenClaw Gateway
│ │
│ 1. 事件发生 │
│ ─────────────────────────► │
│ POST /webhook │
│ {event: "data"} │
│ │
│ 2. Gateway 处理事件 │
│ → 触发 Agent │
│ → 执行任务 │
│ │
│ 3. 返回结果 │
│ ◄───────────────────────── │
│ 200 OK {result: "..."} │
当 GitHub 仓库有新的 PR、Issue 或 Push 时,自动通知 Agent 处理。
接收消息、审批、日程等事件,自动触发 Agent 响应。
构建完成、部署成功等事件触发 Agent 发送通知或执行后续任务。