X Tutup
Skip to content

fix: Normalize phone numbers during WhatsApp channel lookup#13709

Open
muhsin-k wants to merge 3 commits intodevelopfrom
fix/whatsapp-channel-lookup-phone-normalization
Open

fix: Normalize phone numbers during WhatsApp channel lookup#13709
muhsin-k wants to merge 3 commits intodevelopfrom
fix/whatsapp-channel-lookup-phone-normalization

Conversation

@muhsin-k
Copy link
Member

@muhsin-k muhsin-k commented Mar 4, 2026

Fixes https://linear.app/chatwoot/issue/PLA-99/whatsapp-messages-dropped-for-brazilargentina-numbers-due-to-phone

Meta's WhatsApp Cloud API includes display_phone_number in webhook payloads, but its format can differ from the number stored in Chatwoot's channel record.
In Brazil, Meta omits the mobile 9 prefix. For example, it sends 55419XXXXXXX (12 digits) instead of 554199XXXXXXX (13 digits). In Argentina, Meta adds an extra 9 after the country code. For example, it sends 549XXXXXXXXXX instead of 54XXXXXXXXXX.
The whatsapp event job uses display_phone_number for an exact-match channel lookup. When the formats do not match, the lookup returns nil and the incoming message is silently dropped, logging:

Inactive WhatsApp channel: unknown - <phone_number>.

The fix extends get_channel_from_wb_payload to fall back to normalized phone number matching using the existing PhoneNumberNormalizationService normalizers (Brazil, Argentina), which were previously only used for
contact-level lookups.

@muhsin-k muhsin-k marked this pull request as ready for review March 4, 2026 10:43
@muhsin-k
Copy link
Member Author

muhsin-k commented Mar 4, 2026

@codex please review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Member

@sojan-official sojan-official left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup