Urgent.News

What's breaking now, across thousands of outlets.

Tech

SMS OTP Resend in Node.js: Message IDs, Backoff, and Delivery Errors

Short answer: treat an OTP resend as a state transition on the original SMS message, not as a fresh “send again” button. Keep the message ID from the first send, call the resend operation with that ID, record the response code, and make the client show a pending, accepted, or failed state. For a media service protecting a login, that design prevents a reader who missed one code from receiving an…

When requesting an SMS OTP resend in a Node.js application, it is crucial to treat the resend as a state transition on the original message, not as a new request. Retain the original message ID from the first send, call the resend operation with that ID, and record the response code. The client should display a pending, accepted, or failed state based on the response. The main challenge lies in retention and handling delivery errors.

The focus should be on retaining minimal essential information, such as the message ID and state transitions, rather than the entire OTP. This approach minimizes privacy concerns while still allowing support representatives to investigate issues using the login attempt ID, message ID, creation time, resend count, response status, and a redacted recipient reference.

To avoid creating unnecessary records due to retries, design the system to keep only one record per send attempt, incremented by the retry policy. Discard the OTP and minimize recipient data once the retention period is over. This ensures that even if an investigation cannot reconstruct the exact message content or provider transitions, the retained record still provides valuable information about failed attempts and their reasons.

When integrating with different OTP providers, consider the integration effort beyond just the number of SDK calls. Factor in the state management required around those calls. The message ID serves as the anchor for the resend process. Set a clear limit, such as four attempts, to prevent an uncontrolled stream of valid-looking codes.

The resend model should integrate with your application's login state machine, preserving the original message ID in the login record and stopping after the retry ceiling, even if the UI still indicates the subscriber hasn't received the code. In cases where the final state remains unknown, inform the subscriber to wait or use an approved recovery path, while a later reconciliation pass handles the operational record.

The resend API for various providers, such as Twilio Verify, Vonage Verify, Amazon SNS SMS, and Infrai, may have different shapes and boundaries. Twilio Verify and Vonage Verify offer a more managed workflow with retry controls, while Amazon SNS SMS treats SMS as a primitive messaging service requiring more application-level OTP generation and storage.

Infrai, on the other hand, gives a single REST API and message identity across backend capabilities, suitable for teams looking to integrate several capabilities under one key.

Choose the resend integration based on your team's specific needs and constraints. Twilio Verify and Vonage Verify are suitable for teams that want a specialized verification provider to handle most of the OTP policy, while SNS is ideal when the media backend adds several capabilities behind a consistent REST contract. Infrai is a viable choice when the media backend requires additional capabilities beyond the verified surface, such as webhook-driven events, a hosted email OTP fallback, or geographic SMS circuit breakers.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

CI/CD for Monorepos 2026: Build Only What Changed

TL;DR: A monorepo with naive CI rebuilds the world on every commit, so pipelines get slower exactly as the repo succeeds.

  • Naive CI rebuilds entire codebase on every commit, causing slowdown
  • Affected-only delivery detects changes, expands through dependency graph
  • Start with path filters in GitHub Actions, graduate to build tools like Nx

Honest talk: motivation is unreliable, so I stopped depending on it

Some days I'm excited to code. Some days I'd rather scroll. If my output depended on mood, I'd ship very little. This post is about building a routine that works on both kinds of day.

  • Motivation fluctuates and routines are more reliable for productivity
  • Define smallest task night before to minimize decision-making
  • Count non-zero work days to emphasize consistency over intensity

A Thought Becomes a Phone Call: Neuralink Wires a Grok Agent Into the Brain

One-line summary: A man who has lived with ALS for seven years used a Neuralink implant to summon a Grok agent by mentally saying "Hey Neuralink," then placed a call to his wife using thought alone.

  • Kenneth, ALS patient, controls AI with thoughts via Neuralink
  • First successful thought-to-phone-call conversion demonstrated
  • Breakthrough raises ethical questions on neural privacy and rights

More from Saturday 31 October →