Business · Product · Technology · AI

OTP channel fallback: distinguish configured, available, queued and delivered

A Movo-X sign-in delivery walkthrough separating provider configuration, bridge availability, queued messages, rate limits and the channel returned to the client.

Work directly with Omer Muneer Qazi · Reviewed 29 November 2026

The scenario: WhatsApp is configured but its bridge is offline

A sign-in screen can offer a delivery channel that is configured in the application but unavailable at the moment a person requests a code. If the request creates a challenge before discovering there is no delivery path, the person may face resend limits without receiving anything useful. Configuration and present availability need different meanings.

The inspected Movo-X patient handler checks selected delivery-path information and supports an SMS fallback when the chosen WhatsApp outbox cannot queue the message. Six isolated outbox tests passed, including selected enqueue, full-queue and offline fallback cases. No actual code was delivered and no real sign-in session or carrier was exercised.

Separate provider configuration from live-path knowledge

The configuration helper distinguishes an outbox from a direct gateway and validates the settings needed for the selected provider. The available-channel helper also receives bridge and SMS gateway availability inputs; it does not infer a live phone merely because an environment setting names one.

The tests show the outbox appearing when the corresponding availability input is true and disappearing when it is false. This is evidence about channel selection with supplied state. The accuracy, freshness and expiry of that state belong to the coordinating service. A UI label should reflect that distinction instead of promising that a provider configuration is a current delivery guarantee.

Check known unavailability before creating a challenge

The inspected request path validates the input and asks whether the selected channel has a usable path before creating an ordinary challenge. Its comments explain the operational reason: a challenge can start resend and rate-limit consequences even when its code cannot be sent. Avoiding a known dead path prevents a needless failed attempt.

The implementation also treats an availability lookup error differently from a definite offline result: the lookup failure does not independently block the request, and the delivery operation can still refuse later. That is a specific availability tradeoff, not a guarantee that every preflight is complete. A separate acceptance should test known-offline, unknown and state-changes-after-preflight conditions.

Queue the message without pretending to call a gateway

For the selected WhatsApp outbox branch, the handler asks the authoritative delivery operation to queue the prepared text. It does not POST the text to the direct gateway path. The isolated enqueue test checks the selected delivery mode and verifies that its injected gateway fetch recorder remains unused.

When the coordinator reports queued, the handler records WhatsApp as the selected channel for the response. Queued is not the same as sent or delivered. The bridge must still lease the item and perform its part. Keeping these states distinct gives support and monitoring a more accurate explanation than treating the initial HTTP success as proof that the person received the code.

Preserve backpressure instead of bypassing a limit

A tested full-outbox response is surfaced as a rate-limit response rather than silently launching another delivery route. The inspected branch also checks rate-limit results while considering supported SMS delivery operations. These decisions preserve an explicit refusal from the coordinating layer.

A fallback should not become a way around a limit simply because another provider is configured. The full policy still belongs to the authoritative service, including which limits apply across phone, installation and network scopes. The isolated test establishes the selected handler response to a mocked refusal, not the actual counters, expiry or fairness of the production rate-limit implementation.

Report the channel the handler actually selected

The offline fallback fixture makes the WhatsApp enqueue fail as unavailable and the configured device SMS queue accept the message. The handler response names SMS, and the test checks the ordered delivery attempts. Its channel-discovery response also omits the offline WhatsApp outbox while retaining the available options.

This prevents a client from waiting on an inaccurate channel label after the server has chosen a fallback. It does not prove that SMS was received, and it does not authorize every possible fallback policy. The product should explain the accepted behaviour, while operations distinguish request acceptance, queued work, send attempts and eventual delivery information.

Keep security notices independent of the main response

The reviewed handler schedules new-device notice work separately through its deferred-task dependency. In outbox mode it enqueues notices instead of directly contacting the gateway. The isolated reverse-sign-in fixture verifies the deferred callback and its enqueue operation with mocked verification results.

That separation keeps a notice operation from being confused with the sign-in response itself. It also creates an acceptance obligation: best-effort deferred work is not automatically durable notification. Inspect how the hosting environment runs deferred callbacks and how the coordinating service retains due notices. No current worker scheduling or actual account notification was validated by this test.

A useful sign-in delivery acceptance plan

Deliver a state map for configured, known available, queued, attempted, sent and delivered. Test known-offline and unknown availability separately, plus queue refusal, rate limiting, a changing bridge state and successful fallback. Check the returned channel and user guidance for each outcome using synthetic recipients.

For a CTO, this makes reliability claims measurable at the correct stage. A valid provider setting is an input, queue acceptance is a handoff and recipient delivery is a later outcome. The source and mocked cases establish selected application decisions without borrowing certainty from the untested phone, carrier or database. That distinction helps the team improve sign-in without hiding delivery uncertainty behind a successful API response.

Illustrative control flow

Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.

validate_request()
if delivery_path_is_known_unavailable():
    refuse_before_creating_challenge()
challenge = authoritative_service.create_challenge()
result = try_selected_queue(challenge)
if result.is_rate_limited:
    preserve_refusal()
elif not result.queued:
    try_permitted_fallback()
return_selected_channel_without_claiming_recipient_delivery()

About this engineering series

Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.

Explore the Movo-X engineering series → · Related implementation experience →

Discuss a similar engineering problem

Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.

Discuss your project on WhatsApp ↗
WhatsApp Omer about this project ↗