Twilio and Shopify connect through Shopify Webhooks and the Twilio Messages API to automate SMS at every stage of the customer journey, from order placement through delivery confirmation and post-purchase follow-up. This integration is used by Shopify merchants who want higher open rates than email can provide for time-sensitive order and shipping notifications, and who need abandoned cart recovery at a channel with near-instant read rates. The connection requires a middleware layer, a Shopify private app for webhook management, and a Twilio account with an SMS-capable number registered under an A2P 10DLC campaign for US-bound messaging.
What You Need Before You Start
Create a Shopify private app by navigating to Apps in your Shopify admin, clicking Develop apps, creating a new app, and granting it the read_orders, read_customers, and read_checkouts Admin API access scopes, then copying the Admin API access token for use in your middleware. Register for A2P 10DLC in the Twilio Console under Messaging, then Senders, then US A2P 10DLC before sending any marketing or transactional SMS to US numbers, as Twilio requires brand and campaign registration before your messages will be delivered by US carriers. Provision a Twilio phone number with SMS capability and note your Account SID and Auth Token from the Twilio Console under Account, then General Settings. Set up your middleware server with a public HTTPS endpoint to receive Shopify webhook events, as Shopify requires HTTPS for all webhook delivery and will not deliver to plain HTTP endpoints.
Step-by-Step Integration Guide
Register Shopify webhooks for the events you want to trigger SMS by calling the Shopify Admin API at POST https://{shop}.myshopify.com/admin/api/2024-01/webhooks.json with the Admin API token in the X-Shopify-Access-Token header, a body containing webhook.topic set to orders/create and webhook.address set to your middleware endpoint URL, and repeat for the topics orders/fulfilled, checkouts/update, and orders/cancelled. In your middleware, parse the Shopify webhook JSON payload and verify the request by computing HMAC-SHA256 of the raw request body using your Shopify webhook secret and comparing it against the X-Shopify-Hmac-Sha256 header value before processing any event. Extract the customer phone from the payload at order.shipping_address.phone or order.customer.phone, normalize it to E.164 format, and dispatch the Twilio SMS by calling POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json with Basic authentication using your Account SID and Auth Token, To set to the normalized phone, From set to your Twilio number, and Body set to a message composed from the order number, total, and estimated delivery fields. For abandoned cart recovery, subscribe to the checkouts/update webhook and in your middleware set a delayed timer of 60 minutes: if the checkout has not converted to an order by the time the timer fires, query the Shopify Admin API for the checkout status and send a recovery SMS with the checkout URL only if it remains uncompleted.
Common Issues and How to Fix Them
Shopify webhooks are not delivered when the middleware endpoint returns any non-2xx HTTP status, and Shopify retries up to 19 times over 48 hours, which causes duplicate SMS if your middleware processes the same event on a retry after a partial failure. Implement idempotency by storing each processed Shopify order ID and event type in a database and returning HTTP 200 immediately when a duplicate order ID plus event type combination arrives, skipping the Twilio dispatch. Customer phone numbers in Shopify are stored in unformatted or national formats such as (555) 867-5309 rather than E.164, and passing these directly to Twilio results in a 21211 error. Normalize every phone number before the Twilio API call by stripping all non-digit characters and prepending the country code derived from the shipping address country code field in the Shopify order payload. Twilio SMS delivery to some mobile carriers in the US can be delayed or blocked when your A2P 10DLC campaign registration is still in pending review status, causing messages to appear as sent in Twilio but never arriving at the customer phone. Monitor your 10DLC campaign status in the Twilio Console under Messaging, then Senders, then US A2P 10DLC and do not enable customer-facing SMS sending until the campaign status shows Approved.
How to Get More from This Integration
Build a post-purchase review request flow by hooking into the orders/fulfilled Shopify webhook and sending a Twilio SMS to the customer 7 days after the fulfillment date using a scheduled job that checks the fulfillment date stored in your database at creation time, including a short link to your review platform in the message body. Add two-way SMS order tracking by configuring your Twilio number's inbound webhook to handle customer replies containing their order number, looking up the order status from the Shopify Admin API at GET https://{shop}.myshopify.com/admin/api/2024-01/orders.json?name={orderNumber}, and replying with the current fulfillment status and tracking URL. Enable back-in-stock SMS alerts by listening to the Shopify inventory_levels/update webhook, checking whether inventory moved from zero to a positive quantity, querying a waiting list stored in your database keyed by variant ID, and sending a Twilio SMS to each customer who signed up for that specific variant. Integrate Twilio with Shopify Flow by using Shopify Flow's Send HTTP Request action to call your middleware with the order details when a Flow trigger fires, enabling non-technical store operators to configure SMS triggers through the Shopify Flow visual builder without editing middleware code.
Conclusion
Twilio and Shopify together deliver automated SMS notifications that keep customers informed at every order stage and recover revenue from abandoned carts that email alone cannot reach. Contact Telphi Consulting to build and deploy a complete Twilio SMS integration for your Shopify store.
Ready to Transform Your Business Communications?
Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.
Comments (0)
Join the discussion and share your thoughts (AI-moderated for quality)
Be the first to comment
No comments yet. Share your thoughts below.