WhatsApp Salesforce Integration

WhatsApp Salesforce Integration

Really !! Yes, though there isn't any official WhatsApp API being made available, it is possible to integrate WhatsApp to Salesforce. Question is how? Well, fortunately there is a free open-source library available on Github which can be used to register, send and receive messages in WhatsApp through Python code - Yowsup. Now before we jump into the technicalities and the architecture lets quickly see a demo where we will whatsapp a contact from our Salesforce org.

WhatsApp from Salesforce - Demo


From the docs - Yowsup is a python library that enables you build application which use WhatsApp service. For Quickstart introduction, architecture and installation steps you can refer this link. But before you start downloading and looking out for the code and demos, I recommend taking a look at the architecture used to put the integration in place.

In the subsequent article I will share the modified version of the yowsup-cli that has the latest version of WhatsApp SDK details and the corresponding MD5 classes key. Hopefully this will help save your time as it took some time for me to figure out the working version details.

Registration using yowsup-cli

Before starting with the actual Yowsup code you need to register (previously not registered) an actual SIM Card with WhatsApp. Below are the steps for registration using yowsup-cli:

Get Request Code

> python yowsup-cli registration --requestcode sms 
                               -p 91XXXXXXXXXX 
                               --cc 91 
                               --mcc <MCC Code> 
                               --mnc <MNC Code> 
                               -E android -d

Where, 91XXXXXXXXXX is the phone number associated to the new SIM Card you are registering. 91 is the country code for India that is to be passed to --cc parameter.

You can get --mcc and --mnc code from the below link. Refer your Country, State and Service provider for the corresponding codes.

Mobile Country Code

For e.g. the MCC and MNC code for an Airtel Number in Andhra Pradesh state would be 404 and 49 respectively.

With this command you should receive an SMS with a code in the format: YYY-YYY that you will use in the next step to get the password.

Get the Password

> python yowsup-cli registration 
                    --register YYY-YYY 
                    --phone 91XXXXXXXXXX 
                    --cc 91

The response would look like:

INFO:yowsup.common.http.warequest:b'{"status":"ok","login":"91XXXXXXXXXX","type":"new","pw":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx","expiration":4444444444.0,"kind":"free","price":"\\u20b9 55","cost":"55.00","currency":"INR","price_expiration":1485005582}\n'
price: b'\xe2\x82\xb9 55'
kind: b'free'
login: b'91XXXXXXXXXX'
type: b'new'
pw: b'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
currency: b'INR'
price_expiration: 1485005582
expiration: 4444444444.0
status: b'ok'
cost: b'55.00'

The value of pw is the password which we will use in our python client code to send and receive the whatsapp messages.


From Salesforce a callout is made to a Flask (Web microframework for building web applications with Python) Webapp hosted on Openshift with the Message, To and a Token. The Webapp consists of a Client code built on Yowsup library that sends the message and other details over http to whatsapp server and from there on the message is dispatched to the given number.

Whatsapp Salesforce Integration Design

In the next article we will see the Salesforce Callout code and the Yowsup based Client code hosted on Openshift. The Flask webapp can also be hosted on Heroku or with any other cloud hosting service provider. Openshift is free and also easy to commit the code with.

Note: Yowsup library isn't officially supported by Whatsapp. Whatsapp might block your number if it finds the usage suspicious (viz. Marketing, Spamming etc.)



At inteygrate.com, I am trying out ways to integrate Salesforce to various other technologies.

View Comments
Next Post

WhatsApp Salesforce Integration - The Code

Previous Post

Update Records in Salesforce from Zoho