# Let the customer confirm, cancel or change an appointment or an order

_Yes — three buttons Confirm / Cancel / Change, whose id carries the reference (e.g. appt:confirm:A123); the tap comes back in button_id, no template within 24 h._

Keywords: confirm appointment, cancel appointment, change appointment, confirm order, cancel order, reschedule, postpone, 3 buttons, button id, reference, button_id, reminder with reply

## Scenario

You want the customer to confirm they are coming, cancel, or ask to change. You send three buttons; each button's `id` holds the action **and** the appointment or order reference. When the customer taps, your server receives that `id` and knows what to do with which booking, without asking again.

**Yes, it is possible without a template**, with 3 quick-reply buttons, if the customer wrote to you in the last 24 h (for example because they just answered your reminder). For a reminder sent the day before, outside 24 h, the first message must be a [template](https://console.geskap.com/docs/rappel-rendez-vous-veille?lang=en) with buttons; the buttons below take over once the customer has replied.

## Conversation

```text
You      : Awa, is your appointment on Tuesday the 3rd at 09:00 still OK? (ref. A123)
           [ Confirm ]  [ Cancel ]  [ Change ]
Customer : (taps "Cancel")
Webhook  : message.inbound  type=text  text="Cancel"  button_id="appt:cancel:A123"
You      : Your appointment A123 is cancelled.
           [ Book again ]
```

## Code

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/messages/interactive" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+237690000001",
  "body": "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
  "buttons": [
    { "id": "appt:confirm:A123", "title": "Confirmer" },
    { "id": "appt:cancel:A123", "title": "Annuler" },
    { "id": "appt:change:A123", "title": "Modifier" }
  ]
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/messages/interactive", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+237690000001",
    "body": "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
    "buttons": [
      { "id": "appt:confirm:A123", "title": "Confirmer" },
      { "id": "appt:cancel:A123", "title": "Annuler" },
      { "id": "appt:change:A123", "title": "Modifier" }
    ]
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/messages/interactive");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("GESKAP_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "to" => "+237690000001",
    "body" => "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
    "buttons" => [
      ["id" => "appt:confirm:A123", "title" => "Confirmer"],
      ["id" => "appt:cancel:A123", "title" => "Annuler"],
      ["id" => "appt:change:A123", "title" => "Modifier"],
    ],
  ]),
]);
$res = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $res;
```

```python
# Python
import os, requests

res = requests.request(
    "POST",
    "https://wa-api.geskap.com/v1/messages/interactive",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "to": "+237690000001",
        "body": "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
        "buttons": [
            {"id": "appt:confirm:A123", "title": "Confirmer"},
            {"id": "appt:cancel:A123", "title": "Annuler"},
            {"id": "appt:change:A123", "title": "Modifier"},
        ],
    },
    timeout=15,
)
print(res.status_code, res.json())
```

On the receiving side, split the `id`: action and reference.

```js
// data = the "data" field of the message.inbound webhook (see the recipe "Know which button…")
const [scope, action, ref] = (data.button_id || "").split(":"); // "appt", "cancel", "A123"
if (scope === "appt") {
  const appt = await db.findAppointment(ref);        // your database: re-read the booking
  if (action === "confirm") await db.setStatus(appt, "confirmed");
  if (action === "cancel")  await db.setStatus(appt, "cancelled");
  if (action === "change")  await startReschedule(appt, data.from); // send slots back: see below
}
```

For "Change", follow up with a [slot menu](https://console.geskap.com/docs/choix-creneau-places?lang=en). For reception and the signature, see [Know which button or list row the customer tapped](https://console.geskap.com/docs/recuperer-le-clic?lang=en).

## Exact limits

| Item | Limit |
|---|---|
| Buttons | 1 to 3 |
| Button title | 20 characters |
| Button `id` | 256 characters: plenty for `action:reference` |
| Message text (`body`) | 1,024 characters |

> **Pitfall:** a button carries no hidden data other than its `id`: everything you need on the way back (action, reference) must be **in the `id`**. Never put sensitive data in it (amount, ID document): a reference is enough, you re-read the rest on your side.

> **Pitfall:** a customer can tap an old button later. When it comes back, re-read the booking's state (already cancelled? already past?) before acting, and answer accordingly. An interactive message cannot be sent outside the 24 h window (`400` "Hors de la fenêtre de 24h"): your confirmation reply must go out within 24 h of the tap, which is the case since the tap opens the window.

_Proof — verified in the API source: api_schemas.py, public_api.py, webhooks.py ; applied by the WhatsApp demo: sante._

---

# Faire confirmer, annuler ou modifier un rendez-vous ou une commande par le client

_Oui — trois boutons Confirmer / Annuler / Modifier, dont l'id porte la référence (ex. appt:confirm:A123) ; le clic vous revient dans button_id, sans template dans les 24 h._

Mots-clés: confirmer rendez-vous, annuler rendez-vous, modifier rendez-vous, confirmer commande, annuler commande, reporter, déplacer, 3 boutons, id du bouton, référence, button_id, rappel avec réponse

## Scénario

Vous voulez que le client confirme sa venue, annule ou demande à changer. Vous envoyez trois boutons ; l'`id` de chaque bouton contient l'action **et** la référence du rendez-vous ou de la commande. Quand le client touche, votre serveur reçoit cet `id` et sait quoi faire de quelle réservation, sans rien redemander.

**Oui, c'est possible sans template**, avec 3 boutons de réponse rapide, si le client vous a écrit dans les dernières 24 h (par exemple parce qu'il vient de répondre à votre rappel). Pour un rappel envoyé la veille, hors des 24 h, le premier message doit être un [template](https://console.geskap.com/docs/rappel-rendez-vous-veille) à boutons ; les boutons ci-dessous prennent le relais dès que le client a répondu.

## Conversation

```text
Vous    : Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)
          [ Confirmer ]  [ Annuler ]  [ Modifier ]
Client  : (touche « Annuler »)
Webhook : message.inbound  type=text  text="Annuler"  button_id="appt:cancel:A123"
Vous    : Votre RDV A123 est annulé.
          [ Reprendre RDV ]
```

## Code

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/messages/interactive" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+237690000001",
  "body": "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
  "buttons": [
    { "id": "appt:confirm:A123", "title": "Confirmer" },
    { "id": "appt:cancel:A123", "title": "Annuler" },
    { "id": "appt:change:A123", "title": "Modifier" }
  ]
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/messages/interactive", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+237690000001",
    "body": "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
    "buttons": [
      { "id": "appt:confirm:A123", "title": "Confirmer" },
      { "id": "appt:cancel:A123", "title": "Annuler" },
      { "id": "appt:change:A123", "title": "Modifier" }
    ]
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/messages/interactive");
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("GESKAP_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "to" => "+237690000001",
    "body" => "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
    "buttons" => [
      ["id" => "appt:confirm:A123", "title" => "Confirmer"],
      ["id" => "appt:cancel:A123", "title" => "Annuler"],
      ["id" => "appt:change:A123", "title" => "Modifier"],
    ],
  ]),
]);
$res = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $res;
```

```python
# Python
import os, requests

res = requests.request(
    "POST",
    "https://wa-api.geskap.com/v1/messages/interactive",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "to": "+237690000001",
        "body": "Awa, votre RDV du mardi 3 à 09:00 est-il toujours bon ? (réf. A123)",
        "buttons": [
            {"id": "appt:confirm:A123", "title": "Confirmer"},
            {"id": "appt:cancel:A123", "title": "Annuler"},
            {"id": "appt:change:A123", "title": "Modifier"},
        ],
    },
    timeout=15,
)
print(res.status_code, res.json())
```

Côté réception, découpez l'`id` : action et référence.

```js
// data = le champ "data" du webhook message.inbound (voir la recette « Savoir quel bouton… »)
const [scope, action, ref] = (data.button_id || "").split(":"); // "appt", "cancel", "A123"
if (scope === "appt") {
  const appt = await db.findAppointment(ref);        // votre base : relisez la réservation
  if (action === "confirm") await db.setStatus(appt, "confirmed");
  if (action === "cancel")  await db.setStatus(appt, "cancelled");
  if (action === "change")  await startReschedule(appt, data.from); // renvoyez des créneaux : voir ci-dessous
}
```

Pour « Modifier », enchaînez avec un [menu de créneaux](https://console.geskap.com/docs/choix-creneau-places). Pour la réception et la signature, voir [Savoir quel bouton ou quelle ligne le client a touché](https://console.geskap.com/docs/recuperer-le-clic).

## Limites exactes

| Élément | Limite |
|---|---|
| Boutons | 1 à 3 |
| Titre d'un bouton | 20 caractères |
| `id` d'un bouton | 256 caractères : largement assez pour `action:référence` |
| Texte du message (`body`) | 1 024 caractères |

> **Piège :** le bouton ne porte pas de données cachées autres que son `id` : tout ce dont vous avez besoin au retour (action, référence) doit être **dans l'`id`**. N'y mettez jamais de donnée sensible (montant, pièce d'identité) : une référence suffit, vous relisez le reste chez vous.

> **Piège :** un client peut toucher un vieux bouton plus tard. Au retour, relisez l'état de la réservation (déjà annulée ? déjà passée ?) avant d'agir, et répondez en conséquence. Le bouton d'un message de service ne s'envoie plus hors des 24 h (`400` « Hors de la fenêtre de 24h ») : la réponse de votre confirmation doit partir dans les 24 h suivant le clic, ce qui est le cas puisque le clic ouvre la fenêtre.

_Preuve — vérifié dans le code de l'API : api_schemas.py, public_api.py, webhooks.py ; appliqué par la démo WhatsApp : sante._

Support: WhatsApp +237 6 56 09 88 31 · All recipes: https://wa-api.geskap.com/llms.txt
