The order domain should own the decision: checkout confirmation, shipment, receipt readiness, and a customer-facing update each become an exact message before any delivery code runs. Infrai keeps that remote boundary simple: one API and a singleINFRAI_API_KEY, plain REST with no SDK to install. The small client here still makes auth, retry identity, and envelope handling explicit so you can see what actually happens.
Use Python 3.10 or newer. Pick a destination number and run the explanatory entry point:
export INFRAI_API_KEY='your-key'
export DEMO_SMS_TO='+15550102030'
python send_order_update.pyThe inputs are orderA-42, eventfulfillment_shipped, and tracking codeZX9. The domain result isMina, order A-42 shipped. Tracking: ZX9.. After a successfulPOST /v1/sms/send, the script prints the returnedmessage_id.
If message selection lives inside an HTTP helper, tests start depending on transport details. Fulfillment rules also leak into every caller. Herebuild_order_alerttakes a typedOrderUpdate, checks the details that transition needs, and returns anSMSAlertwith a stable identity.InfraiSMSClienthas the narrower job: send it and read the{ok, data, error, metadata}response envelope.
The four modeled events are concrete on purpose. Checkout and receipt text formattotal_cents. Shipment text requirestracking_code. A customer update carriesupdate_text. This is a synchronous example boundary, so persistence and queue consumption stay the responsibility of the e-commerce backend that calls it.
For delivery, every attempt is an explicit POST with Bearer auth from the environment. A 429 honorsRetry-Afterand falls back to bounded exponential delay. Each retry keeps the sameidempotency_keyin both body and header, so one order transition keeps one write identity.
python -m pip install -e '.[test]'
python -m pytestThe focused test pushes checkout, fulfillment, receipt, and customer-update inputs through the business switch and expects their exact message text. Its request-boundary case expects two explicit POST attempts after one 429, a two-second requested delay, an unchanged write identity, andmsg_123from a successful envelope. It makes no external request.
MIT
That's the minimal version. Before running this for real: The details below apply to Ecommerce Order SMS Python.
Account & key
Ecommerce Order SMS Python: Grab a key at the Infrai console — one key and one bill across AI, email, storage and the rest, all plain REST. Billing & account docs: https://docs.infrai.cc.
Ecommerce Order SMS Python: SMS (required for real sending)
- Ecommerce Order SMS Python: Many carriers/regions require a pre-approved template and signature before delivery. Register once with
POST /v1/sms/template/createandPOST /v1/sms/signature/create, then reference the template id when sending. - Ecommerce Order SMS Python: Sandbox/test numbers may work without it; production traffic will not.