Use cases
Event and webinar reminders over WhatsApp
A job that runs every few minutes finds registrations whose event starts within 24 hours or 1 hour, claims one reminder row per registration and slot, and sends a WhatsApp message with the join link through HelloHop. The claim means each person gets each reminder once. Send only to people who agreed to event reminders.
Facts (as of October 2026, API v1)
- Each reminder is one POST
/v1/sessions/{channel}/messagescall. HelloHop does not hold your registrations, so your own database decides who is due. - 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
- Store consent with the registration. Ask on the registration form whether the person wants WhatsApp reminders, and save the phone number with its country code and the answer.
- Create one row per slot. Every few minutes insert a reminder row for each consenting registration whose event is within the slot window. A unique key makes a repeat a no-op.
- Claim at send time. Flip the row from pending to claimed with a condition that also checks consent and that the slot is still useful. Only the run that changes the row sends.
- Send and record. Save the text, send it with the row key as the Idempotency-Key, and record sent, queued, retry, unknown or failed. A timeout is unknown and the run moves on.
The job: people who show up
A reminder a day ahead lets people put the event on their calendar. A second one an hour ahead arrives when they need the join link, and the sample puts the link in both. Each is about something the person registered for. Keep each message to the event and tell people how to stop.
The reminder job (Node.js)
The sample uses SQLite-style SQL, so keep the conditional updates if you change databases. A reminder past its useful window is skipped: a person who registers 30 minutes before the event gets only the 1 hour reminder. Claims older than five minutes become unknown for review and are never resent. The message text is an example.
// Event reminders: 24 hours and 1 hour before, with the join link.
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 tables (SQLite examples: db.run returns { changes }, db.all returns rows, db.get one row). Times are Unix ms.
// events: id, title, starts_at, tz (IANA name), join_url
// registrations: id, event_id, name, phone (digits with country code), consent (1 = agreed to event reminders)
// reminders: key (unique), reg_id, state, expires_at, claimed_at, body, message_id
const SLOTS = [
{ name: '24h', lead: 24 * 60 * 60 * 1000, cutoff: 2 * 60 * 60 * 1000 }, // due from 24 h before, dropped inside 2 h
{ name: '1h', lead: 60 * 60 * 1000, cutoff: 10 * 60 * 1000 }, // due from 1 h before, dropped inside 10 min
];
function reminderText(d) {
const when = new Intl.DateTimeFormat('en-US', {
timeZone: d.tz, weekday: 'short', day: 'numeric', month: 'short',
hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZoneName: 'short',
}).format(new Date(d.starts_at));
return `Hi ${d.name}, ${d.title} starts ${when}. Join here: ${d.join_url} Reply STOP to stop reminders.`;
}
// Run every 5 minutes. Two overlapping runs are safe: every step is a conditional update.
async function runReminders() {
const now = Date.now();
// A claim older than 5 minutes is unknown: a person looks at the chat, nothing re-sends it.
await db.run("UPDATE reminders SET state = 'unknown' WHERE state = 'claimed' AND (claimed_at IS NULL OR claimed_at < ?)", [now - 5 * 60 * 1000]);
for (const s of SLOTS) {
// One row per registration and slot. A repeat changes nothing, so a rerun never reopens a finished reminder.
await db.run(
"INSERT INTO reminders (key, reg_id, state, expires_at) SELECT r.id || '-' || ?, r.id, 'pending', e.starts_at - ? " +
"FROM registrations r JOIN events e ON e.id = r.event_id " +
"WHERE r.consent = 1 AND e.starts_at - ? <= ? AND e.starts_at - ? > ? ON CONFLICT(key) DO NOTHING",
[s.name, s.cutoff, s.lead, now, s.cutoff, now]);
}
// Too late to be useful, or the person withdrew consent: stop.
await db.run("UPDATE reminders SET state = 'skipped' WHERE state = 'pending' AND (expires_at <= ? OR NOT EXISTS (SELECT 1 FROM registrations r WHERE r.id = reminders.reg_id AND r.consent = 1))", [Date.now()]);
const due = await db.all(
"SELECT k.key, r.name, r.phone, e.title, e.starts_at, e.tz, e.join_url FROM reminders k " +
"JOIN registrations r ON r.id = k.reg_id JOIN events e ON e.id = r.event_id WHERE k.state = 'pending' ORDER BY e.starts_at LIMIT 200", []);
for (const d of due) {
// Claim at send time, while consent still stands and the slot is still useful.
const claim = await db.run(
"UPDATE reminders SET state = 'claimed', claimed_at = ? WHERE key = ? AND state = 'pending' AND expires_at > ? " +
"AND EXISTS (SELECT 1 FROM registrations r WHERE r.id = reminders.reg_id AND r.consent = 1)", [Date.now(), d.key, Date.now()]);
if (claim.changes !== 1) continue;
// Save the exact text once, so a retry sends the same body under the same key.
await db.run('UPDATE reminders SET body = ? WHERE key = ? AND body IS NULL', [reminderText(d), d.key]);
const { body } = await db.get('SELECT body FROM reminders WHERE key = ?', [d.key]);
const result = await sendWhatsApp(d.key, { type: 'text', to: d.phone, text: body });
const outcome = classify(result);
await db.run("UPDATE reminders SET state = ?, message_id = ? WHERE key = ? AND state = 'claimed'", [outcome === 'retry' ? 'pending' : outcome, result.id ?? null, d.key]);
if (outcome === 'retry') break; // the helper waited at most 30 seconds; the next run resumes with the same key
}
}
setInterval(() => runReminders().catch(console.error), 5 * 60 * 1000);The same call from the shell
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: REGISTRATION_ID-1h" \
-d '{"type":"text","to":"66XXXXXXXXX","text":"Hi Anna, the product demo starts Tue, Dec 1, 10:00 GMT+7. Join here: https://example.com/join/abc Reply STOP to stop reminders."}'What the job 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.
Stopping reminders
A STOP reply arrives as a message event. Set consent to 0 for that number and the claim condition stops the rest. The receiver in the broadcast guide shows the pattern, including resolving a LID sender to a stored phone.
Common mistakes
- Using one Idempotency-Key for both slots. The key is per message: the sample appends the slot name.
- Reminding at a fixed clock time. Windows relative to the start survive a late run and a late registration.
- Showing the start time without a time zone. The sample formats it in the event's zone and prints the zone name.
- Resending a timed-out reminder without looking at the chat.
- Rescheduling the event without deciding what the existing rows mean. Their keys are fixed, so delete unsent rows or use a new slot name.
Questions
- Can I send 24 hour and 1 hour reminders?
- Yes. The sample defines two slots. Each gets its own row and key per registration, so each person gets each reminder once.
- What if someone registers late?
- Each slot has a cutoff: 2 hours before the start for the 24 hour reminder and 10 minutes for the 1 hour reminder. A registration inside a cutoff gets no reminder for that slot.
- How do I include the join link?
- Put the URL in the text field of the send call, as the sample does.
- What if a reminder times out?
- Treat it as possibly delivered. Record it as unknown and look at the chat before any resend.
- Can I try it without paying?
- Yes. Every account has one free sandbox channel that allows 180 messages sent a day.
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.