javascriptwhatsappvelowhatsapi

How to send a message in whatsApp by clicking on thebutton


I have a website made at https://www.wix.com and I need a js code to send message in whatsApp. There should be 'input' and 'submit button' and when user types his number in input and clicks submit button it should send the message to his whatsApp number. Is there any way to do this ?


Solution

  • You would need to use an API service like the Twilo API for WhatsApp in order to do this. (This is a fairly new service I think, I don't know if there are others like it.)

    You can see details on what's involved in getting you number verified and connected in the docs here.

    However, this would not work with your https://www.wix.com/ website because you need to run the code on a backend server. You need to keep the auth token and sensitive information back there. Also you need logic to decide when to send a WhatsApp message to a user's number, as a result of some action from the website. This needs to be handled by the backend server, and not directly from a user typing in their number and sending a message to it.

    The backend code for a server running Node.js would look something like this: (From the docs)