# Ask the customer for a rating from 1 to 5

_Yes — a list of 5 rows (1 to 5), not buttons: a message carries only 3 buttons; the rating comes back in button_id, no template within 24 h._

Keywords: rating, rate, score, 1 to 5, stars, satisfaction, review, survey, NPS, evaluate, 5 buttons, more than 3 buttons, feedback

## Scenario

After a service, you ask "How was your visit?" and the customer answers with a 1 to 5 rating in one tap. Your server reads the rating in `button_id`.

**Yes, it is possible without a template**, as long as the customer wrote to you in the last 24 h (the case at the end of an exchange: they just replied). **Not with five buttons**: an interactive message carries **3 buttons at most**. For 5 ratings, use a **list of 5 rows**; to stay with buttons, go down to 3 levels (Meh / Good / Excellent). Outside 24 h, a survey message must be a [template](https://console.geskap.com/docs/enquete-satisfaction?lang=en).

## Conversation

```text
You      : Thank you for your visit Awa. What rating do you give us?
           [ Rate ]
Customer : (taps "Rate", the list opens)
             - 5 · Excellent
             - 4 · Good
             - 3 · Average
             - 2 · Disappointing
             - 1 · Bad
Customer : (taps "4 · Good")
Webhook  : message.inbound  type=text  text="4 · Good"  button_id="rate:4"
You      : Thanks for your 4/5!
```

## Code

Option A, the 5-row list (the finest):

```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": "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
  "list": {
    "button": "Noter",
    "sections": [
      {
        "rows": [
          { "id": "rate:5", "title": "5 · Excellent" },
          { "id": "rate:4", "title": "4 · Bien" },
          { "id": "rate:3", "title": "3 · Moyen" },
          { "id": "rate:2", "title": "2 · Décevant" },
          { "id": "rate:1", "title": "1 · Mauvais" }
        ]
      }
    ]
  }
}'
```

```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": "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
    "list": {
      "button": "Noter",
      "sections": [
        {
          "rows": [
            { "id": "rate:5", "title": "5 · Excellent" },
            { "id": "rate:4", "title": "4 · Bien" },
            { "id": "rate:3", "title": "3 · Moyen" },
            { "id": "rate:2", "title": "2 · Décevant" },
            { "id": "rate:1", "title": "1 · Mauvais" }
          ]
        }
      ]
    }
  }),
});
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" => "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
    "list" => [
      "button" => "Noter",
      "sections" => [
        [
          "rows" => [
            ["id" => "rate:5", "title" => "5 · Excellent"],
            ["id" => "rate:4", "title" => "4 · Bien"],
            ["id" => "rate:3", "title" => "3 · Moyen"],
            ["id" => "rate:2", "title" => "2 · Décevant"],
            ["id" => "rate:1", "title" => "1 · Mauvais"],
          ],
        ],
      ],
    ],
  ]),
]);
$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": "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
        "list": {
            "button": "Noter",
            "sections": [
                {
                    "rows": [
                        {"id": "rate:5", "title": "5 · Excellent"},
                        {"id": "rate:4", "title": "4 · Bien"},
                        {"id": "rate:3", "title": "3 · Moyen"},
                        {"id": "rate:2", "title": "2 · Décevant"},
                        {"id": "rate:1", "title": "1 · Mauvais"},
                    ],
                },
            ],
        },
    },
    timeout=15,
)
print(res.status_code, res.json())
```

Option B, three buttons (faster, less precise). The `id` keeps the scale out of 5: `rate:1`, `rate:3`, `rate:5`.

```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": "Merci pour votre visite Awa. Comment était-ce ?",
  "buttons": [
    { "id": "rate:1", "title": "Bof" },
    { "id": "rate:3", "title": "Bien" },
    { "id": "rate:5", "title": "Excellent" }
  ]
}'
```

```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": "Merci pour votre visite Awa. Comment était-ce ?",
    "buttons": [
      { "id": "rate:1", "title": "Bof" },
      { "id": "rate:3", "title": "Bien" },
      { "id": "rate:5", "title": "Excellent" }
    ]
  }),
});
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" => "Merci pour votre visite Awa. Comment était-ce ?",
    "buttons" => [
      ["id" => "rate:1", "title" => "Bof"],
      ["id" => "rate:3", "title" => "Bien"],
      ["id" => "rate:5", "title" => "Excellent"],
    ],
  ]),
]);
$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": "Merci pour votre visite Awa. Comment était-ce ?",
        "buttons": [
            {"id": "rate:1", "title": "Bof"},
            {"id": "rate:3", "title": "Bien"},
            {"id": "rate:5", "title": "Excellent"},
        ],
    },
    timeout=15,
)
print(res.status_code, res.json())
```

Reception, identical in both cases:

```js
const m = /^rate:([1-5])$/.exec(data.button_id || "");
if (m) await db.saveRating(data.from, Number(m[1])); // the rating is in the id, never in the title
```

The signature and reading `button_id`: see [Know which button or list row the customer tapped](https://console.geskap.com/docs/recuperer-le-clic?lang=en). For a full survey with a comment, see [Satisfaction survey](https://console.geskap.com/docs/enquete-satisfaction?lang=en).

## Exact limits

| Item | Limit |
|---|---|
| Buttons per message | 3 at most (so no 5 ratings as buttons) |
| Rows per list | 10 in total: 5 ratings fit easily |
| Button title | 20 characters |
| Row title | 24 characters |

> **Pitfall:** there is no "stars" component: a rating is a choice among rows or buttons, with a title you write ("4 · Good"). Do not count on drawn stars. Do not use an emoji as the only cue: put the digit.

> **Pitfall:** a customer can also type "4" by hand. Then `button_id` is `null` and the rating is in `text`: accept both, check it is a digit from 1 to 5, otherwise send the list again.

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

---

# Demander une note de 1 à 5 au client

_Oui — une liste de 5 lignes (1 à 5), pas des boutons : un message ne porte que 3 boutons ; la note revient dans button_id, sans template dans les 24 h._

Mots-clés: note, noter, notation, 1 à 5, étoiles, satisfaction, avis, sondage, NPS, évaluer, 5 boutons, plus de 3 boutons, enquête

## Scénario

Après un service, vous demandez « Comment était votre visite ? » et le client répond par une note de 1 à 5 en un geste. Votre serveur lit la note dans `button_id`.

**Oui, c'est possible sans template**, tant que le client vous a écrit dans les dernières 24 h (le cas de la fin d'un échange : il vient de répondre). **Pas avec cinq boutons** : un message interactif porte **3 boutons au plus**. Pour 5 notes, utilisez une **liste de 5 lignes** ; pour rester en boutons, passez à 3 niveaux (Bof / Bien / Excellent). Hors des 24 h, un message d'enquête doit être un [template](https://console.geskap.com/docs/enquete-satisfaction).

## Conversation

```text
Vous    : Merci pour votre visite Awa. Quelle note nous donnez-vous ?
          [ Noter ]
Client  : (touche « Noter », la liste s'ouvre)
            - 5 · Excellent
            - 4 · Bien
            - 3 · Moyen
            - 2 · Décevant
            - 1 · Mauvais
Client  : (touche « 4 · Bien »)
Webhook : message.inbound  type=text  text="4 · Bien"  button_id="rate:4"
Vous    : Merci pour votre note de 4/5 !
```

## Code

Option A, la liste de 5 lignes (la plus fine) :

```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": "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
  "list": {
    "button": "Noter",
    "sections": [
      {
        "rows": [
          { "id": "rate:5", "title": "5 · Excellent" },
          { "id": "rate:4", "title": "4 · Bien" },
          { "id": "rate:3", "title": "3 · Moyen" },
          { "id": "rate:2", "title": "2 · Décevant" },
          { "id": "rate:1", "title": "1 · Mauvais" }
        ]
      }
    ]
  }
}'
```

```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": "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
    "list": {
      "button": "Noter",
      "sections": [
        {
          "rows": [
            { "id": "rate:5", "title": "5 · Excellent" },
            { "id": "rate:4", "title": "4 · Bien" },
            { "id": "rate:3", "title": "3 · Moyen" },
            { "id": "rate:2", "title": "2 · Décevant" },
            { "id": "rate:1", "title": "1 · Mauvais" }
          ]
        }
      ]
    }
  }),
});
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" => "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
    "list" => [
      "button" => "Noter",
      "sections" => [
        [
          "rows" => [
            ["id" => "rate:5", "title" => "5 · Excellent"],
            ["id" => "rate:4", "title" => "4 · Bien"],
            ["id" => "rate:3", "title" => "3 · Moyen"],
            ["id" => "rate:2", "title" => "2 · Décevant"],
            ["id" => "rate:1", "title" => "1 · Mauvais"],
          ],
        ],
      ],
    ],
  ]),
]);
$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": "Merci pour votre visite Awa. Quelle note nous donnez-vous ?",
        "list": {
            "button": "Noter",
            "sections": [
                {
                    "rows": [
                        {"id": "rate:5", "title": "5 · Excellent"},
                        {"id": "rate:4", "title": "4 · Bien"},
                        {"id": "rate:3", "title": "3 · Moyen"},
                        {"id": "rate:2", "title": "2 · Décevant"},
                        {"id": "rate:1", "title": "1 · Mauvais"},
                    ],
                },
            ],
        },
    },
    timeout=15,
)
print(res.status_code, res.json())
```

Option B, trois boutons (plus rapide, moins précis). L'`id` garde l'échelle sur 5 : `rate:1`, `rate:3`, `rate:5`.

```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": "Merci pour votre visite Awa. Comment était-ce ?",
  "buttons": [
    { "id": "rate:1", "title": "Bof" },
    { "id": "rate:3", "title": "Bien" },
    { "id": "rate:5", "title": "Excellent" }
  ]
}'
```

```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": "Merci pour votre visite Awa. Comment était-ce ?",
    "buttons": [
      { "id": "rate:1", "title": "Bof" },
      { "id": "rate:3", "title": "Bien" },
      { "id": "rate:5", "title": "Excellent" }
    ]
  }),
});
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" => "Merci pour votre visite Awa. Comment était-ce ?",
    "buttons" => [
      ["id" => "rate:1", "title" => "Bof"],
      ["id" => "rate:3", "title" => "Bien"],
      ["id" => "rate:5", "title" => "Excellent"],
    ],
  ]),
]);
$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": "Merci pour votre visite Awa. Comment était-ce ?",
        "buttons": [
            {"id": "rate:1", "title": "Bof"},
            {"id": "rate:3", "title": "Bien"},
            {"id": "rate:5", "title": "Excellent"},
        ],
    },
    timeout=15,
)
print(res.status_code, res.json())
```

Réception, identique dans les deux cas :

```js
const m = /^rate:([1-5])$/.exec(data.button_id || "");
if (m) await db.saveRating(data.from, Number(m[1])); // la note est dans l'id, jamais dans le libellé
```

La signature et la lecture de `button_id` : voir [Savoir quel bouton ou quelle ligne le client a touché](https://console.geskap.com/docs/recuperer-le-clic). Pour une enquête complète avec commentaire, voir [Enquête de satisfaction](https://console.geskap.com/docs/enquete-satisfaction).

## Limites exactes

| Élément | Limite |
|---|---|
| Boutons par message | 3 maximum (donc pas 5 notes en boutons) |
| Lignes par liste | 10 au total : 5 notes tiennent largement |
| Titre d'un bouton | 20 caractères |
| Titre d'une ligne | 24 caractères |

> **Piège :** il n'existe pas de composant « étoiles » : une note est un choix parmi des lignes ou des boutons, avec un titre que vous écrivez (« 4 · Bien »). Ne comptez pas sur des étoiles dessinées. N'utilisez pas d'émoji comme seule indication : mettez le chiffre.

> **Piège :** un client peut aussi taper « 4 » à la main. Dans ce cas `button_id` vaut `null` et la note est dans `text` : acceptez les deux, validez que c'est un chiffre de 1 à 5, sinon renvoyez la liste.

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

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