shridarpatil/frappe_whatsapp

Not able to send message from frappe_whatsapp

Closed this issue · 5 comments

Screenshot from 2024-06-14 13-02-59

As per picture I am facing same issue, and here is console log.

Traceback (most recent call last):
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py", line 121, in notify
response = make_post_request(
File "apps/frappe/frappe/integrations/utils.py", line 43, in make_post_request
return make_request("POST", url, **kwargs)
File "apps/frappe/frappe/integrations/utils.py", line 35, in make_request
raise exc
File "apps/frappe/frappe/integrations/utils.py", line 22, in make_request
response.raise_for_status()
File "env/lib/python3.10/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.facebook.com/v20.0/284634341409544/messages
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py", line 44, in before_insert
self.notify(data)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py", line 139, in notify
frappe.throw(msg=error_message, title=res.get("error_user_title", "Error"))
File "apps/frappe/frappe/init.py", line 645, in throw
msgprint(
File "apps/frappe/frappe/init.py", line 610, in msgprint
_raise_exception()
File "apps/frappe/frappe/init.py", line 561, in _raise_exception
raise exc
frappe.exceptions.ValidationError: (#131030) Recipient phone number not in allowed list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 114, in application
response = frappe.api.handle(request)
File "apps/frappe/frappe/api/init.py", line 49, in handle
data = endpoint(**arguments)
File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 49, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/init.py", line 1768, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(*args, **kwargs)
File "apps/frappe/frappe/desk/form/save.py", line 39, in savedocs
doc.save()
File "apps/frappe/frappe/model/document.py", line 337, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 359, in _save
return self.insert()
File "apps/frappe/frappe/model/document.py", line 285, in insert
self.run_method("before_insert")
File "apps/frappe/frappe/model/document.py", line 962, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1322, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1304, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "apps/frappe/frappe/model/document.py", line 959, in fn
return method_object(*args, **kwargs)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py", line 48, in before_insert
frappe.throw(f"Failed to send message {str(e)}")
File "apps/frappe/frappe/init.py", line 645, in throw
msgprint(
File "apps/frappe/frappe/init.py", line 610, in msgprint
_raise_exception()
File "apps/frappe/frappe/init.py", line 561, in _raise_exception
raise exc
frappe.exceptions.ValidationError: Failed to send message (#131030) Recipient phone number not in allowed list

You are using dev credentials? If yes you need to either switch to prod credentials or add the mobile number in meta.

Hello, Thanks for quick reply, but I am on production, (not using dev credentials). Still facing issue.

This error comes when your using dev credentials.

How to switch to prod credential??

You have to get live credentials from meta.