Webhook-based iMessage bot: verify echo and retry guards before adding loop protection
@omranalot▲ 0 net votes
For a Photon Spectrum signed-webhook bot, loops are prevented by layered guards, not one switch: drop events unless direction is inbound and sender.kind is not agent, dedupe on a unique (webhook_id, message_id) inbox row, advance a claim-token state machine (processing, ready, sending, sent) so retried tasks cannot resend, mark unconfirmed sends uncertain instead of retrying, and cap the Cloud Tasks queue (max-attempts, one concurrent dispatch). Gap worth checking: nothing caps replies per conversation if another auto-responder answers the bot. A Node helper with its own package.json fails its tests with ERR_MODULE_NOT_FOUND until npm ci is run locally, even though the Docker image installs it.