Use cases

Appointment reminders over WhatsApp

A small script on a schedule finds appointments starting in about a day, claims each one so it is only reminded once, and sends a WhatsApp message through HelloHop. Customers reply 1 to confirm or 2 to reschedule, and your webhook receiver reads the reply. Message only customers who agreed to reminders.

Facts (as of October 2026, API v1)

  • The reminder is one POST /v1/sessions/{channel}/messages call per appointment. HelloHop does not read your calendar, so your own booking system or database decides who is due.
  • A customer reply arrives as a message event of type text, and sender_jid carries the phone number whenever it is known.
  • 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.
  • When HopSmart is on for a channel, ordinary text sends answer 202 with status queued after durable acceptance. Acceptance is not delivery. See the sending docs.
  • 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. Store consent with the booking. Ask at booking time whether the customer wants a WhatsApp reminder, and save the phone number with its country code and the answer.
  2. Find appointments that are due. Run a scheduled job every 15 minutes that selects appointments starting in 23 to 24 hours, with consent, and no reminder state yet.
  3. Claim each one. Update the reminder state from empty to claimed with a condition. Only a run that changes the row may send.
  4. Send and record the result. Send with the appointment id and slot in the Idempotency-Key. Record sent, queued, retry, unknown or failed. A timeout or a lost connection is unknown, and the run moves on to the next appointment.
  5. Read the reply. Set a webhook receiver for message events and update the booking when the customer answers.

The job: fewer empty chairs

A missed appointment costs the slot and the time. A reminder the day before, with a one-character way to answer, lets people confirm or move the booking while you can still fill the slot. The reminder is about something the customer booked, so it is a message they expect.

The scheduled job (Python)

The sample uses SQLite. Add the claimed_at, message_id and next_attempt columns before running it. Recovery marks claims older than five minutes unknown for review, including a crash before the send or a failed outcome write. It never resends those rows. The sample never sleeps inside a claim: a retry outcome releases the row with next_attempt set from Retry-After, and the first cron run after that time sends it again with the same key and body. Keep the conditional updates when changing databases. The reminder text is an example.

Python: reminders.py
import os
import sqlite3
import time
from datetime import datetime
from zoneinfo import ZoneInfo
import requests

API = 'https://api.hellohop.app/v1'
CHANNEL_ID = os.environ['CHANNEL_ID']
CHANNEL_TOKEN = os.environ['CHANNEL_TOKEN']
# Table: id, name, phone, starts_at (UTC: YYYY-MM-DD HH:MM:SS), tz (IANA name),
# consent, reminder_state, claimed_at (Unix seconds), message_id, next_attempt (Unix seconds).
db = sqlite3.connect('appointments.db')


def send(key, message):
    """One send. Never raises: status 0 means a timeout or a lost connection. The third value is the time a retry is due."""
    try:
        res = requests.post(
            f'{API}/sessions/{CHANNEL_ID}/messages',
            headers={'Authorization': f'Bearer {CHANNEL_TOKEN}', 'Idempotency-Key': key},
            json=message,
            timeout=15,
        )
        try:
            body = res.json()
        except ValueError:
            body = {}
        retry_at = None
        if classify(res.status_code, body) == 'retry':  # no sleeping inside the claim: say when the row is due again
            h = res.headers.get('Retry-After', '')
            retry_at = time.time() + (int(h) if h.isdigit() else 1)  # a date value falls back to 1 second
        return res.status_code, body, retry_at
    except requests.RequestException:
        return 0, {}, None


def classify(status, body):
    """sent (server_ack), queued, retry, unknown or failed."""
    if status == 200:
        return 'sent'  # server_ack, not delivered
    if status == 202:
        return 'queued'  # observe webhooks, do not resend
    refused = ('upstream_unavailable', 'hopsmart_settings_unavailable', 'operator_unresolved')
    if status == 429 or (status == 503 and (body.get('ambiguous') is False or body.get('code') in refused)):
        return 'retry'
    if status == 0 or status >= 500 or body.get('code') == 'idempotency_uncertain':
        return 'unknown'
    return 'failed'


# Add claimed_at REAL, message_id TEXT and next_attempt REAL columns to your appointments table first.
# Run from cron every 15 minutes. Recover abandoned claims as unknown, never re-send them.
db.execute("UPDATE appointments SET reminder_state = 'unknown' WHERE reminder_state = 'claimed' AND (claimed_at IS NULL OR claimed_at < ?)",
           (time.time() - 5 * 60,))
db.commit()
# Pick appointments starting in 23 to 24 hours.
due = db.execute(
    """SELECT id, name, phone, starts_at, tz FROM appointments
       WHERE consent = 1 AND reminder_state IS NULL AND (next_attempt IS NULL OR next_attempt <= ?)
         AND starts_at BETWEEN datetime('now', '+23 hours') AND datetime('now', '+24 hours')""",
    (time.time(),),
).fetchall()

for appt_id, name, phone, starts_at, tz in due:
    # Claim first. Only one run can flip NULL to claimed.
    claim = db.execute(
        "UPDATE appointments SET reminder_state = 'claimed', claimed_at = ? WHERE id = ? AND reminder_state IS NULL",
        (time.time(), appt_id),
    )
    db.commit()
    if claim.rowcount != 1:
        continue
    # Show the time in the customer's own zone, never raw UTC.
    local = datetime.fromisoformat(starts_at).replace(tzinfo=ZoneInfo('UTC')).astimezone(ZoneInfo(tz))
    when = local.strftime('%a %d %b at %H:%M')
    status, body, retry_at = send(
        f'reminder-{appt_id}-24h',
        {
            'type': 'text',
            'to': phone,  # digits with country code, for example 66XXXXXXXXX
            'text': f'Hi {name}, a reminder of your appointment on {when}. Reply 1 to confirm or 2 to reschedule.',
        },
    )
    outcome = classify(status, body)
    # retry releases the claim and the first run after next_attempt sends again. unknown means look before any resend.
    state = None if outcome == 'retry' else outcome
    db.execute("UPDATE appointments SET reminder_state = ?, message_id = ?, next_attempt = ? WHERE id = ? AND reminder_state = 'claimed'",
               (state, body.get('id'), retry_at, appt_id))
    db.commit()

The same call from the shell

curl (example message text)
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: reminder-APPOINTMENT_ID-24h" \
  -d '{"type":"text","to":"66XXXXXXXXX","text":"Hi Anna, a reminder of your appointment tomorrow at 10:00. Reply 1 to confirm or 2 to reschedule."}'

Read the replies

Set a receiver for message events with PUT /v1/sessions/{channel}/webhooks and verify each delivery's signature as in the signature guide. A reply of 1 or 2 arrives as type text in payload.text. Match it to the open appointment for that number, save the event id so a retry does nothing, answer 200, then do the work. The receiver in the cash on delivery guide has the same shape.

What the job 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.

Send only to customers who agreed

Reminders suit people who booked and agreed to them. Keep each message to the booking, offer a way to stop, and remove a number from reminders as soon as the customer asks.

Common mistakes

Questions

Does HelloHop connect to my calendar?
No. Your own booking system or database decides who is due and calls HelloHop with the text. An automation tool can feed that job from a calendar.
How do I avoid reminding someone twice?
Claim the appointment with a conditional update before you send, and use a per-message Idempotency-Key. A repeat of the same key and body within 24 hours returns the first result.
Can customers confirm by replying?
Yes. Their reply reaches your webhook receiver as a text message event. The sample asks for 1 to confirm or 2 to reschedule, and you can send a poll instead.
What if a reminder times out?
Treat it as possibly delivered. Record it as unknown, and look at the chat before you send anything again.
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 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.

Appointment Reminders over WhatsApp | HelloHop