> For the complete documentation index, see [llms.txt](https://docs.channel360.co.za/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.channel360.co.za/api-usage/match-replies-to-your-records.md).

# Match replies to your records

Work out which order, ticket or person a customer's reply belongs to, without relying on their phone number.

When a customer replies, work out which order, ticket or person in your system the reply belongs to — even when WhatsApp does not tell you their phone number.

The `message:appUser` event (a customer's message) may not include the customer's phone number. This is not an integration failure. Meta is introducing WhatsApp usernames and stronger privacy, and depending on the customer's settings and Meta's rollout, the number may or may not be present. This affects WhatsApp integrations with every provider, not only Channel360. [WhatsApp usernames and BSUID](/api-usage/match-replies-to-your-records/whatsapp-usernames-and-bsuid.md) has the details.

{% hint style="info" %}
**Keep the phone number in your own system, and link it to Channel360's IDs when you send.** Do not rely on the reply to carry the number.
{% endhint %}

## Steps

### 1. Store your own record before sending

Your system already knows who it is messaging and why. Store that, with the phone number, before you send:

```json
{
  "internalCustomerId": "customer_12345",
  "destinationPhoneNumber": "+27821234567",
  "notificationPurpose": "sales_rep_assignment",
  "status": "notification_sent"
}
```

### 2. Send the notification and keep its ID

[Send the notification](/api-usage/send-a-template-notification.md) to that phone number. Store the `notification._id` from the `201` response on the same record.

### 3. When the delivery event arrives, store the IDs it carries

The `notification:delivery:channel` and `notification:delivery:user` events carry Channel360's IDs for this customer. Store them on the same record:

| Field in the event             | Store as         | What it is                                                     |
| ------------------------------ | ---------------- | -------------------------------------------------------------- |
| `notification._id`             | `notificationId` | The ID returned when you sent. Use it to find your record.     |
| `destination.destinationId`    | —                | The phone number you sent to. Also usable to find your record. |
| `matchResult.appUser._id`      | `appUserId`      | Channel360's ID for this customer. You need it to reply.       |
| `matchResult.conversation._id` | `conversationId` | Channel360's ID for the message thread with this customer.     |

Your record now looks like this:

```json
{
  "internalCustomerId": "customer_12345",
  "destinationPhoneNumber": "+27821234567",
  "notificationPurpose": "sales_rep_assignment",
  "notificationId": "notification_abc123",
  "appUserId": "appUser_abc123",
  "conversationId": "conversation_abc123"
}
```

### 4. When the customer replies, look up the record by Channel360's IDs

When a `message:appUser` event arrives, find your record using, in order of preference:

1. `conversation._id`
2. `appUser._id`
3. `notification._id`, where the event includes it

This finds the right customer, process or notification even when the event has no phone number.

## Why this approach

It keeps customer identification, reply matching, reporting and notification tracking working without depending on the phone number being present in `message:appUser`.

A webhook setting exists that can include a `client` object with the number on some events. It should not be treated as the long-term pattern. The safer approach is to keep the phone number in your own system and bind it to the `appUser`, `conversation` and `notification` IDs from the delivery event.

## Check it worked

Send yourself a notification, reply from your phone, and confirm your handler finds the original record from `conversation._id` without reading any phone number.

## Next

{% content-ref url="/pages/YaMEoRJYkQvY5TiwLtAh" %}
[WhatsApp usernames and BSUID](/api-usage/match-replies-to-your-records/whatsapp-usernames-and-bsuid.md)
{% endcontent-ref %}

{% content-ref url="/pages/g7KUSUMWQLS6klQCKU15" %}
[Identifiers: which ID is which](/api-usage/concepts/identifiers.md)
{% endcontent-ref %}
