WhatsApp API Shopify Integration: Order Notifications & Abandoned Cart
Any statistics or percentages in this article are general industry figures or illustrations, not QuackAPI measurements or promises. Results depend on your audience, consent and sending patterns. QuackAPI connects to WhatsApp as a linked device (an unofficial method), so read our risk and acceptable use policy before sending.
Why WhatsApp for Shopify?
Email open rates for Shopify order notifications average 21%. WhatsApp open rates average 98%. Switching your order notifications to WhatsApp means your customers actually see their shipping updates, order confirmations, and delivery alerts.
More importantly, abandoned cart recovery via WhatsApp converts at 25–35% (vs 5–10% for email). For a store doing $50,000/month with a 70% cart abandonment rate, recovering even 10% of abandoned carts adds $5,000 in monthly revenue.
This guide shows you how to connect QuackAPI to Shopify using Shopify Webhooks — no extra app needed, just a few lines of code on your server. For full bulk messaging details, see how to send bulk WhatsApp messages.
Architecture Overview
The integration works via Shopify Webhooks → your server → QuackAPI. Shopify fires an HTTP webhook to your server whenever an order is placed, shipped, or cancelled, and whenever a cart is abandoned. Your server receives the webhook, extracts the customer's phone number, and calls QuackAPI to send a WhatsApp message.
You need: a QuackAPI account (free tier works for testing), a connected WhatsApp device, and a server to receive Shopify webhooks (Node.js, Python, PHP — all work). The QuackAPI REST API makes sending the message a single HTTP POST request. Before going live, review the WhatsApp messaging best practices guide to minimize ban risk, and read the WhatsApp webhook setup guide for advanced event handling.
Step 1: Set Up Your Shopify Webhook Receiver
Create a webhook endpoint on your server that Shopify can POST to. This Node.js example using Express handles order creation and sends a WhatsApp confirmation:
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
const QUACKAPI_KEY = process.env.QUACKAPI_KEY;
const DEVICE_ID = process.env.QUACKAPI_DEVICE_ID;
// Shopify sends order data to this endpoint
app.post('/webhooks/shopify/order-created', async (req, res) => {
const order = req.body;
const phone = order.shipping_address?.phone
|| order.billing_address?.phone;
if (!phone) {
return res.status(200).json({ skipped: 'no phone' });
}
const orderNumber = order.order_number;
const firstName = order.shipping_address?.first_name || 'there';
const total = order.total_price;
const currency = order.currency;
const message = `Hi ${firstName}! Your order #${orderNumber} has been confirmed. Total: ${currency} ${total}. We will send you tracking info as soon as it ships! — Your Store`;
await axios.post('https://quackapi.com/v1/messages/send', {
deviceId: parseInt(DEVICE_ID),
to: phone.replace(/[^0-9]/g, ''),
content: message,
type: 'text'
}, {
headers: { 'x-api-key': QUACKAPI_KEY }
});
res.status(200).json({ sent: true });
});
app.listen(3000);Step 2: Register Webhooks in Shopify Admin
Go to Shopify Admin → Settings → Notifications → Webhooks. Click 'Create webhook' and register these events pointing to your server's HTTPS endpoint:
orders/create → https://yourdomain.com/webhooks/shopify/order-created
orders/fulfilled → https://yourdomain.com/webhooks/shopify/order-fulfilled
checkouts/create → https://yourdomain.com/webhooks/shopify/cart-created (for abandoned cart tracking)
Make sure your server is accessible via HTTPS. If developing locally, use ngrok to expose your local port publicly for testing.
Step 3: Abandoned Cart Recovery
Abandoned cart recovery requires a time-delayed message. When Shopify fires the checkouts/create webhook, store the cart data and phone number. After 1 hour without an order, send a recovery WhatsApp message.
const pendingCarts = new Map();
app.post('/webhooks/shopify/cart-created', async (req, res) => {
const checkout = req.body;
const phone = checkout.shipping_address?.phone;
if (!phone) return res.json({ skipped: true });
// Store the cart, check back in 1 hour
pendingCarts.set(checkout.token, { phone, checkout });
setTimeout(async () => {
const pending = pendingCarts.get(checkout.token);
if (!pending) return; // Cart was purchased — cleared
const { phone, checkout } = pending;
const total = checkout.total_price;
const firstName = checkout.shipping_address?.first_name || 'there';
await axios.post('https://quackapi.com/v1/messages/send', {
deviceId: parseInt(DEVICE_ID),
to: phone.replace(/[^0-9]/g, ''),
content: `Hi ${firstName}, you left ${total} worth of items in your cart! Complete your order here: ${checkout.abandoned_checkout_url}`,
type: 'text'
}, {
headers: { 'x-api-key': QUACKAPI_KEY }
});
}, 60 * 60 * 1000); // 1 hour delay
res.json({ queued: true });
});
// When an order is placed, cancel the recovery message
app.post('/webhooks/shopify/order-created', async (req, res) => {
const token = req.body.checkout_token;
pendingCarts.delete(token); // Cancel recovery
// ... send confirmation message
res.json({ ok: true });
});Step 4: Shipping Notifications
Register a webhook for orders/fulfilled and send a tracking link message. Shopify includes the tracking URL in the fulfillment data:
app.post('/webhooks/shopify/order-fulfilled', async (req, res) => {
const order = req.body;
const phone = order.shipping_address?.phone;
if (!phone) return res.json({ skipped: true });
const trackingUrl = order.fulfillments?.[0]?.tracking_url || '';
const firstName = order.shipping_address?.first_name || 'there';
await axios.post('https://quackapi.com/v1/messages/send', {
deviceId: parseInt(DEVICE_ID),
to: phone.replace(/[^0-9]/g, ''),
content: `Hi ${firstName}! Your order has shipped. Track it here: ${trackingUrl}`,
type: 'text'
}, { headers: { 'x-api-key': QUACKAPI_KEY } });
res.json({ sent: true });
});WhatsApp Message Templates for Shopify
Your message copy is as important as the technical integration. Here are proven templates for each Shopify notification type, optimized for WhatsApp's conversational format.
Order confirmation: 'Hi {first_name}! Your order #{order_number} has been confirmed. Total: {currency} {total}. We will message you when it ships. Thank you for shopping with {store_name}!'
Shipping notification with tracking: 'Hi {first_name}! Great news — your order has shipped! Track your package here: {tracking_url}. Expected delivery: {estimated_date}. Questions? Just reply to this message.'
Abandoned cart recovery (sent 1 hour after abandonment): 'Hi {first_name}! You left something in your cart. Your {product_name} is still available: {cart_url}. Need help choosing? Reply and we'll assist. This link expires in 24 hours.'
Post-purchase review request (sent 7 days after delivery): 'Hi {first_name}! We hope you are loving your {product_name}! Would you mind leaving us a quick review? It takes 30 seconds and really helps: {review_url}. Thank you!'
Keep messages under 1,024 characters for optimal display. Test templates in the WhatsApp preview tool before deploying to production. See WhatsApp marketing best practices for additional template guidance.
Compliance: GDPR, TCPA, and WhatsApp ToS
Before sending any WhatsApp messages to Shopify customers, you need explicit opt-in consent. The safest approach is to add a checkbox to your Shopify checkout: 'Send me order updates and offers via WhatsApp' — unchecked by default. Store the consent timestamp in your order metadata.
Under GDPR (EU/UK), you must be able to prove consent on request. Under TCPA (US), you must honor opt-outs within 24 hours. Under WhatsApp ToS, messaging contacts who have not opted in can result in your WhatsApp number being banned.
Implement a simple opt-out flow: if a customer replies 'STOP', 'UNSUBSCRIBE', or 'OPT OUT', immediately add them to a do-not-contact list and reply with 'You have been unsubscribed and will receive no further messages from {store_name} on WhatsApp.' Remove them from all future campaign lists. See e-commerce use cases for fully compliant workflow examples.
Store opt-in status in your database alongside the order. Before sending any message, check the opt-in status. This single check prevents the vast majority of compliance issues.