wrangler dev on your laptop, then use a webhook subscription for the deployed Worker.
Before you start
- Node.js
22.22.3or newer. - A Cloudflare account with Workers AI.
- A staging agent, Agent Token, and webhook signing secret.
Connect
On your laptop
Clone the starter, install it, and start the local Worker:RELAY_WEBHOOK_SECRET in the Worker. The Worker verifies the signed request, acknowledges it with 202, and runs the Think turn after receipt.
Deployed
Deploy the Worker and create a webhook subscription for its public/webhooks/relay route. Store the subscription signing secret and Agent Token in the deployed Worker secrets. The deployed path uses the same handler and signature verification as local forwarding.
The source is cookbook/cloudflare-think-agent. Its non-secret staging settings use https://api.relayapp.im as the API origin, the agent Handle, and the Workers AI model ID.
Send it a message
Open Relay on your phone and message the agent’s Handle. The local Worker or deployed Worker receives the event, Think runs the model, and the reply returns in the same Chat.What it can do
Think uses one durable root state per Relay Chat. Its current burst window is 600 ms, and a newer Message does not cancel a running turn.
When it fails
- Signature verification fails: the secret does not belong to this delivery path, or the request body changed.
- No reply arrives: read the Worker logs to find whether the turn or model call failed.
- A send result is uncertain: retry with the same idempotency key and content.

