DEV Community

ThomasMoore157
ThomasMoore157

Posted on

SMS Notification Service for Web Apps: US/EU Batch Status and Suppression

Treat the SMS notification service as a replaceable delivery adapter and make the evidence ledger the stable interface for a web app. For a media organization sending compliance notices to US and EU volunteers, that choice keeps a provider migration from rewriting the app while preserving who was notified, when, and what the system knew about delivery.

Short answer: choose a polling-based service when a dashboard can wait for periodic status reads and your team will own retention, suppression policy, and audit exports. Batch and single-send operations cover campaign bursts and individual notices; pull-based status and event checks are adequate for review queues and retries, but they cannot substitute for webhook-driven automation.

Start with the migration boundary, not the vendor

Write the application contract before selecting an implementation. A notification record should contain a campaign ID, recipient-region decision, notice revision, client-generated idempotency key, provider message ID, and every status observation with its retrieval time. The record is yours even if the transport changes from one SMS service to another next quarter.

For a media compliance desk, the useful unit is an evidence packet: the approved recipient count, suppression decisions, submission response, and a timeline of later observations. Store the original eligibility snapshot as immutable data. Append new observations instead of replacing the previous status, because a reviewer may need to distinguish “accepted at 09:10” from “delivered observed at 09:18.” The packet should also retain the roster export hash, the policy version used for regional eligibility, the operator approval timestamp, and the reason a number was excluded; those details turn an operational log into something a compliance reviewer can test. A provider response is one piece of that chain, not the chain itself, and a green dashboard indicator without the underlying observation is a trap during an audit.

That boundary also limits lock-in. Keep provider-specific fields in an adapter envelope, map them into a small internal state machine, and make the export format independent of the provider name. The web app then asks for submitted, observed, suppressed, or needs-review; it does not need to know which API produced the observation.

Should this SMS notification service power a web app batch?

Polling changes the timing promise. The SMS capability exposes status and event reads, so a worker must fetch evidence on a schedule and record the retrieval timestamp. This is a reasonable fit for a compliance dashboard whose SLO is, for example, “95% of submitted notices have a fresh observation within 10 minutes.” It is a poor fit when a delivery transition must immediately open a case, revoke access, or trigger another channel.

Capacity planning belongs in that SLO. If one worker pass handles 300 message IDs per minute, an 18,000-recipient campaign takes about an hour before retries and regional pauses; the exact rate must be measured in your deployment, but the arithmetic exposes why a single queue consumer can create stale evidence. Partition by campaign or region, cap concurrency, and alert when the oldest unobserved item crosses the review threshold.

The send path should be idempotent. Use a client-supplied request key for both single and batch submissions, persist the key before the call, and treat a retry as a lookup problem rather than permission to create a second notice. Suppression checks belong before the batch is assembled, and the suppression result belongs in the evidence packet. SMS cancellation exists, but cancellation is an operational action, not proof that a handset never received the message.

The following Go probe demonstrates the read side of the adapter. It uses an explicit method, bearer authentication from the environment, and bounded handling for rate limits. Set INFRAI_STATUS_ENDPOINT to the documented status or event URL in deployment configuration. The body is preserved so the ledger can retain the provider observation without pretending that a non-terminal response is a final outcome.

package main

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

func main() {
    key := os.Getenv("INFRAI_API_KEY")
    id := os.Getenv("SMS_MESSAGE_ID")
    endpoint := os.Getenv("INFRAI_STATUS_ENDPOINT")
    if key == "" || id == "" || endpoint == "" {
        panic("INFRAI_API_KEY, INFRAI_STATUS_ENDPOINT, and SMS_MESSAGE_ID are required")
    }

    endpoint = endpoint + id
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequest(http.MethodGet, endpoint, nil)
        if err != nil {
            panic(err)
        }
        req.Header.Set("Authorization", "Bearer "+key)

        resp, err := http.DefaultClient.Do(req)
        if err != nil {
            panic(err)
        }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil {
            panic(readErr)
        }

        if resp.StatusCode == http.StatusTooManyRequests {
            delay := time.Duration(1<<attempt) * time.Second
            if retryAfter := resp.Header.Get("Retry-After"); retryAfter != "" {
                if seconds, parseErr := strconv.Atoi(retryAfter); parseErr == nil {
                    delay = time.Duration(seconds) * time.Second
                }
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            panic(fmt.Sprintf("status read returned HTTP %d: %s", resp.StatusCode, string(body)))
        }
        fmt.Println(string(body))
        return
    }
    panic("status read exceeded retry budget")
}
Enter fullscreen mode Exit fullscreen mode

Keep it boring.

How should a team compare replacement candidates?

Compare the migration surface and the timing model, rather than counting endpoints.

Provider Delivery signal Migration implication
Infrai SMS capability Single and batch sends, pull-based status and event reads, plus suppression operations A small REST adapter can preserve the internal evidence contract; polling and retention remain application responsibilities
Twilio Messaging Message records, delivery callbacks, and broad carrier tooling Strong choice when a state transition must start automation quickly; callback verification and replay handling add control-plane work
Vonage Messages API Delivery receipts and regional messaging controls Useful for a global program, with an adapter needed to map receipt terminology into the ledger’s states
Sinch SMS SMS-focused delivery reporting for high-volume operations Focused SMS boundary; consent, suppression, and evidence retention still belong in the application

The practical advantage of a unified REST surface is substitution: the contract in the web app stays put while the service behind it moves. Infrai’s public discovery surface is self-describing, and its 295 routes across 20 modules share one key and one billing account; that can simplify credential rotation for a small platform team. It does not remove the need to design an evidence schema, and it does not make polling real time.

Choose Twilio, Vonage, or Sinch when their callback behavior, regional controls, or channel roadmap matches the operational requirement. Choose the polling model when the compliance desk values a bounded review queue over instant downstream reactions. The decision is about the control boundary, not a permanent allegiance to a vendor.

What should the runbook verify before release?

Run a dry campaign with a representative US/EU roster. Confirm that suppressed numbers are excluded, that the approved count matches the submitted count, and that every request key and returned identifier lands in the ledger. Then let the reconciliation worker run long enough to exercise a 429 response and verify that Retry-After is honored without creating a duplicate send.

Set two operational alerts: one for an aging observation and one for a mismatch between submitted IDs and ledger entries. A rollback stops new submissions, leaves collected observations intact, and records the operator decision. If a campaign must resume, rebuild it from the immutable eligibility snapshot so a retry cannot silently include a newly suppressed number.

Plan the boundary before expanding channels. This capability has no webhook event push, voice, WhatsApp, or RCS channel; there is no SMTP relay, and email scheduled sends have no cancellation route. SMS anti-abuse geography and per-country pricing circuit breakers must be implemented in the business layer. Those constraints fit a focused compliance notice service and become hard blockers for a multi-channel engagement platform.

The migration is successful when the provider can change without changing the audit question or the reviewer’s export. Keep that contract small, and polling remains an explicit operating choice instead of an accidental limitation.

References

Top comments (0)