Use cases
WhatsApp order and shipping updates for Shopify and WooCommerce
Your Shopify or WooCommerce shop sends order webhooks to a small receiver you own, and the receiver calls HelloHop to message the customer on WhatsApp. Verify the shop's signature on the raw body, send once per event with an idempotency key, include the tracking link, and message only customers who agreed to WhatsApp updates.
Facts (as of October 2026, API v1)
- In this flow HelloHop receives only the message you send. Your shop talks to your own receiver, and your receiver calls POST
/v1/sessions/{channel}/messages. - Shopify signs each webhook with a base64 HMAC-SHA256 of the raw body in the X-Shopify-Hmac-Sha256 header. X-Shopify-Webhook-Id identifies each delivery, and Shopify says to deduplicate on it.
- WooCommerce signs each webhook with a base64 HMAC-SHA256 of the raw body in the X-WC-Webhook-Signature header, using the secret you set on the webhook.
- The unified POST
/v1/sessions/{channel}/messagesroute accepts an Idempotency-Key of up to 255 characters. Repeating the same key and body within 24 hours returns the first result without another send, with the response header Idempotent-Replayed: true. - A 504 send_unconfirmed, a timeout, a 409 idempotency_uncertain or a 503 with ambiguous true means the message may have gone out. Treat it as possibly delivered and look at the chat before you send it again.
- The free sandbox channel allows 180 messages sent a day and 10 new chats a month, counted in Bangkok time. That is enough to build and test the whole flow before you pay.
- Prices: from $20 USD per number per month, billed annually, with a free sandbox and no per-message fees.
Steps
- Create the shop webhooks. In Shopify subscribe your app to orders/create and orders/fulfilled. In WooCommerce add a webhook for order updated. Point both at your HTTPS receiver.
- Verify the signature on the raw body. Hash the bytes you received with the shop secret and compare in constant time. Reject anything that does not match.
- Check the number and the consent. Use a phone number with a country code. If it is missing, or the customer did not agree to WhatsApp updates, send nothing.
- Send once. Call HelloHop with an Idempotency-Key built from the shop's event id. Treat a timeout as possibly delivered and never resend it automatically.
- Read the receipts. Add message.status to your webhook receiver's events list to get delivered and read receipts for each send.
The job: tell the customer where the order is
Customers message you to ask where their package is. A confirmation when the order is placed and a tracking link when it ships answer that question before it is asked. The shop already knows both moments and already fires a webhook for them. The missing piece is a receiver that turns the webhook into one WhatsApp message. HelloHop does not host the receiver and never sees your shop's data beyond the message text and the number. The same steps run in a serverless function, on a small server, or in an n8n, Make or Zapier automation that can verify an HMAC and call an HTTPS API.
Which shop event sends which message
| Shop event | Message | Notes |
|---|---|---|
| Shopify orders/create | Order received | Include the order name. The phone can be on the order, the shipping address or the customer. |
| Shopify orders/fulfilled | Shipped, with tracking | Read the tracking number and link from the order fulfillments. Skip the send when there is no tracking number. |
| WooCommerce order updated, status completed | On its way | The phone is billing.phone. Core WooCommerce has no tracking field, so add yours from the plugin you use. |
The receiver for Shopify (Node.js)
The customer messages in these samples are examples. Write your own wording before you use them. The consent hook returns false until you connect it to your own record of who agreed. Implement the database helpers and a timer that runs recovery before pending events. Saving before 200 retains the payload, but a crash after claiming can lose the send outcome. Recovery marks stale claims unknown for review, never for automatic resend. Conditional finish writes cannot overwrite recovered unknown rows. Store the returned message id.
// Shopify: https://shopify.dev/docs/apps/build/webhooks (HMAC and headers)
// and https://shopify.dev/docs/apps/build/webhooks/ignore-duplicates (X-Shopify-Webhook-Id identifies one delivery).
import crypto from 'node:crypto';
import express from 'express';
const API = 'https://api.hellohop.app/v1';
const { CHANNEL_ID, CHANNEL_TOKEN } = process.env;
// One send. Repeating the same key with the same body returns the first result.
async function sendWhatsApp(key, message) {
try {
const res = await fetch(`${API}/sessions/${CHANNEL_ID}/messages`, {
method: 'POST',
headers: {
Authorization: `Bearer ${CHANNEL_TOKEN}`,
'Content-Type': 'application/json',
'Idempotency-Key': key,
},
body: JSON.stringify(message),
signal: AbortSignal.timeout(15000),
});
const data = await res.json().catch(() => ({}));
const result = { status: res.status, code: data.code, ambiguous: data.ambiguous, id: data.id };
if (classify(result) === 'retry') {
// 429 whatsapp_rate_limited carries no Retry-After, so it falls back to 1 second. This helper waits at most 30 seconds;
// a longer Retry-After is not slept through: result.retryAt (Unix ms) says when the row is due, and your sweep or timer retries then.
const h = res.headers.get('Retry-After');
const ms = Math.max(0, (h ? (/^\d+$/.test(h) ? Number(h) * 1000 : Date.parse(h) - Date.now()) : 1000) || 1000);
result.retryAt = Date.now() + ms;
await new Promise((resolve) => setTimeout(resolve, Math.min(30000, ms)));
}
return result;
} catch {
return { status: 0 }; // timeout or lost connection: the message may have gone out
}
}
// One answer per send: sent (server_ack), queued, retry, unknown or failed.
function classify({ status, code, ambiguous }) {
if (status === 200) return 'sent'; // server_ack, not delivered
if (status === 202) return 'queued'; // observe webhooks, do not resend
// Refused before sending: repeat the same key and body later.
const refused = ['upstream_unavailable', 'hopsmart_settings_unavailable', 'operator_unresolved'];
if (status === 429 || (status === 503 && (ambiguous === false || refused.includes(code)))) return 'retry';
// Possibly sent: look at the chat, never resend.
if (status === 0 || status >= 500 || code === 'idempotency_uncertain') return 'unknown';
return 'failed'; // an unlinked channel, idempotency_conflict, a bad request: fix it, do not retry
}
// Your events table: unique key, payload, state, claimed_at (Unix ms), message_id. Helpers:
// saveEvent(key, payload) insert a pending row once; a repeat changes nothing
// claimSend(key) atomic pending -> claimed, sets claimed_at; true for one caller only
// finish(key, expected, state, id) UPDATE only WHERE state = expected; save the message id
// retry returns to pending with the SAME saved message body; all others stop automatic sends
// skipPending(key) UPDATE pending -> skipped only; never overwrites a claim/outcome
// Your timer must call this first, then re-run pending payloads. Never re-send unknown rows.
// db.run(sql, params) executes SQL in your database; claimed_at is Unix milliseconds.
async function recoverAbandonedClaims() {
await db.run("UPDATE events SET state = 'unknown' WHERE state = 'claimed' AND (claimed_at IS NULL OR claimed_at < ?)",
[Date.now() - 5 * 60 * 1000]);
}
const app = express();
function validShopify(raw, header) {
const { SHOPIFY_API_SECRET } = process.env;
if (!SHOPIFY_API_SECRET) return false; // fail closed: no secret, no valid signature
const expected = crypto.createHmac('sha256', SHOPIFY_API_SECRET).update(raw).digest();
const got = Buffer.from(header || '', 'base64');
return got.length === expected.length && crypto.timingSafeEqual(got, expected);
}
// Your own record of who agreed to WhatsApp messages. Return false until you connect it.
async function hasWhatsAppConsent(order) {
return false;
}
function customerNumber(order) {
const raw = order.phone || order.shipping_address?.phone || order.customer?.phone || '';
return raw.startsWith('+') ? raw.replace(/\D/g, '') : null; // no country code, no message
}
function messageFor(topic, order) {
const name = order.shipping_address?.first_name || order.customer?.first_name || 'there';
if (topic === 'orders/create') {
return `Hi ${name}, we received your order ${order.name}. We will message you when it ships.`;
}
const f = order.fulfillments?.[0];
if (topic === 'orders/fulfilled' && f?.tracking_number) {
return `Hi ${name}, order ${order.name} has shipped. Tracking: ${f.tracking_number} ${f.tracking_url || ''}`.trim();
}
return null;
}
// Claim the key, send once, record the outcome.
async function deliver(key, to, text) {
if (!(await claimSend(key))) return; // already sent, or another run owns it
const result = await sendWhatsApp(key, { type: 'text', to, text });
await finish(key, 'claimed', classify(result), result.id);
}
async function processEvent(key, topic, order) {
const text = messageFor(topic, order);
const to = customerNumber(order);
if (!text || !to || !(await hasWhatsAppConsent(order))) return skipPending(key);
await deliver(key, to, text);
}
app.post('/webhooks/shopify', express.raw({ type: 'application/json' }), async (req, res) => {
if (!validShopify(req.body, req.get('X-Shopify-Hmac-Sha256'))) return res.sendStatus(401);
const topic = req.get('X-Shopify-Topic');
const key = `shopify-${topic}-${req.get('X-Shopify-Webhook-Id')}`;
const raw = req.body.toString('utf8');
try {
await saveEvent(key, raw); // durable first: save, then answer
} catch {
return res.sendStatus(500); // Shopify delivers the event again later
}
res.sendStatus(200);
processEvent(key, topic, JSON.parse(raw)).catch(console.error); // a failure may leave pending or claimed work for the timer
});
app.listen(3000);The receiver for WooCommerce (Node.js)
This route goes in the same file as the Shopify one and reuses the send function, the consent hook and the same event table. The row key is the order and status, so a repeated completed update never sends a second message.
// WooCommerce: https://woocommerce.github.io/woocommerce-rest-api-docs/#webhooks
// Signature: base64 HMAC-SHA256 of the raw body with the webhook secret, in X-WC-Webhook-Signature.
function validWoo(raw, header) {
const { WOO_WEBHOOK_SECRET } = process.env;
const expected = crypto.createHmac('sha256', WOO_WEBHOOK_SECRET).update(raw).digest();
const got = Buffer.from(header || '', 'base64');
return got.length === expected.length && crypto.timingSafeEqual(got, expected);
}
async function processWoo(key, order) {
const to = (order.billing?.phone || '').startsWith('+') ? order.billing.phone.replace(/\D/g, '') : null;
const text = `Hi ${order.billing.first_name}, order ${order.number} is on its way.`;
if (!to || !(await hasWhatsAppConsent(order))) return skipPending(key);
await deliver(key, to, text);
}
app.post('/webhooks/woocommerce', express.raw({ type: 'application/json' }), async (req, res) => {
if (!validWoo(req.body, req.get('X-WC-Webhook-Signature'))) return res.sendStatus(401);
const raw = req.body.toString('utf8');
const order = JSON.parse(raw);
if (order.status !== 'completed') return res.sendStatus(200);
// One row per order and status. The delivery id changes on a retry, the order does not.
const key = `woo-${order.id}-${order.status}`;
try {
await saveEvent(key, raw);
} catch {
return res.sendStatus(500);
}
res.sendStatus(200);
processWoo(key, order).catch(console.error);
});The send call by hand
API=https://api.hellohop.app/v1
curl -s -X POST "https://api.hellohop.app/v1/sessions/$CHANNEL_ID/messages" \
-H "Authorization: Bearer $CHANNEL_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: shopify-orders-fulfilled-WEBHOOK_ID" \
-d '{"type":"text","to":"66XXXXXXXXX","text":"Hi Anna, order #1001 has shipped. Tracking: TH123456789"}'What the handler does with each send result
| Send result | What your handler does |
|---|---|
| 200 server_ack | WhatsApp acknowledged the send. Mark it sent and save id; this is not a delivery receipt. |
| 202 queued | Persisted in the queue, not delivered. A channel that queues its sends (for example while accepted sends drain) answers every text send this way, with id, status queued, position and expires_at. Mark it queued and save id. Observe the result through webhooks without resending. |
| 429, or 503 with ambiguous false or code upstream_unavailable, hopsmart_settings_unavailable or operator_unresolved | Refused before sending. Honor Retry-After, keep the same key and body, and retry later. The Node helper waits at most 30 seconds before returning retry with a retryAt time, and the pages that keep a due time skip the row until then; the other Node timer pages retry on their next run. The Flask, Python reminder and PHP samples return the time to retry instead of waiting; the Sheets helper saves next_attempt_at and skips the row until then. |
| 504 send_unconfirmed, 409 idempotency_uncertain, 503 with ambiguous true, a timeout or a lost response | Possibly delivered. Mark it unknown and look at the chat before any resend. Never force a resend of an uncertain key with a new key. |
| 409 idempotency_conflict | The same key was used for a different message. Fix how you build the key. The first message is unchanged. |
| Any other 409 | Mark it failed. Fix the channel before scheduling another attempt. |
| Other 4xx | The request is wrong and a retry will not fix it. Log it and move on. |
Subscribe to message and message.status webhooks and verify their signatures. The result of a queued send arrives as a message event: match the saved response id to payload.id. message.status reports delivered or read for each id in payload.ids. A send held by HopSmart™ expires 72 hours after acceptance, and the 202 carries expires_at. If no event arrives, read the job with GET /hopsmart/jobs/{id}. Save event ids to deduplicate. Do not resend queued work while waiting for a result.
Send only to customers who agreed
Collect agreement to WhatsApp updates at checkout, for example a checkbox beside the phone field, and store it with the order. Message only people who agreed, keep to messages about their own order, and stop when they say stop.
Common mistakes
- Parsing the JSON before verifying. Hash the bytes you received.
- Using the key of one event for two messages. The key is per message.
- Sending a number with no country code. Skip it instead of guessing a country.
- Retrying a timed-out send in a loop.
- Answering 200 before the event is saved. Save first, answer, then send.
Questions
- Does the shop send its webhooks to HelloHop?
- No. Your shop sends them to a receiver you own. The receiver verifies the signature and calls the HelloHop API with the message.
- How do I avoid sending the shipping message twice?
- Build the Idempotency-Key from the shop's event id. Repeating the same key and body within 24 hours returns the first result. Also save the event in your own table before you answer 200 and claim it before you send, so a retry or a replay days later cannot send again.
- Where does the tracking link come from?
- In Shopify it is on the fulfillment inside the orders/fulfilled payload. WooCommerce has no tracking field in core, so use the field your shipping plugin stores.
- What if the customer has no phone number?
- Skip the message and log it. Add a phone field with a country code at checkout and ask for agreement beside it.
- Can I try it without paying?
- Yes. Every account has one free sandbox channel that allows 180 messages sent a day, so you can test the flow with your own number.
Free sandbox, forever. Upgrade when you're ready.
Start freeKeep going
HelloHop is an independent WhatsApp API for developers: send and receive messages, automate groups and communities, and get signed webhooks. Not affiliated with WhatsApp or Meta. You link your own number.