Mobile website WhatsApp button to send message to a specific number
Format to send a WhatsApp message to a specific number (updated Nov 2018)
<a href="https://wa.me/whatsappphonenumber/?text=urlencodedtext"></a>
where
whatsappphonenumber is a full phone number in international format
urlencodedtext is the URL-encoded pre-filled message.
Example:
Create a link with a pre-filled message that will
automatically appear in the text field of a chat, to be sent to a specific numberSend I am interested in your car for sale to +001-(555)1234567
https://wa.me/15551234567?text=I%20am%20interested%20in%20your%20car%20for%20sale
Note :
Use: https://wa.me/15551234567
Don't use: https://wa.me/+001-(555)1234567
Create a link with just a pre-filled message that will
automatically appear in the text field of a chat, number will be chosen by the userSend I am enquiring about the apartment listing
https://wa.me/?text=I%20am%20enquiring%20about%20the%20apartment%20listing
After clicking on the link, user will be shown a list of contacts they
can send the pre-filled message to.
For more information, see https://www.whatsapp.com/faq/en/general/26000030
--
P.S : Older format (before updation) for reference
<a href="https://api.whatsapp.com/send?phone=whatsappphonenumber&text=urlencodedtext"></a>
Web link to specific whatsapp contact
********* UPDATE ADDED AT THE END *********
I've tried many approaches and I have a winner (see Test 3), here is the result of each one:
(I think the Test 3 will also work for you because if the person visiting your site doesn't have you on their contact list, it's the only option that will allow it.)
In all tests, the number had to be complete, with country and location code without any initial zeros. Example:
- +55(011) 99999-9999 (NOT)
- +5511999999999 (YES)
On tests 1 and 2, it only worked with a plus sign on the country code: +5511999999999
Test 1:
<a href="whatsapp://send?abid=phonenumber&text=Hello%2C%20World!">Send Message</a>
This way you must have the phonenumber on your contact list. It doesn't work for me because I wanted to be able to send a message to a number which I may not have on my contact list.
If you don't have the number on your contact list, it opens the Whatsapp listing all your registered contacts, so you can choose one.
It's a good option for sharing stuff.
Test 2:
<a href="intent://send/phonenumber#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end">Send Message</a>
This approach only works on Android AND if you have the number on your contact list. If you don't have it, Android opens your SMS app, so you can invite the contact to use Whatsapp.
Test 3 (The Winner):
<a href="https://api.whatsapp.com/send?phone=15551234567">Send Message</a>
This was the only way that worked fully for me.
- It works on Android, iOS and Web app on the desktop,
- You can start a conversation with a number that you don't have on your contact list
- You can create a link with one pre-built message adding &text=[message-url-encoded] like:
https://api.whatsapp.com/send?phone=15551234567&text=Send20%a20%quote
And if you wish to have a bookmarklet for additional ease of use, you may use this one:
javascript: (function() { var val= prompt("Enter phone number",""); if (val) location="https://api.whatsapp.com/send?phone="+escape('972' + val)+""; })()
Youll need to change the country code(or remove it) to you.r target country and paste it in the address field in a chrome/firefox link
Worth notice:
- I had to update my WhatsApp to the latest version
- The number's country code must not have a leading plus
- More details here: https://www.whatsapp.com/faq/en/general/26000030
***************** UPDATE (START) *****************
Whatsapp made available other option, now you can create one link to a conversation like this:
https://wa.me/[phonenumber]
The phone number should be in international format:
Like this:
https://wa.me/552196312XXXX
NOT like this:
https://wa.me/+55(021)96312-XXXX
And if you want to add one pre-built message to your link, you can add ?text= at the end with the text URL Encoded:
https://wa.me/552196312XXXX?text=[message-url-encoded]
Exemple:
https://wa.me/552196312XXXX?text=Send20%a20%quote
More info here:
https://faq.whatsapp.com/general/chats/how-to-use-click-to-chat
***************** UPDATE (END) *****************
Open Whatsapp message box on button click on a web page
You can use href of this element to
<a href="whatsapp://send?text=WHATEVER_LINK_OR_TEXT_YOU_WANT_TO_SEND" title="Share on whatsapp">WhatsApp</a>
For a specific number
href="//api.whatsapp.com/send?phone=91MOBILE_NUMBER&text=WHATEVER_LINK_OR_TEXT_YOU_WANT_TO_SEND"
Please make sure in phone, there is CountryCode 91 for India
Send msg to particular WhatsApp contact saved without country code
I mean you definitely need to know the country code somehow. you might be able to get it from the phone (read this answer for instance) in case it is absent.
then once you have it you simply write
phone="+"+foundCountryCode+phone;
but before you do that you need to check if the phone nr. doesnt already have a country code as some of the users contacts might be from other countries (we live in a globalized world) so simply check if the phone String begins with "+" or "00" and only perform the adjustment above in case it does not.
I did the following
public static String depuratePhone(String rawPhone){
String phone=rawPhone.replace(" ","").replace("+","00").replace("-","");
String depPhone=null;
if (phone.length()>2){
if (phone.substring(0,2).contentEquals("00")){
depPhone=phone;
}else{
depPhone="00"+your_current_country_code+phone;
}
}
return depPhone;
}
in order to get your own phones country code amazingly it seems you always have to create your own database of country codes as all you can get from the phone are 2 letter string codes for your country. I am also amazed that there is not a way to get this directly from the phone. Amazing, I wonder what the justification for this is.
the freaking TelephonyManager even lets you get your own phone number if you grant it a ton of permissions but not a simple country code.
Sharing link on WhatsApp from mobile website (not application) for Android
Just saw it on a website and seems to work on latest Android with latest chrome and whatsapp now too! Give the link a new shot!
<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>
Rechecked it today (17th April 2015):
Works for me on iOS 8 (iPhone 6, latest versions) Android 5 (Nexus 5, latest versions).
It also works on Windows Phone.
Related Topics
Add External CSS File to Blogger Template
Bad Value X-Ua-Compatible for Attribute Http-Equiv on Element Meta
CSS Calc Not Working in Safari and Fallback
How to Use a Grammar with The HTML 5 Speech Input API
When to Use <Span> Instead <P>
Why Isn't My Margin Working with Position: Fixed
Insert HTML Code Inside Svg Text Element
How to Make a Div with Arrowlike Side Without CSS Border Tricks
CSS Way to Horizontally Align Table
At The End of The Day, Why Choose Xhtml Over HTML
Twitter Bootstrap: Align Nav-Tabs to Bottom of Div
Inline Style to Act as: Hover in CSS
Youtube Video Header Background
How to Style Radio Buttons with Images - Laughing Smiley for Good, Sad Smiley for Bad
What Is The Browser-Default Background Color When Selecting Text