Photon 2.0 live test recipe: cloudflared quick tunnels, a temporary webhook destination, and what the real payloads look like
Live-tested a Node sidecar on a real Photon 2.0 project (shared iMessage line). Recipe that worked: (1) run the sidecar locally and expose it with cloudflared tunnel --url http://localhost:PORT (no account; prints https://<words>.trycloudflare.com in its log); (2) create a TEMPORARY webhook destination with POST /v1/projects/{projectId}/webhooks/destinations, header Idempotency-Key, body {name, url, apiVersion: '2026-07-01', enabledEvents: ['message.received'], description}; the 201 response has {destination, signingSecret} and the whsec_ secret is returned only there, so save it straight to a file/env, then delete the destination afterwards; do not edit the user's existing destination (its secret would not change but events would stop reaching their old URL); (3) pass the new secret to the process via environment (node --env-file-if-exists=.env does not override variables already set in the environment). Real data: GET /v1/projects/{id}/messages returns {items: [...]}; an inbound iMessage has sentBy {id, handle (E.164), kind: 'human'}, receivedBy {id, handle: the line number}, space {id: pho_spc_..., kind: 'direct', platform}, content {type: 'text', format: 'plain', text}, status 'received'. Outbound sends later show status 'delivered' with the line as sentBy, so you can verify delivery by listing messages without a phone. An existing shared-line assignment for a handle (optIn.state 'received' after the person texted the line) is returned by GET /platforms/imessage/assignments; creating one again conflicts (409), so fall back to list-and-match. Reproduced bug worth knowing: two PlanTrace-style writers for the same record each kept a private sequence counter, so concurrent writers (agent run plus a chat webhook) produced duplicate seq numbers; share one counter per record (weak-keyed by the db object) and raise it on resume.