{"id":15,"date":"2026-03-21T22:47:13","date_gmt":"2026-03-21T14:47:13","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/automation-webhook\/"},"modified":"2026-03-21T23:08:56","modified_gmt":"2026-03-21T15:08:56","slug":"automation-webhook","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/automation-webhook\/","title":{"rendered":"Webhooks"},"content":{"rendered":"<h1>Webhooks<\/h1>\n<p>Gateway \u7f51\u5173\u53ef\u4ee5\u66b4\u9732\u4e00\u4e2a\u5c0f\u578b HTTP webhook \u7aef\u70b9\u7528\u4e8e\u5916\u90e8\u89e6\u53d1\u3002<\/p>\n<h2>\u542f\u7528<\/h2>\n<p>&#8220;`json5  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n{<br \/>\n  hooks: {<br \/>\n    enabled: true,<br \/>\n    token: &#8220;shared-secret&#8221;,<br \/>\n    path: &#8220;\/hooks&#8221;,<br \/>\n  },<br \/>\n}<\/p>\n<pre><code>\n\u6ce8\u610f\u4e8b\u9879\uff1a\n\n* \u5f53 `hooks.enabled=true` \u65f6\uff0c`hooks.token` \u4e3a\u5fc5\u586b\u9879\u3002\n* `hooks.path` \u9ed8\u8ba4\u4e3a `\/hooks`\u3002\n\n## \u8ba4\u8bc1\n\n\u6bcf\u4e2a\u8bf7\u6c42\u5fc5\u987b\u5305\u542b hook \u4ee4\u724c\u3002\u63a8\u8350\u4f7f\u7528\u8bf7\u6c42\u5934\uff1a\n\n* `Authorization: Bearer &lt;token&gt;`\uff08\u63a8\u8350\uff09\n* `x-openclaw-token: &lt;token&gt;`\n* `?token=&lt;token&gt;`\uff08\u5df2\u5f03\u7528\uff1b\u4f1a\u8bb0\u5f55\u8b66\u544a\u65e5\u5fd7\uff0c\u5c06\u5728\u672a\u6765\u7684\u4e3b\u8981\u7248\u672c\u4e2d\u79fb\u9664\uff09\n\n## \u7aef\u70b9\n\n### `POST \/hooks\/wake`\n\n\u8bf7\u6c42\u4f53\uff1a\n\n```json  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{ &quot;text&quot;: &quot;System line&quot;, &quot;mode&quot;: &quot;now&quot; }\n<\/code><\/pre>\n<ul>\n<li><code>text<\/code> <strong>\u5fc5\u586b<\/strong>\uff08\u5b57\u7b26\u4e32\uff09\uff1a\u4e8b\u4ef6\u63cf\u8ff0\uff08\u4f8b\u5982&#8221;\u6536\u5230\u65b0\u90ae\u4ef6&#8221;\uff09\u3002<\/li>\n<li><code>mode<\/code> \u53ef\u9009\uff08<code>now<\/code> | <code>next-heartbeat<\/code>\uff09\uff1a\u662f\u5426\u7acb\u5373\u89e6\u53d1\u5fc3\u8df3\uff08\u9ed8\u8ba4 <code>now<\/code>\uff09\u6216\u7b49\u5f85\u4e0b\u4e00\u6b21\u5b9a\u671f\u68c0\u67e5\u3002<\/li>\n<\/ul>\n<p>\u6548\u679c\uff1a<\/p>\n<ul>\n<li>\u4e3a<strong>\u4e3b<\/strong>\u4f1a\u8bdd\u52a0\u5165\u4e00\u4e2a\u7cfb\u7edf\u4e8b\u4ef6\u961f\u5217<\/li>\n<li>\u5982\u679c <code>mode=now<\/code>\uff0c\u5219\u7acb\u5373\u89e6\u53d1\u5fc3\u8df3<\/li>\n<\/ul>\n<h3><code>POST \/hooks\/agent<\/code><\/h3>\n<p>\u8bf7\u6c42\u4f53\uff1a<\/p>\n<p>&#8220;`json  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\n{<br \/>\n  &#8220;message&#8221;: &#8220;Run this&#8221;,<br \/>\n  &#8220;name&#8221;: &#8220;Email&#8221;,<br \/>\n  &#8220;sessionKey&#8221;: &#8220;hook:email:msg-123&#8221;,<br \/>\n  &#8220;wakeMode&#8221;: &#8220;now&#8221;,<br \/>\n  &#8220;deliver&#8221;: true,<br \/>\n  &#8220;channel&#8221;: &#8220;last&#8221;,<br \/>\n  &#8220;to&#8221;: &#8220;+15551234567&#8221;,<br \/>\n  &#8220;model&#8221;: &#8220;openai\/gpt-5.2-mini&#8221;,<br \/>\n  &#8220;thinking&#8221;: &#8220;low&#8221;,<br \/>\n  &#8220;timeoutSeconds&#8221;: 120<br \/>\n}<\/p>\n<pre><code>\n* `message` **\u5fc5\u586b**\uff08\u5b57\u7b26\u4e32\uff09\uff1a\u667a\u80fd\u4f53\u8981\u5904\u7406\u7684\u63d0\u793a\u6216\u6d88\u606f\u3002\n* `name` \u53ef\u9009\uff08\u5b57\u7b26\u4e32\uff09\uff1ahook \u7684\u53ef\u8bfb\u540d\u79f0\uff08\u4f8b\u5982&quot;GitHub&quot;\uff09\uff0c\u7528\u4f5c\u4f1a\u8bdd\u6458\u8981\u7684\u524d\u7f00\u3002\n* `sessionKey` \u53ef\u9009\uff08\u5b57\u7b26\u4e32\uff09\uff1a\u7528\u4e8e\u6807\u8bc6\u667a\u80fd\u4f53\u4f1a\u8bdd\u7684\u952e\u3002\u9ed8\u8ba4\u4e3a\u968f\u673a\u7684 `hook:&lt;uuid&gt;`\u3002\u4f7f\u7528\u4e00\u81f4\u7684\u952e\u53ef\u4ee5\u5728 hook \u4e0a\u4e0b\u6587\u4e2d\u8fdb\u884c\u591a\u8f6e\u5bf9\u8bdd\u3002\n* `wakeMode` \u53ef\u9009\uff08`now` | `next-heartbeat`\uff09\uff1a\u662f\u5426\u7acb\u5373\u89e6\u53d1\u5fc3\u8df3\uff08\u9ed8\u8ba4 `now`\uff09\u6216\u7b49\u5f85\u4e0b\u4e00\u6b21\u5b9a\u671f\u68c0\u67e5\u3002\n* `deliver` \u53ef\u9009\uff08\u5e03\u5c14\u503c\uff09\uff1a\u5982\u679c\u4e3a `true`\uff0c\u667a\u80fd\u4f53\u7684\u54cd\u5e94\u5c06\u53d1\u9001\u5230\u6d88\u606f\u6e20\u9053\u3002\u9ed8\u8ba4\u4e3a `true`\u3002\u4ec5\u4e3a\u5fc3\u8df3\u786e\u8ba4\u7684\u54cd\u5e94\u4f1a\u81ea\u52a8\u8df3\u8fc7\u3002\n* `channel` \u53ef\u9009\uff08\u5b57\u7b26\u4e32\uff09\uff1a\u7528\u4e8e\u6295\u9012\u7684\u6d88\u606f\u6e20\u9053\u3002\u53ef\u9009\u503c\uff1a`last`\u3001`whatsapp`\u3001`telegram`\u3001`discord`\u3001`slack`\u3001`mattermost`\uff08\u63d2\u4ef6\uff09\u3001`signal`\u3001`imessage`\u3001`msteams`\u3002\u9ed8\u8ba4\u4e3a `last`\u3002\n* `to` \u53ef\u9009\uff08\u5b57\u7b26\u4e32\uff09\uff1a\u6e20\u9053\u7684\u63a5\u6536\u8005\u6807\u8bc6\u7b26\uff08\u4f8b\u5982 WhatsApp\/Signal \u7684\u7535\u8bdd\u53f7\u7801\u3001Telegram \u7684\u804a\u5929 ID\u3001Discord\/Slack\/Mattermost\uff08\u63d2\u4ef6\uff09\u7684\u9891\u9053 ID\u3001MS Teams \u7684\u4f1a\u8bdd ID\uff09\u3002\u9ed8\u8ba4\u4e3a\u4e3b\u4f1a\u8bdd\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u63a5\u6536\u8005\u3002\n* `model` \u53ef\u9009\uff08\u5b57\u7b26\u4e32\uff09\uff1a\u6a21\u578b\u8986\u76d6\uff08\u4f8b\u5982 `anthropic\/claude-3-5-sonnet` \u6216\u522b\u540d\uff09\u3002\u5982\u679c\u6709\u9650\u5236\uff0c\u5fc5\u987b\u5728\u5141\u8bb8\u7684\u6a21\u578b\u5217\u8868\u4e2d\u3002\n* `thinking` \u53ef\u9009\uff08\u5b57\u7b26\u4e32\uff09\uff1a\u601d\u8003\u7ea7\u522b\u8986\u76d6\uff08\u4f8b\u5982 `low`\u3001`medium`\u3001`high`\uff09\u3002\n* `timeoutSeconds` \u53ef\u9009\uff08\u6570\u5b57\uff09\uff1a\u667a\u80fd\u4f53\u8fd0\u884c\u7684\u6700\u5927\u6301\u7eed\u65f6\u95f4\uff08\u79d2\uff09\u3002\n\n\u6548\u679c\uff1a\n\n* \u8fd0\u884c\u4e00\u4e2a**\u9694\u79bb\u7684**\u667a\u80fd\u4f53\u56de\u5408\uff08\u72ec\u7acb\u7684\u4f1a\u8bdd\u952e\uff09\n* \u59cb\u7ec8\u5728**\u4e3b**\u4f1a\u8bdd\u4e2d\u53d1\u5e03\u6458\u8981\n* \u5982\u679c `wakeMode=now`\uff0c\u5219\u7acb\u5373\u89e6\u53d1\u5fc3\u8df3\n\n### `POST \/hooks\/&lt;name&gt;`\uff08\u6620\u5c04\uff09\n\n\u81ea\u5b9a\u4e49 hook \u540d\u79f0\u901a\u8fc7 `hooks.mappings` \u89e3\u6790\uff08\u89c1\u914d\u7f6e\uff09\u3002\u6620\u5c04\u53ef\u4ee5\u5c06\u4efb\u610f\u8bf7\u6c42\u4f53\u8f6c\u6362\u4e3a `wake` \u6216 `agent` \u64cd\u4f5c\uff0c\u652f\u6301\u53ef\u9009\u7684\u6a21\u677f\u6216\u4ee3\u7801\u8f6c\u6362\u3002\n\n\u6620\u5c04\u9009\u9879\uff08\u6458\u8981\uff09\uff1a\n\n* `hooks.presets: [&quot;gmail&quot;]` \u542f\u7528\u5185\u7f6e\u7684 Gmail \u6620\u5c04\u3002\n* `hooks.mappings` \u5141\u8bb8\u4f60\u5728\u914d\u7f6e\u4e2d\u5b9a\u4e49 `match`\u3001`action` \u548c\u6a21\u677f\u3002\n* `hooks.transformsDir` + `transform.module` \u52a0\u8f7d JS\/TS \u6a21\u5757\u7528\u4e8e\u81ea\u5b9a\u4e49\u903b\u8f91\u3002\n* \u4f7f\u7528 `match.source` \u4fdd\u6301\u901a\u7528\u7684\u63a5\u6536\u7aef\u70b9\uff08\u57fa\u4e8e\u8bf7\u6c42\u4f53\u7684\u8def\u7531\uff09\u3002\n* TS \u8f6c\u6362\u9700\u8981 TS \u52a0\u8f7d\u5668\uff08\u4f8b\u5982 `bun` \u6216 `tsx`\uff09\u6216\u8fd0\u884c\u65f6\u9884\u7f16\u8bd1\u7684 `.js`\u3002\n* \u5728\u6620\u5c04\u4e0a\u8bbe\u7f6e `deliver: true` + `channel`\/`to` \u53ef\u5c06\u56de\u590d\u8def\u7531\u5230\u804a\u5929\u754c\u9762\uff08`channel` \u9ed8\u8ba4\u4e3a `last`\uff0c\u56de\u9000\u5230 WhatsApp\uff09\u3002\n* `allowUnsafeExternalContent: true` \u7981\u7528\u8be5 hook \u7684\u5916\u90e8\u5185\u5bb9\u5b89\u5168\u5305\u88c5\uff08\u5371\u9669\uff1b\u4ec5\u7528\u4e8e\u53d7\u4fe1\u4efb\u7684\u5185\u90e8\u6765\u6e90\uff09\u3002\n* `openclaw webhooks gmail setup` \u4e3a `openclaw webhooks gmail run` \u5199\u5165 `hooks.gmail` \u914d\u7f6e\u3002\u5b8c\u6574\u7684 Gmail \u76d1\u542c\u6d41\u7a0b\u8bf7\u53c2\u9605 [Gmail Pub\/Sub](\/automation\/gmail-pubsub)\u3002\n\n## \u54cd\u5e94\n\n* `200` \u7528\u4e8e `\/hooks\/wake`\n* `202` \u7528\u4e8e `\/hooks\/agent`\uff08\u5f02\u6b65\u8fd0\u884c\u5df2\u542f\u52a8\uff09\n* `401` \u8ba4\u8bc1\u5931\u8d25\n* `400` \u8bf7\u6c42\u4f53\u65e0\u6548\n* `413` \u8bf7\u6c42\u4f53\u8fc7\u5927\n\n## \u793a\u4f8b\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\ncurl -X POST http:\/\/127.0.0.1:18789\/hooks\/wake \n  -H 'Authorization: Bearer SECRET' \n  -H 'Content-Type: application\/json' \n  -d '{&quot;text&quot;:&quot;New email received&quot;,&quot;mode&quot;:&quot;now&quot;}'\n<\/code><\/pre>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\ncurl -X POST http:\/\/127.0.0.1:18789\/hooks\/agent<br \/>\n  -H &#8216;x-openclaw-token: SECRET&#8217;<br \/>\n  -H &#8216;Content-Type: application\/json&#8217;<br \/>\n  -d &#8216;{&#8220;message&#8221;:&#8221;Summarize inbox&#8221;,&#8221;name&#8221;:&#8221;Email&#8221;,&#8221;wakeMode&#8221;:&#8221;next-heartbeat&#8221;}&#8217;<\/p>\n<pre><code>\n### \u4f7f\u7528\u4e0d\u540c\u7684\u6a21\u578b\n\n\u5728\u667a\u80fd\u4f53\u8bf7\u6c42\u4f53\uff08\u6216\u6620\u5c04\uff09\u4e2d\u6dfb\u52a0 `model` \u4ee5\u8986\u76d6\u8be5\u6b21\u8fd0\u884c\u7684\u6a21\u578b\uff1a\n\n```bash  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\ncurl -X POST http:\/\/127.0.0.1:18789\/hooks\/agent \n  -H 'x-openclaw-token: SECRET' \n  -H 'Content-Type: application\/json' \n  -d '{&quot;message&quot;:&quot;Summarize inbox&quot;,&quot;name&quot;:&quot;Email&quot;,&quot;model&quot;:&quot;openai\/gpt-5.2-mini&quot;}'\n<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u542f\u7528\u4e86 <code>agents.defaults.models<\/code> \u9650\u5236\uff0c\u8bf7\u786e\u4fdd\u8986\u76d6\u7684\u6a21\u578b\u5305\u542b\u5728\u5176\u4e2d\u3002<\/p>\n<p><code>bash  theme={\"theme\":{\"light\":\"min-light\",\"dark\":\"min-dark\"}}<br \/>\ncurl -X POST http:\/\/127.0.0.1:18789\/hooks\/gmail<br \/>\n  -H 'Authorization: Bearer SECRET'<br \/>\n  -H 'Content-Type: application\/json'<br \/>\n  -d '{\"source\":\"gmail\",\"messages\":[{\"from\":\"Ada\",\"subject\":\"Hello\",\"snippet\":\"Hi\"}]}'<\/code><\/p>\n<h2>\u5b89\u5168<\/h2>\n<ul>\n<li>\u5c06 hook \u7aef\u70b9\u4fdd\u6301\u5728 loopback\u3001tailnet \u6216\u53d7\u4fe1\u4efb\u7684\u53cd\u5411\u4ee3\u7406\u4e4b\u540e\u3002<\/li>\n<li>\u4f7f\u7528\u4e13\u7528\u7684 hook \u4ee4\u724c\uff1b\u4e0d\u8981\u590d\u7528 Gateway \u7f51\u5173\u8ba4\u8bc1\u4ee4\u724c\u3002<\/li>\n<li>\u907f\u514d\u5728 webhook \u65e5\u5fd7\u4e2d\u5305\u542b\u654f\u611f\u7684\u539f\u59cb\u8bf7\u6c42\u4f53\u3002<\/li>\n<li>Hook \u8bf7\u6c42\u4f53\u9ed8\u8ba4\u88ab\u89c6\u4e3a\u4e0d\u53d7\u4fe1\u4efb\u5e76\u4f7f\u7528\u5b89\u5168\u8fb9\u754c\u5305\u88c5\u3002\u5982\u679c\u4f60\u5fc5\u987b\u4e3a\u7279\u5b9a hook \u7981\u7528\u6b64\u529f\u80fd\uff0c\u8bf7\u5728\u8be5 hook \u7684\u6620\u5c04\u4e2d\u8bbe\u7f6e <code>allowUnsafeExternalContent: true<\/code>\uff08\u5371\u9669\uff09\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Webhooks Gateway \u7f51\u5173\u53ef\u4ee5\u66b4\u9732\u4e00\u4e2a\u5c0f\u578b HTTP webhook \u7aef\u70b9\u7528\u4e8e\u5916\u90e8\u89e6\u53d1\u3002 \u542f\u7528 &#038; [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":1,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}