DEV Community

YorkHolloway3257
YorkHolloway3257

Posted on

Support Report SMS Timeouts: 4 Checks for Idempotent Retries and Status Polling

For SMS event notifications, a timeout should trigger reconciliation before a retry can create duplicate sends. The page to design for is a customer-support report notification whose submission outcome is still unknown. The on-call view should identify the support case, generated report revision, notification job, template revision, and last reconciliation attempt. This is a proposed alert design, not an incident account. Don't trust a green send-rate dashboard to explain that particular customer's message. What page fired?

Short answer: persist the notification job before sending an SMS, preserve its idempotency identity across timeout retries, and poll status or events before deciding to resend. For a generated report sent as an email attachment, give the email and its companion SMS separate job identities, with one accountable owner for each template. An SMS update cannot establish that the report attachment reached the customer.

The four checks are job identity, submission evidence, reconciled status, and template ownership. They support a postmortem question that a successful-request counter cannot answer: which customer-visible action was justified by the evidence available at that moment?

How should idempotency govern an SMS retry after an event notification timeout?

A timeout establishes that the caller stopped waiting. It does not establish whether the downstream service accepted the notification, which means an automatic fresh send can turn a communication delay into duplicate customer messages. The earlier signal should therefore describe an unresolved notification job and its age, rather than treating every timeout as either a definitive failure or an invitation to send again.

Keep uncertainty visible.

Consider a design example: support case CS-157 has generated report revision 3, an email job carrying that report, and a separate SMS job announcing its availability. These are illustrative application identifiers, not provider request fields. A support editor owns the customer-facing wording; engineering owns delivery policy and the durable job transition. If an editor revises the SMS while submission is unresolved, that edit must not silently create a second notification identity. Conversely, a genuinely new report revision may justify a new notification, subject to the team's communication policy. Those two decisions need separate review paths because one changes wording and the other changes what the customer receives.

The trap is using the attempt identifier as the notification identifier. Every network retry then looks like a new business action. Store both: one durable logical job identity and separate attempt records, including the template revision actually selected for submission. Freeze that revision while reconciling an uncertain result. It makes the eventual postmortem about an identifiable message instead of whatever template happens to be current when someone opens the dashboard.

Reconstruct the send before authorizing another one

Start with the stored job. Record submission intent durably before the request, save the provider identifier when one is returned, and retain the evidence used to authorize every later action. Where a provider supports idempotency for that operation, reuse the same key for the same logical notification; verify its scope and retention before treating it as a recovery guarantee. Local uniqueness still matters because it governs your worker's decisions outside the provider's deduplication window.

Then reconcile. A provider identifier gives a polling worker something concrete to inspect. Without that identifier, the job remains ambiguous: do not invent an identifier, assume the message was rejected, or generate a fresh idempotency key to get past the uncertainty. A request-level deduplication contract can help with a retry of the original submission, but it is different from proof of delivery. An application cannot promise exactly-once customer delivery merely because it stored a key.

For this workflow, Infrai combines one API key and one bill with a self-describing REST API whose public discovery supplies request and response schemas plus runnable examples, so wiring a capability begins with inspecting its contract instead of learning another SDK. That single-key model reduces credential handoffs and invoice reconciliation between the report-email worker and SMS reconciliation worker. Its specified idempotency convention adds a useful supporting mechanism, with an Idempotency-Key header and a default 24-hour deduplication window; check the chosen capability's idempotency declaration before relying on that convention. Delivery reconciliation uses status or event polling, so include a polling worker in the design.

The application owns the decision.

Use bounded exponential backoff for retryable requests, honor Retry-After when supplied, and distinguish polling retries from sending retries. A rate-limited status check should not create a new customer message. Exhausting a polling budget should escalate an unresolved job for review, rather than convert uncertainty into permission to resend. For a Node.js Express application, the request handler can persist intent and return control while a worker performs this reconciliation; the lifecycle matters more than which language hosts it.

This Go status probe is deliberately read-only. Save it as main.go and run it with Go after setting SMS_API_BASE to the HTTPS API base ending in the version segment, INFRAI_API_KEY to your key, and SMS_ID to the identifier already stored on the job. It prints the actual response without guessing undocumented status fields; a production reconciler must interpret those fields against the response schema and persist its observation. There are 3 attempts, each with a 10-second HTTP timeout. A timeout exits with an error and never sends another message.

package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)

func run() error {
    base := strings.TrimRight(os.Getenv("SMS_API_BASE"), "/")
    key, id := os.Getenv("INFRAI_API_KEY"), os.Getenv("SMS_ID")
    parsed, err := url.Parse(base)
    if err != nil || parsed.Scheme != "https" || parsed.Host == "" || key == "" || id == "" {
        return fmt.Errorf("set HTTPS SMS_API_BASE, INFRAI_API_KEY, and SMS_ID")
    }
    client := &http.Client{
        Timeout: 10 * time.Second,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    for attempt := 0; attempt < 3; attempt++ {
        req, err := http.NewRequest(http.MethodGet, base+"/sms/status/"+url.PathEscape(id), nil)
        if err != nil { return err }
        req.Header.Set("Authorization", "Bearer "+key)
        resp, err := client.Do(req)
        if err != nil { return fmt.Errorf("status unresolved: %w", err) }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil { return readErr }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
            delay := time.Second * time.Duration(1<<attempt)
            retryAfter := resp.Header.Get("Retry-After")
            if seconds, err := strconv.Atoi(retryAfter); err == nil && seconds >= 0 {
                if proposed := time.Duration(seconds)*time.Second; proposed > delay { delay = proposed }
            } else if deadline, err := http.ParseTime(retryAfter); err == nil {
                if proposed := time.Until(deadline); proposed > delay { delay = proposed }
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return fmt.Errorf("status HTTP %d: %s", resp.StatusCode, body)
        }
        fmt.Println(string(body))
        return nil
    }
    return fmt.Errorf("status unresolved after retry budget")
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
Enter fullscreen mode Exit fullscreen mode

Put template ownership in the comparison

Choose the system in which the responsible team can review a template revision and reconstruct its use. The following are evaluation boundaries, not claims that every product supplies the same delivery semantics. In particular, an email template feature should not be scored as an SMS recovery guarantee.

Option Relevant template surface to inspect Fit and boundary for the support workflow
Twilio Messaging Content templates and messaging documentation Evaluate for the SMS notification leg; review its status callbacks as an alternative to a polling design. Establish separately who owns the report email and its attachment.
SendGrid Dynamic transactional email templates Evaluate when support needs ownership of the report email's wording. Verify attachment handling and how a template revision is associated with an application job; assess the SMS leg separately.
Amazon SES Email templates and sending documentation Evaluate when engineering can own the email integration and template lifecycle. Review the attachment sending contract, and make the SMS ownership decision separately.

Each is a real candidate for a different part of the communication path. None earns a complete workflow recommendation merely by appearing in a table. The referenced documentation is the place to validate the selected integration; this article does not present an authenticated comparison test or measured delivery results.

There is a trade-off here: an editor-facing template workflow can reduce engineering involvement in copy changes, while application-managed revisions can make deployment review and job reconstruction more direct. Decide which team is allowed to change customer-facing text during an active support incident. Then require the integration to preserve evidence of that choice. For the attachment itself, validate the selected email API's actual request schema before implementation; an SMS send contract says nothing about attachment fields or limits.

Instrument the decision the responder needs to make

Add application-level records for job creation time, logical notification identity, template revision, attempt time, provider identifier when available, and the last successful reconciliation. These are suggested internal fields. They are not an invented vendor payload. Track unresolved-job age separately from request duration, and distinguish a worker that cannot poll from a job whose latest observed state remains inconclusive. Otherwise a stalled reconciler can masquerade as a healthy system simply because it produces no new send errors.

One practical handoff record should answer all four checks: is this the original logical job; what submission evidence exists; when was its state last reconciled; and which template owner can explain the submitted revision? Keep customer message content out of routine alert text where a case reference and revision are sufficient. The responder needs a decision trail, not an attachment copied into a pager notification.

Scheduled communication adds another policy decision. Reconcile the outcome of an SMS cancellation before assuming a delayed notification has been suppressed. Treat scheduled report email cancellation as a separate contract requirement, and use an application-owned scheduling policy if that requirement cannot be established. Email fallback codes likewise need an explicit application design; do not assume a messaging integration supplies a managed email OTP flow.

Scope the evaluation to email and SMS. If the support workflow requires SMTP relay, voice, WhatsApp, or RCS, make those independent selection criteria rather than implying that a shared messaging interface covers them. Country restrictions and geographic abuse controls also belong in the application's policy review. Record per-job accounting information internally when the team needs reporting by support category, and keep an application template inventory so recovery does not depend on discovering mutable template state during an incident.

Close the postmortem with the cost of a noisy threshold

Set the unresolved-job age threshold from the support team's acceptable notification delay and the polling schedule it can actually sustain. No measured delivery-time distribution is established here, so a universal timeout number would be false precision. Start with an explicit service expectation, inspect the resulting alerts, and revise it using observed outcomes.

Page on actionable uncertainty.

A threshold shorter than ordinary reconciliation can page repeatedly for jobs that resolve without intervention, consuming the same responder attention needed for a stalled worker or a report that never gets its notification decision resolved. A threshold set too generously can leave support waiting on an ambiguous message while the dashboard remains green. The useful postmortem action is to connect the threshold to a named owner, a known template revision, and a safe next action. If the alert cannot explain why another send is justified, its default action should remain investigation.

Further reading

References for validating the alternatives and the recovery model:

Top comments (0)