shridarpatil / frappe_whatsapp Goto Github PK
View Code? Open in Web Editor NEWWhatsApp cloud integration for frappe
Home Page: https://www.youtube.com/watch?v=nq5Kcc5e1oc
License: Other
WhatsApp cloud integration for frappe
Home Page: https://www.youtube.com/watch?v=nq5Kcc5e1oc
License: Other
From Today, It is failed to trigger whatsapp message for me
Here is Whatsapp notification log.
{
"error": {
"code": 100,
"error_data": {
"details": "Parameter 'text' is mandatory for component parameter type 'text'",
"messaging_product": "whatsapp"
},
"fbtrace_id": "AauRgAP8m_ImekhgAZPeC7d",
"message": "(#100) Invalid parameter",
"type": "OAuthException"
}
}
pdf sending issue while sending it through frappe whatsapp
SalesInvoice' object has no attribute 'get_document_share_key
I get the following message once I installed this app on frappecloud and navigate to WhatsApp settings using awesome bar.
“Sorry! I could not find what you were looking for.”
It seems like the replied message is not tagged to the conversation that was initiated. Not sure what is the issue, but the webhook setup has already been done, as shown in the WhatsApp messages docType, where the message that was replied was successfully received as an incoming
message. However, in the CRM section, I'm unable to see the incoming message under that respective lead.
@shridarpatil Do you know if this is something you are still working on, or is this a bug?
I have created a template in Meta with Image as Header and added a sampl Image.
When I Fetch templates from Meta. the Header is not set as Image.
But if I set header as Document its working and header is set as Documents
How to create action button in WhatsApp template?
like book now, call now etc
How can I use already created templates from Meta account, while creating WhatsApp templates.
Currently we need to create a new template.
Let me know if there is any method to use the existing templates
Hi there,
I was trying to install it with docker and managed to install it by using the given commands and could see it installed after using the following command
bench --site site_name list-apps
Somehow my site is not loading up anymore. Restating the container gives the following error
ModuleNotFoundError: No module named 'frappe_whatsapp'
Am I missing any steps?
Thanks for the help
Good day,
This is a great app but I was thinking we push it to Frappe Core as a module. As WhatsApp is used worldwide, it can be just like the Message Module. Am just suggesting.
Thank you
Hi, I have fixed the grammar of your message without changing the images:
Hi, I have finished all the setup process.
I have created a permanent token as per the meta docs.
I have used the URL that I saw in the picture in the readme.md, which is https://graph.facebook.com/.
I have used both versions V15.0 and V16.0, but now I am using V16.0 because the webhook is configured with that one.
I have set the phone number and business ID.
I have also set the webhook verify token.
In the message list, I made many tests and found that when I send a message without receiving the first one from the number I'm messaging, the other number won't receive it. Basically, it should be a user-initiated conversation to be able to receive messages sent from the WhatsApp message functionality.
So I thought that in order to create a business-initiated conversation, I should use WhatsApp templates. I created my templates, and all were approved. Then, I added them to a WhatsApp notification using the new option to set a custom field on the mobile_no field.
I had no errors in the process, but it won't send WhatsApp messages. I tried sending the message first from the user and then performing the action to receive the notification, but nothing happened. I tried with different fields and still had the issue.
Is there an additional configuration that I need to do to be able to initiate business conversations? Or any meta documentation that I need to check? Additionally, is there any way that I can check the logs generated by this app? I tried looking in the error log, but I found nothing.
"erpnext": "14.18.0",
"frappe": "14.26.4",
"frappe_whatsapp": "0.0.1",
"healthcare": "15.0.0-dev",
"hrms": "14.1.0",
"payments": "0.0.1"
Host frappecloud
Thank you for tanking the time to read this and work on this project.
whatsapp setting is correct but unable to send whatsapp text direct message.
message save succesfully but message not received.
i sent the message with country code with mobile.
Hello Shridarpatil,
I have just implemented, frappe WhatsApp.
MY ERPNext is self hosting, V14.
I was able to integrate with Whatsapp, Settings seem to be fine, I even created template and it got approved on Meta.
However I am unable to send messages, WhatsApp notification list is also created.
One issue I am facing is that I am unable to send manual message.
Couple of screenshots for your reference.
Your support will be highly appreciated
Tried with .pdf and .docx files.
Text and images worked fine.
{
"chat": "0.0.1",
"erpnext": "14.44.0",
"frappe": "14.52.0",
"frappe_whatsapp": "0.0.2",
"hrms": "14.13.1",
"insights": "1.1.3",
"payments": "0.0.1",
}
Form/WhatsApp Message/new-whatsapp-message-5
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 95, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 54, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 47, 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 1622, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/client.py", line 229, in save
doc.save()
File "apps/frappe/frappe/model/document.py", line 307, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 329, in _save
return self.insert()
File "apps/frappe/frappe/model/document.py", line 255, in insert
self.run_method("before_insert")
File "apps/frappe/frappe/model/document.py", line 917, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1279, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1261, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "apps/frappe/frappe/model/document.py", line 914, in fn
return method_object(*args, **kwargs)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py", line 22, in before_insert
"to": self.format_number(self.to),
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py", line 82, in format_number
if number.startswith("+"):
AttributeError: 'NoneType' object has no attribute 'startswith'
{
"type": "POST",
"args": {
"doc": "{\"docstatus\":0,\"doctype\":\"WhatsApp Message\",\"name\":\"new-whatsapp-message-5\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"type\":\"Outgoing\",\"message_type\":\"Manual\",\"content_type\":\"document\",\"__run_link_triggers\":1,\"attach\":\"/private/files/sample.docx\"}"
},
"freeze": true,
"headers": {},
"error_handlers": {},
"url": "/api/method/frappe.client.save"
}
{
"exception": "AttributeError: 'NoneType' object has no attribute 'startswith'"
}
I am trying to add 'Send Whatsapp message' option/button to sales invoice, payment receipt and others to send that doc pdf as a service message. My code is able to send pdf but it is not showing or getting into the Whatsapp Message log. Please help me to get the sent message in the log. Here's my code.
import json
import frappe
from frappe.integrations.utils import make_post_request
from frappe import _
from frappe.utils import get_url
def get_settings() -> dict:
"""Get WhatsApp settings"""
settings = frappe.get_doc("WhatsApp Settings", "WhatsApp Settings")
return settings
def generate_payload(recipient: str, doctype: str, docname: str, print_format: str) -> str:
"""Generate WhatsApp message payload"""
link = get_pdf_link(doctype, docname, print_format)
payload = json.dumps({
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": recipient,
"type": "document",
"document": {
"link": link,
"caption": docname
}
})
return payload
def make_request(settings: dict, payload: str) -> dict:
"""Make POST request to WhatsApp API"""
headers = {
"authorization": f"Bearer {settings.get_password('token')}",
"content-type": "application/json",
}
response = make_post_request(
f"{settings.url}/{settings.version}/{settings.phone_id}/messages",
headers=headers,
data=payload,
)
return response
def log_message(response: dict, recipient: str, doctype: str, docname: str) -> None:
"""Log WhatsApp message"""
message_id = response["messages"][0]["id"]
frappe.get_doc({
"doctype": "WhatsApp Message",
"type": "Outgoing",
"message": str(response),
"to": recipient,
"message_type": "Manual",
"message_id": message_id,
"content_type": "document"
}).save(ignore_permissions=True)
def handle_error(error: Exception) -> None:
"""Handle error and log notification"""
response = frappe.flags.integration_request.json()['error']
error_message = response.get('Error', response.get("message"))
frappe.msgprint(
f"Failed to trigger whatsapp message: {error_message}",
indicator="red",
alert=True
)
@frappe.whitelist()
def send_whatsapp_message(recipient: str, doctype: str, docname: str, print_format: str) -> dict:
"""Send WhatsApp message"""
settings = get_settings()
payload = generate_payload(recipient, doctype, docname, print_format)
try:
response = make_request(settings, payload)
log_message(response, recipient, doctype, docname)
return response
except Exception as e:
handle_error(e)
@frappe.whitelist()
def get_pdf_link(doctype: str, docname: str, print_format: str) -> str:
"""
Generate a PDF link for a document.
:param doctype: The document type (e.g., "Sales Invoice")
:param docname: The document name (e.g., "SINV-001")
:param print_format: The print format (e.g., "Standard")
:return: The PDF link as a string
"""
doc = frappe.get_doc(doctype, docname)
if not doc:
frappe.throw(_("Document not found: {doctype} - {docname}").format(doctype=doctype, docname=docname))
print_settings = frappe.get_doc("Print Format", print_format)
if not print_settings:
frappe.throw(_("Print format not found: {print_format}").format(print_format=print_format))
pdf_link = "/api/method/frappe.utils.print_format.download_pdf?"
pdf_link += "doctype={doctype}&name={docname}&format={print_format}&no_letterhead=0".format(
doctype=doctype, docname=docname, print_format=print_format
)
key = doc.get_document_share_key()
pdf_link += "&key={key}".format(key=key)
return get_url(pdf_link)
When trying to uninstall the app, following error occurs:
user@tech-hostname9315809:~/frappe-bench/apps/frappe_whatsapp$ bench --site erp.techgroup.com uninstall-app frappe_whatsapp
Uninstalling App frappe_whatsapp from Site erp.techgroup.com...
All doctypes (including custom), modules related to this app will be deleted. Are you sure you want to continue? [y/N]: y
Backing up...
Deleting Module 'Frappe Whatsapp'
* removing Module Def 'Frappe Whatsapp'...
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/user/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
main()
File "/home/user/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
click.Group(commands=commands)(prog_name="bench")
File "/home/user/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/home/user/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/user/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/user/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/user/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File "/home/user/frappe-bench/apps/frappe/frappe/commands/site.py", line 969, in uninstall
remove_app(app_name=app, dry_run=dry_run, yes=yes, no_backup=no_backup, force=force)
File "/home/user/frappe-bench/apps/frappe/frappe/installer.py", line 396, in remove_app
drop_doctypes = _delete_modules(modules, dry_run=dry_run)
File "/home/user/frappe-bench/apps/frappe/frappe/installer.py", line 441, in _delete_modules
frappe.delete_doc("Module Def", module_name, ignore_on_trash=True, force=True)
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 1345, in delete_doc
return frappe.model.delete_doc.delete_doc(
File "/home/user/frappe-bench/apps/frappe/frappe/model/delete_doc.py", line 135, in delete_doc
doc.run_method("after_delete")
File "/home/user/frappe-bench/apps/frappe/frappe/model/document.py", line 962, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "/home/user/frappe-bench/apps/frappe/frappe/model/document.py", line 1322, in composer
return composed(self, method, *args, **kwargs)
File "/home/user/frappe-bench/apps/frappe/frappe/model/document.py", line 1306, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File "/home/user/frappe-bench/apps/frappe_whatsapp/frappe_whatsapp/utils/__init__.py", line 17, in run_server_script_for_doc_event
notification = get_notifications_map().get(
File "/home/user/frappe-bench/apps/frappe_whatsapp/frappe_whatsapp/utils/__init__.py", line 36, in get_notifications_map
enabled_whatsapp_notifications = frappe.get_all(
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 2007, in get_all
return get_list(doctype, *args, **kwargs)
File "/home/user/frappe-bench/apps/frappe/frappe/__init__.py", line 1982, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
File "/home/user/frappe-bench/apps/frappe/frappe/model/db_query.py", line 185, in execute
self.columns = self.get_table_columns()
File "/home/user/frappe-bench/apps/frappe/frappe/model/db_query.py", line 546, in get_table_columns
return get_table_columns(self.doctype)
File "/home/user/frappe-bench/apps/frappe/frappe/model/meta.py", line 73, in get_table_columns
return frappe.db.get_table_columns(doctype)
File "/home/user/frappe-bench/apps/frappe/frappe/database/database.py", line 1197, in get_table_columns
raise self.TableMissingError("DocType", doctype)
pymysql.err.ProgrammingError: ('DocType', 'WhatsApp Notification')
Installed apps:
{
"crm": "2.0.0-dev",
"erpnext": "15.20.6",
"frappe": "15.23.0",
"frappe_whatsapp": "0.0.2",
"insights": "1.1.3",
"wiki": "2.0.0"
}
Does Incoming Message support file attachments also?
I want to send notifications to my students whenever the payment request is created in their name.
Usually I send Payment request link using the following method "{{ doc.get_payment_url() }}".
How can I send the same link here as well.
Also whenever the student pays the amount using the link I shared, I want to send the Confirmation payment receipt using the payment receipt attachment of 'Payment Entry' doctype.
Can you please tell how to do it @shridarpatil @mohsinalimat @chechani @vineyrawat
Hi,
Please help
{
"custom_doctypes": "0.0.1",
"erpnext": "15.23.3",
"exchangedata": "0.0.1",
"frappe": "15.27.0",
"frappe_whatsapp": "v1.0.7",
"healthcare": "14.0.3",
"hrms": "15.21.0",
"leave_app": "0.0.1",
"payments": "0.0.1"
}
Form/Leave Application/LIC-10937
Traceback (most recent call last):
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 186, in notify
headers=headers, data=json.dumps(data)
File "/usr/lib/python3.10/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.10/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.10/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.10/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type date is not JSON serializable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 205, in notify
response = frappe.flags.integration_request.json()['error']
AttributeError: 'NoneType' object has no attribute 'json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 110, 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 37, in savedocs
doc.submit()
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1048, in submit
return self._submit()
File "apps/frappe/frappe/model/document.py", line 1031, in _submit
return self.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 390, in _save
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1131, in run_post_save_methods
self.run_method("on_submit")
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 1306, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File "apps/frappe_whatsapp/frappe_whatsapp/utils/__init__.py", line 27, in run_server_script_for_doc_event
).send_template_message(doc)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 170, in send_template_message
self.notify(data)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 216, in notify
"meta_data": frappe.flags.integration_request.json()
AttributeError: 'NoneType' object has no attribute 'json'
{
"type": "POST",
"args": {
"doc": "{\"name\":\"LIC-10937\",\"owner\":\"[email protected]\",\"creation\":\"2024-06-12 11:02:36.511016\",\"modified\":\"2024-06-12 13:50:48.001979\",\"modified_by\":\"[email protected]\",\"docstatus\":0,\"idx\":0,\"naming_series\":\"LIC-.\",\"employee\":\"CUE-10379\",\"employee_name\":\"Name Name\",\"custom_col_dpi\":\"246630101\",\"fecha_crea\":\"2024-06-12\",\"tipo_lic\":\"\",\"leave_type\":\"Vacaciones\",\"custom_empjoining\":\"2023-05-19\",\"custom_emp_branch\":\"Planta\",\"company\":\"SAMP\",\"department\":\"Pintura Máquina - L\",\"custom_col_phone\":\"47573540\",\"from_date\":\"2024-06-13\",\"to_date\":\"2024-06-27\",\"half_day\":0,\"custom_hours\":0,\"total_leave_days\":13,\"fecha_alta_vac\":\"2023-05-19\",\"inic_per_vac\":\"2023-05-19\",\"fin_per_vac\":\"2024-05-18\",\"fecha_reg_lab\":\"2024-06-28\",\"hora_inic_sol\":\"0:00:00\",\"hora_fin_sol\":\"0:00:00\",\"hora_inic\":\"0:00:00\",\"hora_fin\":\"0:00:00\",\"hora_cita\":\"0:00:00\",\"description\":\"Vacaciones programadas por aniversario laboral\",\"doc_sol\":\"No Aplica\",\"const\":\"No Aplica\",\"leave_balance\":15,\"leave_approver\":\"[email protected]\",\"leave_approver_name\":\"[email protected]\",\"follow_via_email\":1,\"posting_date\":\"2024-06-12\",\"status\":\"Approved\",\"proc_conta\":0,\"letter_head\":\"Membrete LANS\",\"doctype\":\"Leave Application\",\"half_day_date\":\"\"}",
"action": "Submit"
},
"btn": {
"jQuery3700086204198274978161": {
"events": {
"click": [
{
"type": "click",
"origType": "click",
"guid": 4620,
"namespace": ""
}
]
}
}
},
"freeze": true,
"headers": {},
"error_handlers": {},
"url": "/api/method/frappe.desk.form.save.savedocs",
"request_id": null
}
{
"exception": "AttributeError: 'NoneType' object has no attribute 'json'",
"exc_type": "AttributeError",
"_exc_source": "frappe_whatsapp (app)"
}
I fetched WhatsApp templates from Meta, but only one template was fetched for those with multiple languages. This is because ERPNext does not accept duplicate template names. Therefore, it is necessary to consider the language when fetchin templates.
the temp in erpnext
Upon comparison, we will also find that there is a template that was created in ERPNext (zahed) and there are many notes on this template:
1- This template was created in erpnext and approved by Meta, but it is still pending in ERP Next.
2- This template was deleted from the ERP Next screen and was actually deleted from Meta, but it was not deleted in ERP Next.
3- I made several attempts to delete it from the list, but to no avail.
bench get-app https://github.com/shridarpatil/frappe_whatsapp
pulls version 0.0.2 but I believe v1.0.3 is also released!
I did the following things to setup this custom app, but some setting is not right & i am unable to send message like its shown in installation guide of this page.
Is it something related to webhook setting or something else ?
I am not an expert so please guide with simple steps
Hello!
I have a WhatsApp Template, Approved, and pulled successfully. AFAIK, the only way to initiate a message from this app is via WhatsApp Notification
DocType.
The DocType Event
menu does not have what I need. I need a custom event.
More specifically, I have a custom button on a DocType Form View, and I need the notification to be triggered once the button is clicked.
Could you please give me high level directions on how to achive this?
BR
Traceback with variables (most recent call last):
File "apps/frappe/frappe/integrations/utils.py", line 21, in make_request
frappe.flags.integration_request.raise_for_status()
method = 'POST'
url = 'https://graph.facebook.com/v16.0/108142048963233/messages'
auth = ''
headers = {'authorization': 'Bearer @@@@@@@@@@@@', 'content-type': 'application/json'}
data = '{"messaging_product": "whatsapp", "to": "91@@@@@@", "type": "template", "template": {"name": "Testt",
"language": {"code": null},
"components": [{"type": "body", "parameters": [{"type": "text", "text": "Helllooo"}]}]}}'
s = <requests.sessions.Session object at 0x7fec0833c4c0>
exc = HTTPError('400 Client Error: Bad Request for url: https://graph.facebook.com/v16.0/108142048963233/messages')
File "env/lib/python3.10/site-packages/requests/models.py", line 960, in raise_for_status
raise HTTPError(http_error_msg, response=self)
self = <Response [400]>
http_error_msg = '400 Client Error: Bad Request for url: https://graph.facebook.com/v16.0/108142048963233/messages'
reason = 'Bad Request'
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.facebook.com/v16.0/108142048963233/messages
Which can be fixed by customizing the doc. Currently, i got around by doing the follows:
I have set up WhatsApp notification as a Doctype event After Submit for stock entry. now when I create and submit a new document, I get a popup message with the text "Error: Value missing for WhatsApp Message: Content Type".
Note: The message is successfully delivering
Traceback (most recent call last):
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 165, in notify
frappe.get_doc({
File "apps/frappe/frappe/model/document.py", line 309, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 331, in _save
return self.insert()
File "apps/frappe/frappe/model/document.py", line 263, in insert
self._validate()
File "apps/frappe/frappe/model/document.py", line 533, in _validate
self._validate_mandatory()
File "apps/frappe/frappe/model/document.py", line 868, in _validate_mandatory
raise frappe.MandatoryError(
frappe.exceptions.MandatoryError: [WhatsApp Message, 1243ff0196]: content_type
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 95, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 54, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 47, 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 1622, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/desk/form/save.py", line 31, in savedocs
doc.save()
File "apps/frappe/frappe/model/document.py", line 309, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 360, in _save
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1095, in run_post_save_methods
self.run_method("on_submit")
File "apps/frappe/frappe/model/document.py", line 919, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1281, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1265, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File "apps/frappe_whatsapp/frappe_whatsapp/utils/init.py", line 27, in run_server_script_for_doc_event
).send_template_message(doc)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 146, in send_template_message
self.notify(data)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 177, in notify
response = frappe.flags.integration_request.json()['error']
KeyError: 'error'
Trying to send media via frappe_whatsapp, the message is not sent the same thing goes for receiving messages, why?
When attempting to save, message is correctly sent, but I get this error:
Error: Value missing for WhatsApp Message: Content Type
KeyError: 'error'
Possible source of error: frappe_whatsapp (app)
{
"custom_doctypes": "0.0.1",
"erpnext": "15.23.3",
"exchangedata": "0.0.1",
"frappe": "15.27.0",
"frappe_whatsapp": "0.0.2",
"healthcare": "14.0.3",
"hrms": "15.21.0",
"leave_app": "0.0.1",
"payments": "0.0.1"
}
Form/Leave Application/new-leave-application-urqmygeihu
Traceback (most recent call last):
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 189, in notify
frappe.get_doc({
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 292, in insert
self._validate()
File "apps/frappe/frappe/model/document.py", line 574, in _validate
self._validate_mandatory()
File "apps/frappe/frappe/model/document.py", line 911, in _validate_mandatory
raise frappe.MandatoryError(
frappe.exceptions.MandatoryError: [WhatsApp Message, 8dclqi0ppk]: content_type
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 110, 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 315, in insert
self.run_post_save_methods()
File "apps/frappe/frappe/model/document.py", line 1128, in run_post_save_methods
self.run_method("on_update")
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 1306, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File "apps/frappe_whatsapp/frappe_whatsapp/utils/__init__.py", line 27, in run_server_script_for_doc_event
).send_template_message(doc)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 170, in send_template_message
self.notify(data)
File "apps/frappe_whatsapp/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_notification/whatsapp_notification.py", line 202, in notify
response = frappe.flags.integration_request.json()['error']
KeyError: 'error'
{
"type": "POST",
"args": {
"doc": "{\"docstatus\":0,\"doctype\":\"Leave Application\",\"name\":\"new-leave-application-urqmygeihu\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"[email protected]\",\"naming_series\":\"LIC-.\",\"fecha_crea\":\"2024-06-08\",\"tipo_lic\":\"\",\"company\":\"samp\",\"half_day\":0,\"custom_hours\":0,\"hora_inic_sol\":\"00:00\",\"hora_fin_sol\":\"00:00\",\"hora_inic\":\"00:00\",\"hora_fin\":\"00:00\",\"hora_cita\":\"00:00\",\"doc_sol\":\"\",\"const\":\"\",\"follow_via_email\":1,\"posting_date\":\"2024-06-08\",\"status\":\"Open\",\"letter_head\":\"Membrete Samp\",\"leave_type\":\"Vacaciones\",\"employee\":\"CUE-10022\",\"leave_approver\":\"[email protected]\",\"leave_approver_name\":\"You\",\"employee_name\":\"Samp samp samp samp\",\"custom_col_dpi\":null,\"custom_empjoining\":\"2014-08-15\",\"custom_emp_branch\":\"Oficina\",\"department\":\"Administracion - Lans\",\"custom_col_phone\":\"+50256942010\",\"fecha_alta_vac\":\"2014-08-15\",\"from_date\":\"2024-06-10\",\"half_day_date\":\"\",\"to_date\":\"2024-06-11\",\"total_leave_days\":2,\"leave_balance\":48.618,\"fecha_reg_lab\":\"2024-06-12\"}",
"action": "Save"
},
"btn": {
"jQuery370028253802060637281": {
"events": {
"click": [
{
"type": "click",
"origType": "click",
"guid": 878,
"namespace": ""
}
]
}
}
},
"freeze": true,
"headers": {},
"error_handlers": {},
"url": "/api/method/frappe.desk.form.save.savedocs",
"request_id": null
}
{
"exception": "KeyError: 'error'",
"exc_type": "KeyError",
"_exc_source": "frappe_whatsapp (app)",
"_server_messages": "[\"{\\\"message\\\": \\\"Email sent to [email protected]\\\", \\\"title\\\": \\\"Message\\\"}\", \"{\\\"message\\\": \\\"Error: Value missing for WhatsApp Message: Content Type\\\", \\\"title\\\": \\\"Message\\\"}\"]"
}
I've noticed this error appears to remain in cache, even after modifying the document to no longer send email to [email protected], the error retains that error message.
This was on a template with no variables.
On another template with variables, if I attempted to use dates, the message would not be sent. If variables are changed to text, then it gets sent, but still shows the error message.
Please help.
When I am selecting Notification Type as Scheduled Events fields "Reference Document Type" and "Field Name" is disappearing but after saving below error is showing.
We can achieve this by unchecking "Mandatory" and adding this condition eval:doc.notification_type == "DocType Event" to field "Mandatory Depends On" in "Reference Document Type" and "Field Name" fields from "WhatsApp Notification" doctype.
I am unable to uncheck "Mandatory" from both fields because these are standard fields.
Is it possible to use ERPNext Chat to manage conversations?
Best,
Hi, Thanks for the awesome plugin,
I have exact 2 Whatsapp templates, one plain text the other comes with document,
the issue is that when i use the first one plain text (no media) it's working perfectly, but if i use the one with document, no message begins sent, i think it's related to the pdf file download.
I have already test the print via /api/method/frappe.utils.print_format.download_pdf
there is no issue.
Please try to fix this or inform me if there is any hidden step to do.
Ah just to be sure, my app on meta still in dev mode, can be this the issue? Note that I'm able to send text messages, but only with pdf not working.
Originally posted by shridarpatil December 7, 2022
We’re using Discussions as a place to connect with other members of our community. We hope that you:
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
When i create notification for workflow submitted state its gonna error
Output
AttributeError: 'NoneType' object has no attribute 'json'
Possible source of error: frappe_whatsapp (app
Try to test your app, but no massage sent
My developer account test not production
I installed Healthcare app, and by default it doesn't have any phone number field on the Patient Appointment DocType, so I created a Custom Form but on the Whatsapp Notification Reference Document Type Field it only accepts the Original DocType. At the moment I have found that is possible to fix this adding a Client Script but I think it is possible to implement this option by default.
I tried with the URL you have provided for the WhatsApp integration.
Its throwing the error.
Please help me to solve this @shridarpatil
i have generated token temp setting looks something like below
Certainly, here's a rephrased version of your statement:
I'm attempting to send messages upon creating a record, and although the record is saved and the status changes to success, I'm not receiving any messages. Do you have any suspicions about potential issues or anything unusual in this scenario? How can I go about debugging this situation? The phone number has already been added. My ERPNext instance is version 13, set up as a multitenant DNS-based system with SSL.
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
Hi
How to send image through whats app?
This error appears when I try to save a form in another doctype.
{
"crm": "2.0.0-dev",
"erpnext": "15.20.6",
"frappe": "15.23.0",
"frappe_whatsapp": "0.0.2",
"insights": "1.1.3",
"wiki": "2.0.0"
}
Form/Design/new-design-ejcbheawrt
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 110, 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 1718, 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 1306, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File "apps/frappe_whatsapp/frappe_whatsapp/utils/__init__.py", line 17, in run_server_script_for_doc_event
notification = get_notifications_map().get(
File "apps/frappe_whatsapp/frappe_whatsapp/utils/__init__.py", line 36, in get_notifications_map
enabled_whatsapp_notifications = frappe.get_all(
File "apps/frappe/frappe/__init__.py", line 2007, in get_all
return get_list(doctype, *args, **kwargs)
File "apps/frappe/frappe/__init__.py", line 1982, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
File "apps/frappe/frappe/model/db_query.py", line 185, in execute
self.columns = self.get_table_columns()
File "apps/frappe/frappe/model/db_query.py", line 546, in get_table_columns
return get_table_columns(self.doctype)
File "apps/frappe/frappe/model/meta.py", line 73, in get_table_columns
return frappe.db.get_table_columns(doctype)
File "apps/frappe/frappe/database/database.py", line 1197, in get_table_columns
raise self.TableMissingError("DocType", doctype)
pymysql.err.ProgrammingError: ('DocType', 'WhatsApp Notification')
{
"type": "POST",
"args": {
"doc": "{\"docstatus\":0,\"doctype\":\"Design\",\"name\":\"new-design-ejcbheawrt\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"naming_series\":\"DE-.YY.###\",\"design_for\":\"Customer\",\"title\":\"safasfsadsad\"}",
"action": "Save"
},
"btn": {
"jQuery37006038109508222111": {
"events": {
"click": [
{
"type": "click",
"origType": "click",
"guid": 652,
"namespace": ""
}
]
}
}
},
"freeze": true,
"headers": {},
"error_handlers": {},
"url": "/api/method/frappe.desk.form.save.savedocs",
"request_id": null
}
{
"exception": "pymysql.err.ProgrammingError: ('DocType', 'WhatsApp Notification')",
"exc_type": "ProgrammingError",
"_exc_source": "frappe_whatsapp (app)"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.