# Cookbook

## Appointment reminder

Template, category `UTILITY`, language `de`:

```
POST /api/v1/templates
{"name": "termin_erinnerung", "language": "de", "category": "UTILITY",
 "body": "Hallo {{1}}, wir erinnern dich an deinen Termin am {{2}} um {{3}} Uhr bei {{4}}. Antworte mit JA zum Bestätigen oder schreib uns, wenn du verschieben musst.",
 "examples": ["Max", "Dienstag, 14.10.", "09:00", "Salon Bellevue"]}
```

Send it 24 hours before the appointment, with an idempotency key so a retried job never sends twice:

```python
httpx.post(f"{BASE}/api/v1/messages",
           headers={"Authorization": f"Bearer {key}", "Idempotency-Key": f"booking-{b.id}-reminder-24h"},
           json={"to": b.phone, "template": "termin_erinnerung", "language": "de",
                 "params": [b.first_name, b.date_label, b.time_label, b.shop_name], "number_id": b.relay_number_id})
```

Keep it neutral. "Book your next visit and get 10 % off" turns a reminder into marketing, which Meta charges at the marketing rate.

## Confirmation with a reply

Customers answer the reminder with free text. Read it from the `messages` webhook:

```python
for change in (c for e in payload["entry"] for c in e["changes"]):
    for msg in change["value"].get("messages", []):
        if msg["type"] == "text" and msg["text"]["body"].strip().lower() in {"ja", "yes", "ok"}:
            confirm_booking(phone=msg["from"])
```

With [quick-reply buttons](/docs/messages) ("Bestätigen", "Absagen") the customer taps instead of typing:

```python
for change in (c for e in payload["entry"] for c in e["changes"]):
    for msg in change["value"].get("messages", []):
        if msg["type"] == "button":
            booking = booking_by_wamid(msg["context"]["id"])  # wa_message_id from POST /messages
            if msg["button"]["text"] == "Bestätigen":
                confirm_booking(booking)
            else:
                cancel_booking(booking)
```

Within 24 hours of that reply you can answer with free text (`"text": "Danke, bis Dienstag!"`). Replies sent through the API are billed by Meta since 1 October 2026; replies typed in the app stay free.

## Cancellation notice

A separate `UTILITY` template (`termin_abgesagt`) with the date and a phone number to rebook. Send it as soon as the booking is cancelled; idempotency key `booking-{id}-cancelled`.

## Several shops in one account

Create an [onboarding link](/docs/onboarding-links) per shop with your customer id as `external_ref`, store the `number_id` from `relay.number.connected`, and pass `number_id` on every send.

## Mark the integration as tested

Run the whole flow with a test key first ([Test mode](/docs/test-mode)): send the reminder, simulate the "JA" with `POST /api/v1/test/inbound`, check your webhook handling, then switch to a live key.
