# Recognise a customer by their WhatsApp number

_Yes: the from field of every message.inbound is the sender's number in E.164 format; use it as the key of your customer record. It identifies the phone, not the person: for a sensitive action, add a PIN._

Keywords: recognise a customer, identify a customer, phone number, from, E.164, customer record, known customer, unknown customer, CRM, customer database, authentication by number, who is writing to me, find the customer, number matching, contact name

## Scenario

A customer writes "Where is my order?". Your server must know **who** it is, find their record and answer with their data, without asking for a name or a customer number.

**Yes.** Every received message reaches your webhook with `data.from`: the sender's number, in E.164 format (`+237690000001`). It is a value given by WhatsApp, not typed by the customer. Make it the lookup key of your customer database.

## Conversation

```text
Customer : Where is my order?
Webhook  : message.inbound  from=+237690000001  contact_name="Awa"  text="Where is my order?"
Server   : record found by number → order CMD-1042, "being prepared"
You      : Hello Awa, your order CMD-1042 is being prepared.
```

## Code

Look the record up by `from`, then answer the same number (`to` = `from`):

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/messages/reply" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+237690000001",
  "text": "Bonjour Awa, votre commande CMD-1042 est en préparation.",
  "from": "100000000000001"
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/messages/reply", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+237690000001",
    "text": "Bonjour Awa, votre commande CMD-1042 est en préparation.",
    "from": "100000000000001"
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/messages/reply");
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",
    "text" => "Bonjour Awa, votre commande CMD-1042 est en préparation.",
    "from" => "100000000000001",
  ]),
]);
$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/reply",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "to": "+237690000001",
        "text": "Bonjour Awa, votre commande CMD-1042 est en préparation.",
        "from": "100000000000001",
    },
    timeout=15,
)
print(res.status_code, res.json())
```

On your server, the lookup is a plain number comparison:

```js
// Node.js
// Webhook handler body: data is the "data" object of a message.inbound event.
function onInbound(data) {
  const phone = data.from;                       // "+237690000001" (E.164)
  const customer = customersByPhone.get(phone);  // your own table, keys normalised to E.164
  if (!customer) return replyUnknown(phone);     // propose to sign up
  return answerFor(customer, data.text);
}
```

If no record exists, do not answer with an error: offer to sign up or open a file with a [step-by-step form](https://console.geskap.com/docs/formulaire-pas-a-pas?lang=en), or route to [a human](https://console.geskap.com/docs/faq-ia-humain?lang=en).

> **Pitfall:** normalise the numbers in **your** database to E.164 before comparing (`+237690000001`, no spaces or dashes, with the country code). A customer saved as `6 90 00 00 01` will never be found by a string comparison.

> **Pitfall:** `from` identifies a **phone**, not a person. A phone is lent, lost, shared in a family. To read a balance, a history or confirm a payment, do not rely on the number alone: see [Sensitive data: single-use link and PIN](https://console.geskap.com/docs/donnees-sensibles-lien-pin?lang=en).

> **Pitfall:** `contact_name` is the WhatsApp profile name, chosen and editable by the customer. Fine to say "Hello Awa", never to identify someone or to decide an access right.

> **Pitfall:** with several WhatsApp numbers, answer with the event's `number` field as `from`, so the customer finds the same conversation: see [Several numbers](https://console.geskap.com/docs/plusieurs-numeros?lang=en).

To receive these events: [Webhook: verify the signature](https://console.geskap.com/docs/webhook-verifier-signature?lang=en). To plug them into an existing tool: [Webhook to n8n, Zapier or a CRM](https://console.geskap.com/docs/webhook-n8n-zapier-crm-llm?lang=en).

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

---

# Reconnaître un client à son numéro WhatsApp

_Oui : le champ from de chaque message.inbound est le numéro de l'expéditeur au format E.164 ; utilisez-le comme clé de votre fiche client. Il identifie le téléphone, pas la personne : pour une action sensible, ajoutez un PIN._

Mots-clés: reconnaître un client, identifier un client, numéro de téléphone, from, E.164, fiche client, client connu, client inconnu, CRM, base clients, authentification par numéro, qui m'écrit, retrouver le client, correspondance numéro, nom du contact

## Scénario

Un client écrit « Où en est ma commande ? ». Votre serveur doit savoir **qui** c'est, retrouver sa fiche et répondre avec ses données, sans lui demander son nom ni un numéro de client.

**Oui.** Chaque message reçu arrive sur votre webhook avec `data.from` : le numéro de l'expéditeur, au format E.164 (`+237690000001`). C'est une valeur donnée par WhatsApp, que le client ne saisit pas. Faites-en la clé de recherche de votre base clients.

## Conversation

```text
Client  : Où en est ma commande ?
Webhook : message.inbound  from=+237690000001  contact_name="Awa"  text="Où en est ma commande ?"
Serveur : fiche trouvée par numéro → commande CMD-1042, « en préparation »
Vous    : Bonjour Awa, votre commande CMD-1042 est en préparation.
```

## Code

Cherchez la fiche par `from`, puis répondez au même numéro (`to` = `from`) :

```bash
# curl
curl -X POST "https://wa-api.geskap.com/v1/messages/reply" \
  -H "Authorization: Bearer $GESKAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+237690000001",
  "text": "Bonjour Awa, votre commande CMD-1042 est en préparation.",
  "from": "100000000000001"
}'
```

```js
// Node.js
const res = await fetch("https://wa-api.geskap.com/v1/messages/reply", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GESKAP_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+237690000001",
    "text": "Bonjour Awa, votre commande CMD-1042 est en préparation.",
    "from": "100000000000001"
  }),
});
console.log(res.status, await res.json());
```

```php
// PHP
$ch = curl_init("https://wa-api.geskap.com/v1/messages/reply");
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",
    "text" => "Bonjour Awa, votre commande CMD-1042 est en préparation.",
    "from" => "100000000000001",
  ]),
]);
$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/reply",
    headers={"Authorization": f"Bearer {os.environ['GESKAP_API_KEY']}"},
    json={
        "to": "+237690000001",
        "text": "Bonjour Awa, votre commande CMD-1042 est en préparation.",
        "from": "100000000000001",
    },
    timeout=15,
)
print(res.status_code, res.json())
```

Côté serveur, la recherche est une simple comparaison de numéros :

```js
// Node.js
// Webhook handler body: data is the "data" object of a message.inbound event.
function onInbound(data) {
  const phone = data.from;                       // "+237690000001" (E.164)
  const customer = customersByPhone.get(phone);  // your own table, keys normalised to E.164
  if (!customer) return replyUnknown(phone);     // propose to sign up
  return answerFor(customer, data.text);
}
```

Si aucune fiche n'existe, ne répondez pas par une erreur : proposez de s'inscrire ou de créer un dossier avec un [formulaire pas à pas](https://console.geskap.com/docs/formulaire-pas-a-pas), ou orientez vers [un conseiller](https://console.geskap.com/docs/faq-ia-humain).

> **Piège :** normalisez les numéros de **votre** base au format E.164 avant de comparer (`+237690000001`, sans espaces ni tirets, avec l'indicatif). Un client enregistré comme `6 90 00 00 01` ne sera jamais retrouvé par une comparaison de chaînes.

> **Piège :** `from` identifie un **téléphone**, pas une personne. Un téléphone se prête, se perd, se partage en famille. Pour consulter un solde, un historique ou valider un paiement, ne vous fiez pas au seul numéro : voir [Données sensibles : lien unique et PIN](https://console.geskap.com/docs/donnees-sensibles-lien-pin).

> **Piège :** `contact_name` est le nom de profil WhatsApp, choisi et modifiable par le client. Bon pour dire « Bonjour Awa », jamais pour identifier quelqu'un ni pour décider d'un droit d'accès.

> **Piège :** répondez avec le champ `number` de l'événement en `from` si vous avez plusieurs numéros WhatsApp, pour que le client retrouve la même conversation : voir [Plusieurs numéros](https://console.geskap.com/docs/plusieurs-numeros).

Pour recevoir ces événements : [Webhook : vérifier la signature](https://console.geskap.com/docs/webhook-verifier-signature). Pour les brancher à un outil existant : [Webhook vers n8n, Zapier ou un CRM](https://console.geskap.com/docs/webhook-n8n-zapier-crm-llm).

_Preuve — vérifié dans le code de l'API : dev_api_docs.py, api_schemas.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
