Most of our users in India are delivery riders, guards, pickers and telecallers signing up on budget Android phones. SMS OTP was our biggest sign-up leak: messages arrived late or not at all, and every resend cost money. We moved the primary OTP channel to WhatsApp and kept SMS as a fallback. Here's how it works and the bugs we hit.
The flow
The client calls a serverless function /send with the phone number.
The function normalises the number to E.164, finds or creates the auth user, generates a 6-digit code, and sends it through a WhatsApp Business authentication template.
Only a SHA-256 hash of userId:code is stored in the user's prefs, with an expiry and an attempt counter.
/verify compares hashes, counts attempts, and on success mints a short-lived session token the client exchanges for a session.
If WhatsApp delivery fails, /send returns { fallback: "sms" } and the client falls back to the platform's SMS OTP.
Rate limits that don't lock real users out
A per-number minimum gap between sends, and…