waha icon indicating copy to clipboard operation
waha copied to clipboard

[CHATWOOT][Feature] Merge brazilian contacts on chatwoot

Open rafwell opened this issue 1 year ago • 29 comments

Here in Brazil we have a problem. Some years ago we've added on all mobile numbers an extra 9 at beginning. But a lot of whatsapp accounts had already registered without that.

So, whatsapp deal with it handling contacts with and without 9 on same chat.

In chatwoot integration by Waha it doesnt. If a user create a manual contact, with the 9 extra, they send a message normally. But when receive a message, the number come without the 9, so waha create a new contact and a new conversation.

Describe the solution you'd like

Detect and merge contacts when receive a message.

Describe alternatives you've considered

I've did a script directly on my database to deal with it, using the endpoint /api/v1/accounts/%s/actions/contact_merge on chatwoot api (poor documented)

Also had search Waha documentation about contacts creation event, but have no luck.

Examples:

Create a contact with number then send a message.

55 31 9 8888-8888 (55=country code, 31=local code, 9 extra, original number)

When receive a answer for this number, if its registered without 9 (about 90% of the brazilian numbers) they come in like this:

55 31 8888-8888

Both numbers are valid on Whatsapp. Idk why they did it, but... you know politicians.

patron:PLUS

rafwell avatar Aug 20 '25 21:08 rafwell

Nice, @rafwell!

This is useful for me too!

patron:PLUS

igordisco avatar Aug 21 '25 00:08 igordisco

☝️

joaomachado-pg avatar Aug 24 '25 00:08 joaomachado-pg

related

  • https://github.com/devlikeapro/waha/issues/238
  • https://waha.devlike.pro/docs/how-to/contacts/#check-phone-number-exists

patron:PRO

devlikepro avatar Aug 24 '25 09:08 devlikepro

My solution for this in evolutionapi

https://github.com/EvolutionAPI/evolution-api/pull/587/files

deivisonrpg avatar Aug 29 '25 13:08 deivisonrpg

+1

hereck avatar Sep 01 '25 01:09 hereck

+1

patron:PLUS

bergpinheiro avatar Sep 02 '25 13:09 bergpinheiro

+1

soudiegogoncalves avatar Sep 02 '25 13:09 soudiegogoncalves

+1

patron:PLUS

mxyzt avatar Sep 02 '25 13:09 mxyzt

+1

marceloengecom avatar Sep 02 '25 14:09 marceloengecom

+1

oasilap avatar Sep 02 '25 18:09 oasilap

+1

mcabral2510 avatar Sep 02 '25 20:09 mcabral2510

+1

HermesMacedo avatar Sep 03 '25 13:09 HermesMacedo

+1

Midasstart avatar Sep 03 '25 13:09 Midasstart

I want to support this request. We also have the same problem with numbers in Brazil — many users reply without the extra 9, and this creates duplicate contacts and conversations in WAHA + Chatwoot. A normalization or merge solution would solve a real pain point for us.

patron:PRO

bergpinheiro avatar Sep 06 '25 22:09 bergpinheiro

+1

patron:PLUS

fbsfernando avatar Sep 16 '25 21:09 fbsfernando

+1

abextadu avatar Sep 17 '25 16:09 abextadu

+1

patron:PRO

paulobautz avatar Sep 18 '25 01:09 paulobautz

+1

patron:PLUS

jayveloper avatar Sep 19 '25 01:09 jayveloper

+1

patron:PLUS

Lucasmartinspg avatar Sep 20 '25 15:09 Lucasmartinspg

A normalization is the way to go 👍 don’t want to use an undocumented API 🤔

So WAHA will insert 9 (if not already) in all Brazil +55 JIDs — let’s assume [email protected]:

  1. Try to find a contact with phone_number = 5531988888888. If found, update its custom attributes with the chat ID [email protected].
  2. If not found, create a contact with phone_number = 5531988888888 and chat ID [email protected].

🧩 Apps

2025.9.6 - ChatWoot - add additional 9 in Brazil phone numbers - #1261

patron:PRO

devlikepro avatar Sep 29 '25 02:09 devlikepro