Connecting Whatsapp "Click to Chat" feature [SOLVED!]

Hello Coders,
Is there a way to connect the whatsapp click to chat feature to a text box containing a phone number? I have done till here:

export function phonenumber_click(event) {

let phonenumber=$w("#phonenumber").text;
let phonenumber_link="https://api.whatsapp.com/send?phone="+phonenumber;
$w("#phonenumber").XXXXXXXXXXXXXXXXXXXXXXXX==phonenumber_link. 

I need to assign the variable phonenumber_link to the phonenumber text element so that when the user clicks on it, their whatsapp is automatically opened for messaging. I tried using this :

 $w("#phonenumber").link=phonenumber_link. 

But its showing an error and unfortunately I couldn’t find any way to assign that link to a text box(phonenumber ). Do you guys have any idea? Thanks

Update: I just found that there is a function called to() in wix-location. It solved my issue.

wix-location-frontend - Velo API Reference - Wix.com

2 Likes

any one please help for me for this i want to connecct whatsapp

Hi shivamgolhani,

You can refer to this sample code to implement the WhatsApp Click to Chat feature.

Good luck!

Regards, Ben