How to Fix WhatsApp Api on Desktop Browsers

Jean Livino
Jan 12, 2018 · 2 min read

In this post I will teach you how to solve the WhatsApp api link problem “Click to Chat” does not work in Firefox and Safari desktop browsers by creating a “responsive” WhatsApp link.

What is the api of WhatsApp?

There’s a time WhatsApp has released a “Click to Chat” function where you can create links where the person can start a conversation with you without it having the saved phone number. With this function you can even add standard texts for the person to send to you.

What’s the problem?

There are three bases for you to do this solution: whatsapp://, api.whatsapp and web.whatsapp. Throughout the internet you will find people teaching with api., However in some tests I realized that it doesn't work in Firefox and Safari desktop browsers and iPhone. Web.whatsapp doesn't work on desktops and whatsapp:// works on mobiles.

How to Solve?

This can be solved with a simple script that will redirect the user according to the device he is using.

Update 01/2019 — I create a link generator with React and Express what you can use in your server or with my example. read more at:

Update 05/2019 — For WordPress users i create a plugin to generate redirect links:

<?php// Fix Api Whatsapp on Desktops// Dev: Jean Livino// insert the text and message$phone = 'YOURNUMBER';$message = 'YOURTEXT';// DO NOT EDIT BELOW$message = urlencode($message);$message = str_replace('+','%20',$message);$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");// check if is a mobileif ($iphone || $android || $palmpre || $ipod || $berry == true){header('Location: whatsapp://send?phone='.$phone.'&text='.$message);//ORecho "<script>window.location='whatsapp://send?phone='.$phone.'&text='.$message</script>";}// all otherselse {header('Location:'.$phone.'&text='.$message);//ORecho "<script>window.location=''.$phone.'&text='.$message</script>";}?>

GitHub Link

  1. A Change where “YOURNUMBER” is by its number in the following format 15551234567, without the “+” and “()”..
  2. Replace the text “YOURTEXT” with what you want the person to send.
  3. Save the file named index.php and upload it to your server.


The “Click to Chat” solution is awesome, but for your actions you need to be aware of this api, otherwise you will end up losing many leads that use Safari and Firefox.

This is my first post on Medium. Did you find this post relevant? If so, give a Clap and a Follow to help: D

Originally published at on January 12, 2018.

Jean Livino

Written by

FrontEnd Developer and Digital Marketing adept at Growth Hacking. | Desenvolvedor FrontEnd e Marketing Digital adepto ao Growth Hacking.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade