Neurotech-HQ / heyoo

Opensource python wrapper to WhatsApp Cloud API
https://pypi.org/project/heyoo/
MIT License
438 stars 100 forks source link

Whatsapp messages cannot be received although no error message pops up as output #40

Open emre84 opened 1 year ago

emre84 commented 1 year ago

Environment: MACOS Monterey Python:3.7.3 heyoo:0.0.6 (pip)

Code: from heyoo import WhatsApp messenger = WhatsApp('xxx',phone_number_id='xxx') messenger.send_message('Hello I am WhatsApp Cloud API', '49xxx')

Output: 2022-11-03 22:51:34,464 - root - INFO - Sending message to 49xxx 2022-11-03 22:51:35,200 - root - INFO - Message sent to 49xxx

Description: Although my Facebook WhatsApp setting are done properly(Test message from Facebook Website can be sent properly). The WhatsApp message cannot be sent via heyoo. (No error message is received from python)

Note:I am sure that my token number, phone_number_id and recipient_id number are correct, with the reason that if I write anything wrong in these fields, I get following error message.:

2022-11-03 23:03:01,945 - root - INFO - Status code: 400 2022-11-03 23:03:01,945 - root - INFO - Response: {'error': {'message': '(#131030) Recipient phone number not in allowed list', 'type': 'OAuthException', 'code': 131030, 'error_data': {'messaging_product': 'whatsapp', 'details': 'Empfänger-Telefonnummer steht nicht auf Positivliste: Füge die Telefonnummer des Empfängers zu einer Empfängerliste hinzu und versuche es dann noch einmal.'}, 'error_subcode': 2655007, 'fbtrace_id': 'Akf6LRk1j9htPAuzA5P971E'}}

Kalebu commented 1 year ago

Hi @emre84 Can you please share the response message in English ?

emre84 commented 1 year ago

Hi Kalebu,

thanks for the response. This is unfortunately what i get as response(nothingelse as imentiined above)

Output: 2022-11-03 22:51:34,464 - root - INFO - Sending message to 49xxx 2022-11-03 22:51:35,200 - root - INFO - Message sent to 49xxx

Mattia921 commented 1 year ago

Hi Kalebu,

thanks for the response. This is unfortunately what i get as response(nothingelse as imentiined above)

Output: 2022-11-03 22:51:34,464 - root - INFO - Sending message to 49xxx 2022-11-03 22:51:35,200 - root - INFO - Message sent to 49xxx

I have exactly the same problem. Thanks in advance for your time

Kalebu commented 1 year ago

Hi @emre84 and @Mattia921 just know you cannot send other messages other than to un whitelisted numbers, To able to do this you need to add the number to the recipient list in your Facebook developer portal.

The error translates to

{'error': {'message': '(#131030) Recipient phone number not in allowed list', 'type': 'OAuthException', 'code': 131030, 'error_data': {'messaging_product': 'whatsapp' , 'details': 'Recipient's phone number is not whitelisted: add the recipient's phone number to a recipient list, then try again.'}, 'error_subcode': 2655007, 'fbtrace_id': 'Akf6LRk1j9htPAuzA5P971E'}}

They Allow up to 5 test numbers which you cannot change

Please let me know if you're still having issues

Mattia921 commented 1 year ago

Hi @Kalebu, thanks for your response. The fact is that I do not receive any errors while executing the python code. This is the output:

2022-11-09 10:49:39,296 - root - INFO - Sending message to 39333 2022-11-09 10:49:40,604 - root - INFO - Message sent to 39333

So the code is executed without errors, but I don't actually receive anything on the whatsapp number. I've already added the receiver into the recipient list inside the Facebook developer portal. Can be this problem related to the country prefix number? In my case, I've entered the Italian code without the + (so only 39). I hope I was clear. Thanks again for your time. Have a nice day

Kalebu commented 1 year ago

Hi @Mattia921

Can you run this and let me know if you're able to receive a message?

>>> messenger.send_template("hello_world", "255757xxxxxx", components={})
emre84 commented 1 year ago

Hi @emre84 and @Mattia921 just know you cannot send other messages other than to un whitelisted numbers, To able to do this you need to add the number to the recipient list in your Facebook developer portal.

The error translates to

{'error': {'message': '(#131030) Recipient phone number not in allowed list', 'type': 'OAuthException', 'code': 131030, 'error_data': {'messaging_product': 'whatsapp' , 'details': 'Recipient's phone number is not whitelisted: add the recipient's phone number to a recipient list, then try again.'}, 'error_subcode': 2655007, 'fbtrace_id': 'Akf6LRk1j9htPAuzA5P971E'}}

They Allow up to 5 test numbers which you cannot change

Please let me know if you're still having issues

I added also in the recipient list in your Facebook developer portal.

Note:I am sure that my token number, phone_number_id and recipient_id number are correct, with the reason that if I write anything wrong in these fields, I get following error message.:

2022-11-03 23:03:01,945 - root - INFO - Status code: 400 2022-11-03 23:03:01,945 - root - INFO - Response: {'error': {'message': '(#131030) Recipient phone number not in allowed list', 'type': 'OAuthException', 'code': 131030, 'error_data': {'messaging_product': 'whatsapp', 'details': 'Empfänger-Telefonnummer steht nicht auf Positivliste: Füge die Telefonnummer des Empfängers zu einer Empfängerliste hinzu und versuche es dann noch einmal.'}, 'error_subcode': 2655007, 'fbtrace_id': 'Akf6LRk1j9htPAuzA5P971E'}}

Mattia921 commented 1 year ago

Hi @Mattia921

Can you run this and let me know if you're able to receive a message?

>>> messenger.send_template("hello_world", "255757xxxxxx", components={})

Hi @Kalebu, in this case I'am able to receive the message. So since I would like to use the library to upload and then download images, should I always use the send_template method?

Thanks again for your help

Mattia921 commented 1 year ago

Hi Kalebu,

This is my output. messenger.send_template("hello_world", "49xxx", components={}) 2022-11-09 15:37:06,533 - root - INFO - Sending template to 49xxx 2022-11-09 15:37:07,003 - root - INFO - Template not sent to 49xxx 2022-11-09 15:37:07,003 - root - INFO - Status code: 401 2022-11-09 15:37:07,003 - root - INFO - Response: {'error': {'message': 'Error validating access token: Session has expired on Friday, 04-Nov-22 14:00:00 PDT. The current time is Wednesday, 09-Nov-22 06:37:06 PST.', 'type': 'OAuthException', 'code': 190, 'error_subcode': 463, 'fbtrace_id': 'A4QGvLtyY9xP-QVKPYRWMjX'}}

Note:I tried also +49xxx, 0049xxx, but none of them worked.

Since the access token updates every 24 hours, did you use the new one?

soerenetler commented 1 year ago

I had many similar problems in the beginning and It just got solved with a new Facebook Business Profile. As far as I see this is not a issue with the heyoo library. Does it work to send the same messege in e.g. Postman?

Mattia921 commented 1 year ago

I had many similar problems in the beginning and It just got solved with a new Facebook Business Profile. As far as I see this is not a issue with the heyoo library. Does it work to send the same messege in e.g. Postman?

Hi @soerenetler, I've just tried with postman and I obtain the same result. If I use the "type"="template" everything works fine, as with the wrapper of the heyoo library. On the other hand, with the "type"="text" (equivalent to the heyoo method send_message), the API call works but I don't receive anything on the WhatsApp number.

I will try with a new Facebook Business profile as you suggest. Thanks

Mattia921 commented 1 year ago

I had many similar problems in the beginning and It just got solved with a new Facebook Business Profile. As far as I see this is not a issue with the heyoo library. Does it work to send the same messege in e.g. Postman?

Hi @soerenetler, I've just tried with postman and I obtain the same result. If I use the "type"="template" everything works fine, as with the wrapper of the heyoo library. On the other hand, with the "type"="text" (equivalent to the heyoo method send_message), the API call works but I don't receive anything on the WhatsApp number.

I will try with a new Facebook Business profile as you suggest. Thanks

I've tried with a new Business profile but I could not solve the problem

SrVitinho commented 1 year ago

I'm currently having the exact same problem, I've done all steps and still no message

orkunozturk commented 1 year ago

@emre84

Currently, customers in Turkey cannot receive messages sent by businesses using Cloud API. However, businesses in Turkey are still able to send messages using the Cloud API.

https://developers.facebook.com/docs/whatsapp/cloud-api/support/troubleshooting#message-not-delivered

elimardom commented 1 year ago

Hi @Mattia921

Can you run this and let me know if you're able to receive a message?

>>> messenger.send_template("hello_world", "255757xxxxxx", components={})

this way works for me, any other method doesn't give any error but doesn't send anything either.

Kalebu commented 1 year ago

Hi @Mattia921 Can you run this and let me know if you're able to receive a message?

>>> messenger.send_template("hello_world", "255757xxxxxx", components={})

this way works for me, any other method doesn't give any error but doesn't send anything either.

Did you add your number as one of the test numbers to the Facebook developer portal?

You could also try replying first to the number before sending any other message other than the template message

emre84 commented 1 year ago

Hi,

Thanks for the response. Following code works fine for me either:

messenger.send_template("hello_world", "255757xxxxxx", components={})

But I can just send template messages with this command. isn't it possible to use messenger.send_message? I do not want to use any templates.

germor24 commented 1 year ago

Hi @Mattia921 Can you run this and let me know if you're able to receive a message?

>>> messenger.send_template("hello_world", "255757xxxxxx", components={})

this way works for me, any other method doesn't give any error but doesn't send anything either.

Did you add your number as one of the test numbers to the Facebook developer portal?

You could also try replying first to the number before sending any other message other than the template message

Replying first to the number solve the problem. Thanks.

RadiBytes commented 1 year ago

Is anyone still having this issue? Here are the common causes:

filipporomani commented 1 year ago

I had this problem the very first time I set up the Facebook Dev Portal, fixed it by sending an SMS to the test number.

filipporomani commented 1 year ago

image

Okkk so I got this issue again, this was the fix

filipporomani commented 1 year ago

Just send a template message and you are done!