🔗 Webhook 端點
{
"command": "file.add",
"params": {
"name": "合同-2026.pdf",
"type": "application/pdf",
"size": 204800,
"hash": "sha256:abc123...",
"tags": ["tag-contract"],
"source": "clawbot"
},
"id": "req-uuid-123",
"source": "clawbot"
}
{
"id": "req-uuid-123",
"status": "ok",
"command": "file.add",
"result": {
"id": "generated-uuid",
"name": "合同-2026.pdf",
"status": "pending",
"tags": ["tag-contract"]
},
"timestamp": 1745610000000
}
📡 Webhook 配置(Clawbot/微信)
Webhook URL: https://aih5.pages.dev/webhook-handler.js
Method: POST
Content-Type: application/json
Signature Header: X-Webhook-Signature (HMAC-SHA256)
file.add → 文件上傳時觸發
ai.classify → AI 分類完成時觸發
ocr.scan → OCR 識別完成時觸發
✅ webhook-handler.js 部署完成。H5 頁面即可調用 /webhook-handler.js 接口與 Clawbot/微信雙向通信。
🔐 安全性配置
| 層級 | 方式 | 說明 |
| 網絡層 | HTTPS Only | Cloudflare Pages 強制 HTTPS |
| 應用層 | HMAC-SHA256 | X-Webhook-Signature 頭校驗請求真實性 |
| 數據層 | D1 logs | 所有請求寫入日誌表,支援審計 |
| 速率限制 | Cloudflare Rate Limit | 配置 Cloudflare 防火牆規則 |
const crypto = require('crypto');
const body = JSON.stringify({ command: 'file.add', params: {...} });
const signature = crypto
.createHmac('sha256', SECRET)
.update(body)
.digest('base64');