Use cases

WhatsApp shipment tracking updates from a tracking webhook

To send shipment updates on WhatsApp with HelloHop, take the push notifications from a tracking service, verify their signature, and call the HelloHop send route when a parcel reaches a status worth a message. HelloHop only sends the message. The tracking service finds the parcel status, and your own order table says who to tell.

Facts (as of October 2026, API v1)

  • The sample uses 17TRACK, one tracking service with a documented webhook. Any service that can post a webhook to your receiver fits the same flow.
  • You register each parcel with a tag of your own, such as the order id. Every push carries that tag back in data.tag, and the sample uses it to look up the customer in your order table.
  • 17TRACK signs a push in a header named sign. It is the SHA-256 hex of the raw body, a slash and your security key. Its documentation names no delivery id and the signature covers no timestamp, so the sample dedupes on the carrier, the parcel number, your tag and the status.
  • 17TRACK counts any answer other than HTTP 200 as a failed push and retries three times, after 10, 30 and 60 minutes.
  • HelloHop does not look up carriers, read parcel status or store orders. It sends the text you give it.
  • The unified POST /v1/sessions/{channel}/messages route 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

  1. Register each parcel with a tag. When you create the shipment, register its tracking number with the tracking service and set the tag to your order id.
  2. Point the webhook at your receiver. Set the push URL in the tracking service and keep its security key in an environment variable.
  3. Verify and save. Check the sign header against the raw body, save the push under the carrier, parcel number, tag and status, and answer exactly 200.
  4. Look up the customer. Read the order by tag. Message only a customer who said yes to WhatsApp updates and has not opted out.
  5. Send once per status. Claim the row, send the status text with the row key as the Idempotency-Key and record the result.

Which statuses to message

A parcel passes through many statuses and most are noise. The sample sends for four: OutForDelivery, AvailableForPickup, Delivered and DeliveryFailure. It saves every other push and sends nothing. A status can repeat for one parcel, for example a second failed delivery. The sample sends each status once per parcel, so the repeat gets no message.

The receiver (Node.js)

The sample needs Express and an order table you keep: a tag, a name, a phone number with the country code and a WhatsApp consent flag. It answers 200 only after the push is saved. A push that fails the signature gets 401, and a push for a tag you do not know is saved and skipped. The sample has no timer of its own. Implement the helpers named in the comments on your own database, and add a timer that runs recovery and then re-runs pending rows from their stored payload. The message wording is an example. For another tracking service, change the signature check and the field names to match its documentation, and keep the rest.

Node.js: tracking push to WhatsApp
// 17TRACK push notifications (an example of a tracking aggregator): https://api.17track.net/en/doc (API v2.4)
// Register each parcel with a tag that you choose, such as your order id; every push carries it back in data.tag.
// Signature: the push has a "sign" header. It is the SHA-256 hex of the raw notification body + "/" + your security key.
//   This is a plain hash of body and key, not an HMAC.
// Event: TRACKING_UPDATED, data { number, carrier, tag, track_info.latest_status { status, sub_status }, track_info.latest_event { time_utc, description } }.
//   status is one of NotFound, InfoReceived, InTransit, Expired, AvailableForPickup, OutForDelivery, DeliveryFailure, Delivered, Exception.
// Any answer other than HTTP 200 counts as a failed push; 17TRACK retries three times, after 600, 1800 and 3600 seconds.
//   The docs name no delivery id and the signature has no timestamp, so the key below is the carrier, the parcel number, your tag and the status.
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, next_attempt (Unix ms, default 0). Helpers:
//   saveEvent(key, payload)  insert a pending row once; a repeat changes nothing
//   claimSend(key)           atomic pending -> claimed, only when next_attempt <= now; sets claimed_at; true for one caller only
//   finish(key, expected, state, id, nextAttempt) UPDATE only WHERE state = expected; save the message id
//     retry returns to pending and saves nextAttempt (the helper's retryAt); all other outcomes stop automatic sends
//   skipPending(key)         UPDATE pending -> skipped only; never overwrites a claim or an outcome
//   saveBody(key, text) / savedBody(key)  keep the exact text, so a retry sends the same body
// Your timer calls recoverAbandonedClaims first, then re-runs pending rows. 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();
// Also yours: orderForTag(tag) returns { phone, name, whatsappOk } from your own order table, or undefined.
// hasOptedOut(phone) is true if this number asked you to stop.
const { TRACK17_KEY } = process.env;
if (!TRACK17_KEY) throw new Error('Set TRACK17_KEY to your 17TRACK security key before you start');

function valid17Track(raw, header) {
  const expected = crypto.createHash('sha256').update(`${raw.toString('utf8')}/${TRACK17_KEY}`).digest('hex');
  if (typeof header !== 'string') return false;
  const got = Buffer.from(header.toLowerCase()), want = Buffer.from(expected); // compare bytes: a non-ASCII header must not throw
  return got.length === want.length && crypto.timingSafeEqual(got, want);
}

// The statuses worth a message, and the wording. Everything else is saved and skipped. The wording is an example.
const WORDING = {
  OutForDelivery: (n, o) => `Hi ${o.name}, your order ${o.id} is out for delivery (tracking ${n}).`,
  AvailableForPickup: (n, o) => `Hi ${o.name}, your order ${o.id} is ready for pickup (tracking ${n}).`,
  Delivered: (n, o) => `Hi ${o.name}, your order ${o.id} was delivered (tracking ${n}). Reply here if anything is wrong.`,
  DeliveryFailure: (n, o) => `Hi ${o.name}, the carrier could not deliver order ${o.id} (tracking ${n}). Reply here and we will sort it out.`,
};

async function processUpdate(key, data) {
  const status = data.track_info?.latest_status?.status;
  const order = await orderForTag(data.tag);
  const wording = WORDING[status];
  const phone = String(order?.phone ?? '').replace(/\D/g, '');
  if (!wording || !phone || order.whatsappOk !== true || (await hasOptedOut(phone))) return skipPending(key);
  if (!(await claimSend(key))) return; // one message per shipment and status
  let text = await savedBody(key);
  if (!text) {
    text = wording(data.number, { name: String(order.name ?? 'there').slice(0, 60), id: String(data.tag).slice(0, 40) });
    await saveBody(key, text); // a retry sends this exact text
  }
  const result = await sendWhatsApp(key, { type: 'text', to: phone, text });
  await finish(key, 'claimed', classify(result), result.id, result.retryAt);
}

app.post('/webhooks/tracking', express.raw({ type: 'application/json' }), async (req, res) => {
  if (!valid17Track(req.body, req.get('sign'))) return res.sendStatus(401);
  const event = JSON.parse(req.body.toString('utf8'));
  if (event.event !== 'TRACKING_UPDATED') return res.sendStatus(200);
  const status = event.data.track_info?.latest_status?.status;
  const key = `track-${event.data.carrier}-${event.data.number}-${event.data.tag}-${status}`; // a repeated push finds the same row
  try {
    await saveEvent(key, req.body.toString('utf8')); // durable first
  } catch {
    return res.sendStatus(500); // 17TRACK pushes it again
  }
  res.sendStatus(200); // exactly 200: any other status counts as a failed push
  processUpdate(key, event.data).catch(console.error); // a failure leaves a row for your timer
});

app.listen(3010);

What the handler does with each send result

Send resultWhat your handler does
200 server_ackWhatsApp acknowledged the send. Mark it sent and save id; this is not a delivery receipt.
202 queuedPersisted 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_unresolvedRefused 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 responsePossibly 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_conflictThe same key was used for a different message. Fix how you build the key. The first message is unchanged.
Any other 409Mark it failed. Fix the channel before scheduling another attempt.
Other 4xxThe 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.

Who may be messaged

Message only customers who agreed to WhatsApp order updates at checkout, keep the text about their parcel, and stop when they ask. The sample checks your opt-out list before every send, and recording a stop request in that list is your code. Consent rules differ by country, so check the ones that apply to you.

Questions

Does HelloHop track parcels?
No. A tracking service reads the carrier and pushes the status to your receiver. HelloHop sends the WhatsApp message you build from that status.
How do I verify a 17TRACK push?
Compute the SHA-256 hex of the raw request body, a slash and your security key, and compare it with the sign header in constant time.
How do I avoid sending the same status twice?
Save each push under the carrier, parcel number, tag and status before you answer, claim the row before you send, and use that key as the Idempotency-Key.
What should my receiver answer?
Exactly HTTP 200 once the push is saved. 17TRACK treats any other status as a failed push and retries it up to three times.
Can I use another tracking service?
Yes. Change the signature check and the field names to match that service, and keep the save, claim and send steps.

Free sandbox, forever. Upgrade when you're ready.

Start free

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.

WhatsApp Shipment Tracking Updates | HelloHop