Use cases
Abandoned cart follow-up over WhatsApp
Track each checkout from your shop's webhooks, wait an hour, and if no order arrived, send one WhatsApp message with the cart link through HelloHop. Claim the checkout before sending so it can only go out once, skip anyone without a phone number or consent, and never send a second reminder.
Facts (as of October 2026, API v1)
- Shopify has checkouts/create and checkouts/update webhook topics. The payload carries the contact and an abandoned_checkout_url that returns the shopper to the cart.
- WooCommerce has no abandoned cart webhook in core. Use a cart plugin that fires one, or record the cart yourself when the shopper enters a phone number.
- 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
- Record each checkout. On every checkout webhook store the id, the phone, the cart link and the time it was last touched.
- Close it when an order arrives. An order webhook marks the checkout bought. Conditional writes preserve that state; an already-started send may still finish.
- Sweep on a schedule. Every few minutes find open checkouts untouched for an hour, with a phone number and consent.
- Claim, then send once. Flip the checkout from open to claimed in one atomic update. Only the run that wins the update calls HelloHop, with the checkout id in the Idempotency-Key. A late checkout update never reopens a checkout that is bought, sent or unknown.
The job: bring back the shopper who left
A shopper who reached checkout, entered a phone number and left had already chosen what to buy. One message with the cart link, sent an hour later, takes them back to that cart. This page sends exactly one message per checkout.
The flow in your own code
| Moment | Source | What your code does |
|---|---|---|
| Shopper reaches checkout | Shopify checkouts/create or checkouts/update | Store or refresh the checkout record |
| Shopper buys | Your order webhook | Close the checkout |
| One hour of silence | Your scheduler | Claim, then send one message |
Record, sweep and send (Node.js)
Implement the db helpers in your own database: claim atomically changes open to claimed and records claimed_at; setState updates only the expected state and saves the message id. Recovery marks stale claims unknown, never open. An order arriving during a send stays bought, although the send may still finish. Freeze the message body for retries. The wording is an example.
// Shopify checkouts/create and checkouts/update carry the cart, the contact and
// abandoned_checkout_url: see the Checkout resource in the Shopify REST reference at shopify.dev.
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
}
// Called from your checkout webhook receiver (verified like the order receiver on the
// Shopify guide). Remember the newest contact and when the checkout was last touched.
// INSERT ... ON CONFLICT (id) DO UPDATE must leave state alone: state is 'open' on insert only,
// so a late or repeated update never reopens a bought, sent or unknown checkout.
async function onCheckout(checkout) {
await db.upsertCheckout({
id: checkout.token,
phone: checkout.phone,
first_name: checkout.billing_address?.first_name,
url: checkout.abandoned_checkout_url,
touched_at: Date.now(),
});
}
// Called from your order webhook: close the checkout; an already-started send may still finish.
async function onOrder(order) {
// Sets state 'bought', and creates that row if the order arrived first.
await db.closeCheckout(order.checkout_token); // deprecated by Shopify but still sent; the checkout payload calls it token
}
// Runs every few minutes (cron, a queue or a scheduled automation step).
async function sweep() {
// db.run executes SQL; claim sets claimed_at (Unix ms). Expired claims are never re-sent.
await db.run("UPDATE checkouts SET state = 'unknown' WHERE state = 'claimed' AND (claimed_at IS NULL OR claimed_at < ?)",
[Date.now() - 5 * 60 * 1000]);
const cutoff = Date.now() - 60 * 60 * 1000; // one hour of silence
for (const c of await db.openCheckoutsTouchedBefore(cutoff)) {
const to = c.phone?.startsWith('+') ? c.phone.replace(/\D/g, '') : null;
if (!to || !(await hasWhatsAppConsent(c))) {
await db.setState(c.id, 'skipped', 'open');
continue;
}
if (!(await db.claim(c.id))) continue; // atomic: state open -> claimed, one winner
const result = await sendWhatsApp(`cart-${c.id}`, {
type: 'text',
to,
text: `Hi ${c.first_name || 'there'}, you left items in your cart. Pick up where you stopped: ${c.url}`,
});
const outcome = classify(result);
// setState(id, state, expected, messageId) updates only WHERE state = expected.
// Never overwrite bought or a recovered unknown; retry must use the SAME saved body.
await db.setState(c.id, outcome === 'retry' ? 'open' : outcome, 'claimed', result.id);
}
}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: cart-CHECKOUT_ID" \
-d '{"type":"text","to":"66XXXXXXXXX","text":"Hi Anna, you left items in your cart. Pick up where you stopped: https://shop.example.com/cart/XXXX"}'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 shoppers who agreed
Put a checkbox beside the phone field that says the shopper agrees to WhatsApp messages about their cart and order, and store the answer with the checkout. If the box is not checked, send nothing. Remove a shopper who replies stop from every future send.
Common mistakes
- Sending before the order webhook has had time to arrive. An hour is a safe wait.
- Reading and updating the checkout in two steps. Use one atomic claim.
- Writing state open on every checkout update. Set it on insert only, or a replay reopens a sent checkout.
- Sending a second and third reminder. Record the send on the checkout and stop there.
- Using a phone number with no country code.
Questions
- How long should I wait before the reminder?
- One hour is a common start. The sample sweeps for checkouts untouched for an hour. Change the cutoff and measure it against your orders.
- How do I stop a reminder going to someone who already bought?
- Close the checkout from your order webhook, and have the sweep skip anything that is not open.
- Does WooCommerce work?
- The same sweep works. WooCommerce has no abandoned cart webhook in core, so record the cart with a plugin that fires one, or from your own checkout script.
- Can I send more than one reminder?
- The sample sends one per checkout. Any further message needs the shopper to have agreed to it, and each one needs its own idempotency key.
- Can I try it without paying?
- Yes. Every account has one free sandbox channel. It allows 10 new chats a month, so test with your own number and a few friends who agreed.
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.