whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

ninth digit does not deliver the message

Open AmparoGuiase opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

Hello, all in peace with you?

About 5 years ago, numbers in Brazil had the format 99 9999-9999.

Due to the increasing number of numbers, a ninth digit was added and became 99 9 9999-9999. If I use the api to send a message to a number with the new digit and the account was initially registered without the ninth digit, the message is not delivered. I send an image to exemplify.

Note in the image that if I send it to the new number with the ninth digit, the message is not delivered. This creates a difficulty, as everyone passes the number with the ninth digit, but when sending the message using the api, it is not delivered. 1111111111

Expected behavior

As with the cell phone, it would be interesting if, when sending a message to a number with the ninth digit, the message would be delivered to the accounts created without the ninth digit.

Message to 9 9999 9999, if the account was created a long time ago, and at the time it only had 9999 9999, the message does not arrive.

Steps to Reproduce the Bug or Issue

  1. Just find someone with an old Brazilian account
  2. Try to send a message to the number with the new digit.
  3. The message will not arrive

Relevant Code

.

Browser Type

Google Chrome

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

All

Additional context

If you have a way to check if the number has active whatsapp, that already solves it for me.

AmparoGuiase avatar Jan 30 '23 12:01 AmparoGuiase

Hi, I face the same issua with projects over here in Brazil, I dont think that it is actually a bug, because with this change some numbers are registered within the ninth digit and other didnt. So my workaround for this e verify both, with and without the ninth digit to ensure the number destination is the right one registered. It is possible via the method "getNumberId" of the client instace, like this:

let to = numberViaRequestOrInput
let contactId

if (to.startsWith('55') && to.length == 13 && to[4] == 9) {
  contactId = await client.getNumberId(to.slice(0, 4) + to.slice(5))
}

if (!contactId) {
  contactId = await client.getNumberId(to)
}

if (contactId) {
  to = contactId.user
}

In this case, the format expected in the "to" variable is CountryCode(55 for Brazil) + State Code + Number

alaordev avatar Jan 30 '23 14:01 alaordev

Works alaordev. Tks a lot :-D

AmparoGuiase avatar Jan 30 '23 15:01 AmparoGuiase

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 22 '23 03:05 stale[bot]