Adds `whatsapp_agent`, an additive channel that connects nanobot to the official WhatsApp Agent Platform API (https://api.whatsapp.com/agent/v1). It authenticates with a per-agent API token and long-polls `GET /updates` instead of linking a device, so it is the officially supported interface rather than the Neonize linked-device protocol used by the existing `whatsapp` channel. The existing `whatsapp` channel is unchanged; both can run at once under different names. Design notes: - The poll cursor, dedup window, and creator identifier live in one atomically replaced state file. A message id is recorded before it is handled, so a crash re-reads the batch without answering twice, and the cursor is only accepted after the batch is processed. - The first poll omits `offset`, which resolves the head and never replays up to 30 days of history into an auto-replying agent. - A changed token resets the cursor, because `next_offset` is only valid for the agent that issued it. - Each API method is paced below its own rolling 60-second limit, and progress/tool-hint messages default to off because they spend the shared 12-per-minute send budget. - Retries are limited to confirmed non-delivery (`429`, `503`/`131016`). A `500` or read timeout is ambiguous, so it is not retried unless `retryAmbiguousSends` is set; a duplicate is worse than a missed reply. - Inbound media is downloaded through the shared SSRF guard, size-capped, and verified against the reported digest. Outbound media is validated before upload. - Reactions are receive-only, matching the API. The token is never logged or persisted; state stores only a SHA-256 fingerprint. Docs compare both WhatsApp channels, including the lack of end-to-end encryption, country availability, and rate limits.
80 lines
2.2 KiB
JSON
80 lines
2.2 KiB
JSON
{
|
||
"setup": {
|
||
"docsLabel": "開啟代理設定指南",
|
||
"officialLabel": "開啟 WhatsApp 代理說明",
|
||
"summary": "將 nanobot 作為官方第三方代理連結到你的 WhatsApp 帳號。只有你可以與它對話,它無法存取你的其他聊天。",
|
||
"fields": {
|
||
"token": {
|
||
"label": "API 權杖",
|
||
"placeholder": "在 WhatsApp 中開啟 設定 → 代理,建立代理,然後從代理聊天 → 聊天資訊 → API 金鑰 複製金鑰。",
|
||
"help": "在 WhatsApp 中開啟 設定 → 代理,建立代理,然後從代理聊天 → 聊天資訊 → API 金鑰 複製金鑰。"
|
||
},
|
||
"allowFrom": {
|
||
"label": "允許的寄件者",
|
||
"placeholder": "user:1234567890"
|
||
},
|
||
"stateDir": {
|
||
"label": "狀態目錄",
|
||
"placeholder": "~/.nanobot/whatsapp-agent"
|
||
},
|
||
"pollTimeout": {
|
||
"label": "輪詢逾時(秒)",
|
||
"placeholder": "25"
|
||
},
|
||
"maxMediaMb": {
|
||
"label": "媒體大小上限(MB)",
|
||
"placeholder": "16"
|
||
},
|
||
"markRead": {
|
||
"label": "傳送已讀回條",
|
||
"choices": {
|
||
"true": "開啟",
|
||
"false": "關閉"
|
||
}
|
||
},
|
||
"typingIndicator": {
|
||
"label": "顯示正在輸入",
|
||
"choices": {
|
||
"true": "開啟",
|
||
"false": "關閉"
|
||
}
|
||
},
|
||
"downloadMedia": {
|
||
"label": "下載傳入媒體",
|
||
"choices": {
|
||
"true": "開啟",
|
||
"false": "關閉"
|
||
}
|
||
},
|
||
"deleteMediaAfterDownload": {
|
||
"label": "下載後刪除媒體",
|
||
"choices": {
|
||
"true": "開啟",
|
||
"false": "關閉"
|
||
}
|
||
},
|
||
"retryAmbiguousSends": {
|
||
"label": "重試結果不明的傳送",
|
||
"choices": {
|
||
"true": "開啟",
|
||
"false": "關閉"
|
||
}
|
||
},
|
||
"sendProgress": {
|
||
"label": "傳送進度訊息",
|
||
"choices": {
|
||
"true": "開啟",
|
||
"false": "關閉"
|
||
}
|
||
},
|
||
"sendToolHints": {
|
||
"label": "傳送工具提示",
|
||
"choices": {
|
||
"true": "開啟",
|
||
"false": "關閉"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|