Create a link that will open Viber and WhatsApp and will send a message to me

Alexander picture Alexander · Dec 25, 2016 · Viewed 56.8k times · Source

Everyone around used to use IM. On my site I need to put a link that will open given instant messaging application (both on PC and on mobile) and open a send message to my number - and I can't find a way!

I suppose to use some URL scheme to do that, but all I can find is (__number is my mobile phone number):

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

and

<a href="viber://add?number=__number__">Viber</a>

(I don't even know if I should use phone in +1202... or simple 1202... (that is, if the plus is needed)

but frankly speaking it won't work. Viber opens its window and then tells me it won't handle that request, and WhatsApp is not linked to intent scheme at all (tested at several devices and OSes).

So, I please ask you to help me with this small problem: what kind of URL will open Viber and WhatsApp apps to let visitors of the site to contact me?

Answer

Pedro Lobito picture Pedro Lobito · Dec 25, 2016

What you need is called deep-linking, some examples for viber and whatsapp are:

Viber:

<a href="viber://pa?chatURI=[public account URI]&text=[message text]"> some text </a>

WhatsApp:

<a href="whatsapp://send?abid=[users name]&text=[message text]"> some text </a>

While not a deep link, you can also use the following url (don't use + on phone) for WhatsApp:

<a href="https://api.whatsapp.com/send?phone=0000000">Contact Me</a>

Sources:

http://origamiengine.com/deep-linking
https://support.viber.com/customer/en/portal/articles/2872423-deep-links