WhatsApp API – How to use the WhatsApp Chat API
WhatsApp is together with Facebook Messenger, WeChat, Line and Telegram one of the biggest messaging services. A programmatic access via a WhatsApp API would be a fundamental requirement to create chatbots, support systems or other services which live on top of the Whatsapp ecosystem. Unfortunately, WhatsApp hasn’t released an official API yet. In this article, we talk about what is actually available, unofficial APIs and alternatives. Moreover, this article will constantly be updated with the latest news around the WhatsApp APIs.
How to get access to the WhatsApp API?
The answer is, currently there is no official way to get full programmatic access to the Whatsapp ecosystem. There are some libraries available which use an unofficial API to send and receive messages, but this is only limited to a single number. All those libraries are basically hacks which try to act like a standard WhatsApp client which you see on Android or iOS in combination with WhatsApp Web. This is a cool way to run some tests, but for a real chatbot or a sophisticated support system, especially in an enterprise context, it’s not the right choice. Moreover, it seems like WhatsApp doesn’t tolerate these libraries and regularly forces the developers to discontinue their projects. Nevertheless, there is one official offering by WhatsApp: the Click to Chat API.
The Click to Chat API
WhatsApp offers a very simple “Click to Chat” API which is basically only a link containing a target number and a prefilled text. Once a user clicks on this link, the WhatsApp client (Android, iOS, Web, etc) opens with a new message to the prefilled number with the prefilled text. This is a cool way to add a fast contact option for example if you want to sell your car. The link needs to contain the phone number in international format and the URL-encoded text. So if you want to send “I’m interested in your car for sale” to +1(555)1234567 the link must be:
Will there be an official WhatsApp API in future?
Yes, we think so. Facebook already opened the Messenger platform via an API a while ago and since WhatsApp got acquired by Facebook there is hope. Once there are updates, you will read it here and in case we see an official WhatsApp API, it will definitely become part of the CloudRail Unified Messaging API.
Edit: Today (Jan 18th 2018), WhatsApp announced the WhatsApp Business App which allows small business to get in touch with their customers. This is not an API, but at least a way to officially communicate as a brand rather than a normal user (phone number). It comes with features like automatic answers if you are not available, quick replies or welcome messages.
WhatsApp API Alternatives / The Universal Messaging API
If you want to play around with messaging platforms to build chatbots or other systems, have a look at Facebook Messenger, Telegram, Viber, Slack or Line. All of these services offer a full API which is easy to implement with CloudRail. With our Unified Messaging API, you can access all services via a single interface. So e.g. the function to send a message works exactly the same for Facebook Messenger as for Telegram (and hopefully soon WhatsApp). Check out our tutorial how to create a chatbot for Facebook Messenger.
Once an official WhatsApp API becomes available, it will be added to this universal API as well. This means you can start building your system based on other messaging services and make WhatsApp available to it with just a line of code eventually.
Here is a small code sample how the Unified Messaging API abstracts over all provider APIs and offers a universal function to send a message (see line 43):
Other platforms like Android, iOS or Xamarin can be found here.
Get Started Now
Create a free CloudRail account and download the Unified Messaging SDK.
We will keep this article updated to cover the current situation regarding the WhatsApp API.