Files
moreminimore-chat/spec
Kesh d1a6ea5798 fix: normalize mexico whatsapp phone numbers (#14174)
## Summary

This fixes WhatsApp phone number normalization for Mexico numbers when
using Twilio as a provider.

Twilio may send incoming Mexico WhatsApp phone numbers with an extra `1`
after the country code, for example:

- stored contact inbox source: `whatsapp:+525512345678`
- incoming message source: `whatsapp:+5215512345678`

Before this change, Chatwoot could treat these as different source IDs
and create a duplicate contact/conversation path instead of matching the
existing one.

## What changed

- added a Mexico-specific phone normalizer
- normalize `+521...` to `+52...` for contact matching
- kept the original incoming source ID when creating a brand new contact
inbox

## Why this approach

Chatwoot already has country-specific normalization for WhatsApp numbers
in the normalization service. This follows the same pattern and keeps
the change small and isolated.

## Tests

Added specs covering:

- matching an existing Mexico WhatsApp contact inbox when Twilio sends
`+521...`
- preserving the original source ID when no matching contact inbox
exists and a new one is created

Fixes
https://linear.app/chatwoot/issue/CW-6844/fix-normalize-mexico-whatsapp-phone-numbers-on-twilio-to-prevent

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-05 12:12:01 +04:00
..
2026-07-30 16:04:17 +05:30