Hi I would like to know if there is something to send a whatsapp message using javascript or something I was searching but I did not find any new post. This is not for any special purpose. I found this but it only works if you have whatsapp web. I was thinking on clicking on a link to send a default message to a default number
<a href="https://api.whatsapp.com/send?phone=1111111111">Send Message</a>
js) → We need to scan this QR from the WhatsAPPWeb from WhatsApp mobile app. var data = [{ id: 1, received: 'Hello', reply: 'Hi'},{ id: 2, received: 'Sorry', reply: 'No problem'},{ id: 3, received: 'Can we have a call? ', reply: 'Please leave a voicemail.
Sure! We only need to install a library called pywhatkit. Then we can schedule messages to send to any of our contacts or even to a group. Here are the 3 steps you need to follow to send WhatsApp messages to contacts and groups using Python.
js works by running WhatsApp Web in the background and automating its interaction, you'll need to authorize the client by scanning a QR code from WhatsApp on your phone. Copied! And now we'll modify our code to use this new module: const qrcode = require('qrcode-terminal'); const { Client } = require('whatsapp-web.
Install the WhatsApp Business API Client — Install your API client. Once your client is working, you can update your application settings. Start using the client — Register your phone number with an API call to /account and send a test message with a call to /messages .
Just make use of this function in web browser to get it running as you want.
Note: You need to run the code manually through browser console with an opened conversation in WhatsApp (web version).
function sendMessage (message) {
window.InputEvent = window.Event || window.InputEvent;
var event = new InputEvent('input', {
bubbles: true
});
var textbox = document.querySelector('div._2S1VP');
textbox.textContent = message;
textbox.dispatchEvent(event);
document.querySelector("button._35EW6").click();
}
My gist
Original code
Thanks to Gabriel!
Important: If you're trying to send a message directly from URL (i.e using API), you cant. Its impossible to send WhatsApp messages without user interaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With