-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
Since updating to WAHA 2025.9.6, the automatic normalization of Brazilian phone numbers (adding the 9th digit) is causing contact duplication in Chatwoot integration.
Steps to Reproduce
- Have an existing contact in Chatwoot without the 9th digit (e.g.,
551187654321) - number as originally registered in WhatsApp - Update WAHA to version 2025.9.6 or higher
- Receive a new message from this contact
- WAHA automatically normalizes the number by adding the 9th digit (
5511987654321) - Chatwoot doesn't recognize it as the same contact and creates a new duplicate record with the normalized number
Expected Behavior
WAHA should check if a contact already exists in Chatwoot (with or without the 9th digit) before creating a new one, or at minimum, provide a configuration option to control this normalization behavior for Chatwoot integration.
Current Behavior
Every message received after the 2025.9.6 update creates duplicate contacts for numbers that already existed in Chatwoot without the 9th digit. This results in:
- Duplicate contacts in the database
- Fragmented conversation history
- Confusion for support agents
- Issues with automations that depend on unique contact identifiers
Environment
- WAHA Version: 2025.9.6, 2025.9.7, 2025.9.8, 2025.10.0 (issue persists across all versions)
- Engine: GOWS
- Integration: Native WAHA App to Chatwoot
- Chatwoot Version: Mega 4.7.0
Proposed Solutions
Option 1: Pre-check Before Contact Creation (Recommended)
Before creating a new contact in Chatwoot, WAHA could check if a contact already exists with either format:
- Original format:
551187654321 - Normalized format:
5511987654321
If found, use the existing contact ID instead of creating a new one.
Option 2: Configuration Flag
Add a configuration option to control Brazilian number normalization behavior:
WAHA_CHATWOOT_NORMALIZE_BR_NUMBERS: true/falseThis would allow users to disable normalization if they already have an established contact base.
Option 3: Bidirectional Matching
Implement a matching algorithm in the Chatwoot webhook handler that:
- Receives the normalized number from WhatsApp
- Queries Chatwoot for contacts with both number formats
- Returns the existing contact if found in either format
- Only creates a new contact if neither format exists
Option 4: Migration Script
Provide a migration script/endpoint that:
- Identifies duplicate contacts (same number with/without 9th digit)
- Merges conversation history
- Updates references to use a single contact ID
- Removes duplicates
Technical Context
The Brazilian 9th digit was introduced in mobile numbers years ago, but many existing WhatsApp contacts still use the old 8-digit format in their registration. WAHA's normalization is technically correct for current standards, but it breaks backward compatibility with existing Chatwoot contact databases.
Additional Notes
I've also reported this to Chatwoot, but since the normalization happens on WAHA's side before sending to Chatwoot, it might be more efficient to handle this in WAHA's integration layer.
Would appreciate any guidance on:
- Whether this is considered a bug or expected behavior
- If there's a workaround available
- Timeline for a potential fix
- If you'd accept a PR addressing this issue
Impact: High - Affects all Brazilian users with existing Chatwoot databases after WAHA updates