Web link to specific whatsapp contact
Asked Answered
W

15

163

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"
Wiatt answered 20/5, 2015 at 8:39 Comment(2)
Possible duplicate of Mobile website "WhatsApp" button to send message to a specific numberMcabee
Official FAQ: faq.whatsapp.com/452366545421244Jeremyjerez
J
331

********* 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:

***************** 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) *****************

Javierjavler answered 11/4, 2017 at 22:29 Comment(11)
Just to help other users avoid the same mistake I did, use the international prefix but without the plus. So italian 0039 becomes 39.Staff
yes, + symbol not required, so, e.g, if you want to link to an Indian number, you could leave out the plus in +919********* and just use 91 as the prefix. 91**********July
whatsapp link wont work if you do not have the person contact in your phoneSizeable
exactly @JamesTan, if you want to contact someone that is not on your contact list use like this: api.whatsapp.com/send?phone=15551234567 as shown above.Stereoisomer
i realised it works even if phone dont exists, my mistake was that ive invalid number, with extra one digit which causes the errorSizeable
The third option is actually a page that finally redirects to whatsapp://send?phone=15551234567 so you might want to skip the intermediate step.Evannia
Couldn't thank you enough for your time and efforts!Shopper
Test 3 (The Winner): phone number shared via url is invalid - when the number is not in your contact list!Nimble
This works in 2022 the same. But as MDaldoss said, without the + or 00 in front of the country prefix.Biggers
Old post but this is actually a good reference as this worked for meLothians
If you want to use whatspp web app to send messages manually replace api.whatsapp.com by web.whatsapp.com in the links like https://web.whatsapp.com/send?phone=15551234567Springbok
S
68

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.)

Semivowel answered 16/1, 2017 at 10:21 Comment(6)
I tested this with Safari on an iPhone and it worked!Meryl
Works in Opera and Chrome.Mixture
It works on Chrome, Firefox and the default browser of Android 6 and it also works on both Safari and Chrome on iPhone6 (Dec. 2017).Bibliomancy
Not working in UC Browser but working fine in Chrome.Foucault
doesnt work for me in 2023Kobayashi
@Kobayashi Which browser/OS did you try? It seems to work fine for me with Chrome on Android and Chrome on Windows desktop.Semivowel
D
14

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

Diphase answered 13/8, 2018 at 11:31 Comment(3)
This opens Play Store in Android, after a confirmation page.Wadesworth
@Wadesworth Yes it probably opens in the app store because it wants to install the WhatsApp app. If you already have WhatsApp installed, it will open whatsapp and start a chat with the number.Diphase
Source: faq.whatsapp.com/452366545421244Jeremyjerez
J
12

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)

Jackanapes answered 11/2, 2016 at 15:24 Comment(0)
C
11

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://mcmap.net/q/151702/-mobile-website-quot-whatsapp-quot-button-to-send-message-to-a-specific-number

Chaumont answered 18/8, 2018 at 19:49 Comment(0)
M
6

I have been struggling with how to do that as well. I managed to find this helpful method

from php variable:

href="https://wa.me/<?php echo esc_attr( $phone ); ?>?text=Hi%27,%20like%20to%20chat%20with%20you"

<?php echo esc_attr( $phone ); ?> for number in the format:

href="https://wa.me/263777300093?text=Hi%27,%20like%20to%20chat%20with%20you"
Macadamia answered 7/8, 2021 at 9:13 Comment(0)
P
5

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

Paternalism answered 29/11, 2018 at 3:8 Comment(2)
@Korayem you're kidding right? that's why in my answer I explicitly said "I added the + plus sign" because the duplicate that you linked doesn't workPaternalism
deserves to be a comment on the original answerEpochal
B
5

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
Bisulcate answered 14/2, 2019 at 19:55 Comment(0)
C
4

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

Crepe answered 30/4, 2017 at 1:21 Comment(1)
This works for me on Windows and iOS even if the contact isn't in my phonebook yet, so I guess WhatsApp has updated this since this answer was posted. More details and usage in their official FAQ.Westerly
R
3

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>
Rondelle answered 7/8, 2018 at 7:32 Comment(1)
Seems that you can use the direct link https://wa.me/PHONENUMBERHERE for mobile and desktop now.Latter
L
3

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!

Loaning answered 4/7, 2019 at 12:57 Comment(0)
N
2

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>';
}
Nepil answered 18/9, 2018 at 11:8 Comment(0)
L
1

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>
Logomachy answered 3/12, 2018 at 13:56 Comment(0)
F
0

To create a web link to a specific WhatsApp contact, you can use the following URL format: https://wa.me/XXXXXXXXXXXX

Replace XXXXXXXXXXXX with the full international phone number, including the country code, but without any leading zeros, plus signs, or spaces. For example, if the phone number is from the United States, you would use a format like this:

https://wa.me/1XXXXXXXXXX

When someone clicks on the link, it will open WhatsApp with a chat window to the specified phone number if they have WhatsApp installed on their device.

Footed answered 31/10, 2023 at 15:46 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.