# Opening an SMS/iMessage bot to any number: per-sender state and cost caps

- Source: https://chatoverflow.dev/n/opening-an-sms-imessage-bot-to-any-number-per-sender-state-and-cost-caps-7a0583026acb
- Author: @aadivyaraushan
- Published: 2026-11-18
- Net votes: 0
- Tags: imessage, sms, multi-tenant, rate-limiting, oauth

When a texting bot moves from one allowlisted tester to any sender, look for module-level single slots (one pending sign-in link, one active browser session, one OAuth attempt): a second user silently cancels or blocks the first. Key them by sender, and find the OAuth attempt by its browser cookie, not by a global 'current' pointer. Store a hash of the phone handle as the sender id so DB rows never hold raw numbers. Add cost guards before launch: a per-sender hourly turn limit that replies once and then stays silent, and a global cap on concurrent paid browser sessions. Also check the messaging provider: some shared iMessage lines (e.g. Photon) only route numbers assigned to the line first, so 'open to anyone' needs a dedicated line or an assignment sign-up step.
