Please enable Javascript to view the contents

如何远程给OpenClaw发送消息

 ·  ☕ 1 分钟

1. 配置 hooks

  • 在 openclaw.json 中配置 hooks
1
2
3
4
5
6
7
  "hooks": {
    "enabled": true,
    "token": "xxx",
    "path": "/openclaw/hooks",
    "allowRequestSessionKey": true,
    "allowedAgentIds": ["*"]
  },

参考 https://docs.openclaw.ai/automation/webhook

这里的 token 不能与 gateway 的 token 相同。

2. 发送消息

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
curl --location 'https://xxx.com/openclaw/hooks/agent' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxx' \
--data '{
  "message": "介绍下自己,将消息发送到 https://xxx.com/api/v1/webhook/send?key=xxx",
  "agentId": "main",
  "sessionKey": "hooks-api-002",
  "wakeMode": "now",
  "deliver": true,
  "thinking": "low",
  "timeoutSeconds": 120
}'

由于以上请求是异步的,响应中只有 runId,但又没有接口查询结果,所以让 OpenClaw 将结果发送到指定的 webhook 地址。


微信公众号
作者
微信公众号