Whatsapp message

Hi… I found the code to send message from my website to Whatsapp number… but I have a problem… I need to send the message in many lines. In javascript that code is “\n”:

	var phoneNumber = "+57" + $w("#input4").value; 
	var Texto = "Gracias " + $w("#input1").value + " " + $w("#input2").value+"\n"+ 
				"Ahora perteneces a la gran comunidad Coffee Time+"\n"+ 
				"Disfruta nuestros productos."; 
	var phonenumber_link = "https://api.whatsapp.com/send?text=" + Texto + "&phone=" + phoneNumber; 
	$w("#button1").link = phonenumber_link; 

This last code does’t work… but the next yes…

	var phoneNumber = "+57" + $w("#input4").value; 
	var Texto = "Gracias " + $w("#input1").value + " " + $w("#input2").value+"..."+ 
				"Ahora perteneces a la gran comunidad Coffee Time+"..."+ 
				"Disfruta nuestros productos."; 
	var phonenumber_link = "https://api.whatsapp.com/send?text=" + Texto + "&phone=" + phoneNumber; 
	$w("#button1").link = phonenumber_link; 

The only diferent is “\n” <> “…”

Can you help me to get the syntax to get a new line between the same text?.

Thanks

3 Likes

Hi,
Since you’re putting the string into a URL, you need to use the encoded version of new line, which is %0A . I’d also recommend using encodeURI() on the entire string to make sure special characters don’t sneak in and mess up your link.

Thanks Ohad… it works Ok… now, I would like to know, how can I send WhatsApp Emojis through WixCode?

Thanks and regards.

Hi,

Simply use the java code for emojis from this database

For example typing \uD83D\uDC32 before you encode will produce a dragon emoji after you decode.

You can test it here

What is the full code?

Hi,

I managed to implement the WhatsApp Click to Chat feature on my website. Here is a sample code for anyone who needs help.

Was wondering if anyone knows how to directly send the message instead of opening the WhatsApp mobile or web app?

Thank you.

Regards, Ben