Adding to Facebook, Twitter, now WhatsApp is picking up in "Social Media" although it is not a social media. Now, how many of you know that you can directly send messages or start a conversation in WhatsApp, right from a website? I have installed AddThis in my blog, so I saw there was an option to share using WhatsApp, so I thought of finding how it works.

Using WhatsApp Protocol

The WWW (World Wide Web) works on the HTTP or HTTPS protocol. Similar to that, WhatsApp has its own protocol that is known to the devices, which starts with whatsapp://. The schema is very straight-forward and it looks something like this:

whatsapp://send?text=message

With the above code, we can invoke WhatsApp with a pre-filled message that asks us for whom to send. So, using the above schema, we can embed a link that invokes WhatsApp with a predefined message using:

<a href="whatsapp://send?text=Hello%2C%20World!">Send message to WhatsApp</a>  

When you click on the above, it displays this way:

This is just the beginning. Try clicking on Send message to WhatsApp and see what happens.

Using Android Intent

Intents in Android are messages that allow your browser to request functionality from the WhatsApp app. Intents allow not only sending messages, but also to interact with components from the same applications as well as with components contributed by other applications. This is something similar to Inter Process Communication and Intra Process Communication.

For WhatsApp, the intent scheme might be like this:

intent://send/+XXXXXXXXXXX#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end  

To use that in a web page, you can wrap it in a <a> tag:

<a href="intent://send/+XXXXXXXXXXX#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end">Open WhatsApp chat window</a>  

In the above, you need to change the +XXXXXXXXXXX to a valid WhatsApp number in International Format. Hope this was useful. Do let me know what you think in the comments below.