In this article, you will learn how to connect and integrate WhatsApp with Odoo. To do this integration we are going to use WhatsApp web API. After connecting WhatsApp with Odoo you can send messages to your WhatsApp contact list from Odoo.
How to Connect WhatsApp with Odoo
To create a Whatsapp connector in Odoo you just need to create a button in your XML file and a method or WhatsApp integration function in Python code. Below is the complete guideline to configure WhatsApp with Odoo.
Read More: Connecting Odoo to Third Party Apps using XML RPC
Whatsapp Integration with Odoo (XML)
<button name="btn_whatsapp" string="Whatsapp" type="object" icon="fa-whatsapp"/>
Whatsapp Integration with Odoo (Python)
def btn_whatsapp(self):
message = 'Hello'
wa_api_url = 'https://api.whatsapp.com/send?phone=%s&text=%s' % (self.phone,message)
return {
'type': 'ir.actions.act_url',
'target': 'new',
'url':wa_api_url
}
In the message variable, you can get the message from an Odoo text or HTML field, similarly, you can get a phone number from the text field dynamically. In general, you can create a wizard with a phone number and text message field and on the button click call that function to send messages from Odoo.
Read More: Install Python Packages Automatically on Installation of Odoo Modules
If you are facing some issue with this WhatsApp API URL.
https://api.whatsapp.com/send?phone=%s&text=%s' % (self.phone,message)
Then replace the above Whatsapp API URL with the below one.
https://web.whatsapp.com/send?phone=%s&text=%s' % (self.phone,message)
0 Comments