[html] Web link to specific whatsapp contact

I'd like to place a link on a webpage which opens a whatsapp chat with a certain whatsapp contact. In other words: I want a "contact me by whatsapp" link to go next to the page's "Contact us my facebook/twitter/google+/etc" links. Something like:

href="whatsapp:[email protected]&message="I'd like to chat with you"

This question is related to html web whatsapp url-scheme

The answer is


This answer is useful to them who want click to chat whatsapp in website to redirect web.whatsapp.com with default content or message and in mobile device to open in whatsapp in mobile app with default content to text bar in app.

also add jquery link.

<a  target="_blank" title="Contact Us On WhatsApp" href="https://web.whatsapp.com/send?phone=+919581880892&amp;text=Hi, I would like to get more information.." class="whatsapplink hidemobile" style="background-color:#2DC100">
    <i class="fa fa-fw fa-whatsapp" style="color:#fff"></i>
    <span style="color:#fff">
        Contact Us On WhatsApp        </span>
</a>
<a  target="_blank" title="Contact Us On WhatsApp" href="https://api.whatsapp.com/send?phone=+919581880892&text=Hi,%20I%20would%20like%20to%20get%20more%20information.." class="whatsapplink hideweb" style="background-color:#2DC100">
    <i class="fa fa-fw fa-whatsapp" style="color:#fff"></i>
    <span style="color:#fff">
        Contact Us On WhatsApp        </span>
</a>

   <script type="text/javascript"> 
var mobile = (/iphone|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));  
if (mobile) { 

    $('.hidemobile').css('display', 'none'); // OR you can use $('.hidemobile').hide();
} 
else 
{ 
    $('.hideweb').css('display', 'none'); // OR you can use $('.hideweb').hide();
}
</script>

Phone Number will be a country code followed by WhatsApp mobile number without any symbol. Please refer below code.

<a href="https://api.whatsapp.com/send?phone=19998887878&text=Hi%20There!">WhatsApp Now</a>


I've tried this:

<a href="whatsapp://send?abid=phonenumber&text=Hello%2C%20World!">whatsapp</a>

changing 'phonenumber' into a specific phonenumber. This doesn't work completely, but when they click on the link it does open whatsapp and if they click on a contact the message is filled in.

If you want to open a specific person in chat you can, but without text filled in.

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

You'll probably have to make a choice between the two.

some links to help you Sharing link on WhatsApp from mobile website (not application) for Android https://www.whatsapp.com/faq/nl/android/28000012

Hope this helps

(I tested this with google chrome on an android phone)


From the Official Whatsapp FAQ: https://faq.whatsapp.com/en/android/26000030/

WhatsApp's Click to Chat feature allows you to begin a chat with someone without having their phone number saved in your phone's address book. As long as you know this person’s phone number, you can create a link that will allow you to start a chat with them. By clicking the link, a chat with the person automatically opens. Click to Chat works on both your phone and WhatsApp Web.

To create your own link, use https://wa.me/ where the is a full phone number in international format. Omit any zeroes, brackets or dashes when adding the phone number in international format. For a detailed explanation on international numbers, read this article. Please keep in mind that this phone number must have an active account on WhatsApp.

Use: https://wa.me/15551234567

Don't use: https://wa.me/+001-(555)1234567

You can use the following URL as per the WhatsApp FAQ:

https://wa.me/PHONENUMBERHERE

Add the country code in front of the number and don't add any plus (+) sign or any dashes (-) or any other characters in the number. Only integrers/numeric values.

You can also predefine a text message to start with:

https://wa.me/PHONENUMBERHERE/?text=urlencodedtext


For what its worth, as of this writing (Nov. 29, 2018), the updated API that seems to work on my end is using this link:

https://wa.me/<phone number here>

Note:

Just replace the placeholder <phone number here> with the intended phone number that you want to use INCLUDING the country code, this means I had to add +60 then the rest of the remaining number.

It doesn't work on my end without one (using Android and iOS at least). It doesn't work means an error message that says along the lines of "you don't have this number".

Reference:

https://faq.whatsapp.com/en/general/26000030


You can now use a very simple API https://wa.me/ to perform this task where you can provide a valid whatsapp contact number like 15555555555 ( add country code, remove all '+', '-', brackets, spaces or leading zeros). You can also provide a urlencoded text as a predefined msg which user can send directly or change before sending.

Chat with me link : <a href="https://wa.me/15555555555">Contact me by whatsapp</a>

Chat with me link with predefined text : <a href="https://wa.me/15555555555?text=I%27d%20like%20to%20chat%20with%20you">Contact me on whatsapp</a>

Beauty of this wa.me url is you don't need to check user agent as it works on both mobile and desktop (opens web.whatsapp.com)


Source : https://faq.whatsapp.com/en/general/26000030

More details in my answer on a similar question https://stackoverflow.com/a/51854282/2485420


The solution that worked for me is here in PHP:

$android = stripos($_SERVER['HTTP_USER_AGENT'], "android");
$iphone = stripos($_SERVER['HTTP_USER_AGENT'], "iphone");
$ipad = stripos($_SERVER['HTTP_USER_AGENT'], "ipad");

$whatsappNumber = '1234597891';
$whatsappLink = '';
if($android !== false || $ipad !== false || $iphone !== false) {//For mobile
    $whatsappLink = '<a href="https://api.whatsapp.com/send?phone='.$whatsappNumber.'">'.$whatsappNumber.'</a>';
} else {//For desktop
    $whatsappLink = '<a href="https://web.whatsapp.com/send?phone='.$whatsappNumber.'">'.$whatsappNumber.'</a>';
}

I tried all combination for swiss numbers on my webpage. Below my results:

Doesn't work for Android and iOS

https://wa.me/0790000000/?text=myText

Works for iOS but doesn't work for Android

https://wa.me/0041790000000/?text=myText
https://wa.me/+41790000000/?text=myText

Works for Android and iOS:

https://wa.me/41790000000/?text=myText
https://wa.me/041790000000/?text=myText

Hope this information helps somebody!


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.

<a href="https://api.whatsapp.com/send?phone=2567xxxxxxxxx" method="get" target="_blank"><i class="fa fa-whatsapp"></i></a>

Google Chrome am targeting a blank window


The following link seems to work fine -

<a href="whatsapp://send?text=Hello World!&phone=+9198********1">Ping me on WhatsApp</a>

It opens the contact in WhatsApp app, along with the message 'Hello World!' prepopulated in the input text box.

(Tested this with google chrome on an android phone.)


Examples related to html

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

Examples related to web

Cannot open local file - Chrome: Not allowed to load local resource How do I detect if a user is already logged in Firebase? HTML button opening link in new tab What does "app.run(host='0.0.0.0') " mean in Flask Web link to specific whatsapp contact App not setup: This app is still in development mode How to delete/remove nodes on Firebase Cannot read property 'push' of undefined when combining arrays HTML: Image won't display? JWT (JSON Web Token) library for Java

Examples related to whatsapp

Get Path from another app (WhatsApp) Does WhatsApp offer an open API? Web link to specific whatsapp contact Mobile website "WhatsApp" button to send message to a specific number Showing Thumbnail for link in WhatsApp || og:image meta-tag doesn't work Sharing link on WhatsApp from mobile website (not application) for Android Add Whatsapp function to website, like sms, tel Provide an image for WhatsApp link sharing Send text to specific contact programmatically (whatsapp) WhatsApp API (java/python)

Examples related to url-scheme

Web link to specific whatsapp contact iOS Launching Settings -> Restrictions URL Scheme Open Facebook page from Android app? How to mark-up phone numbers?