Ayyash
Elmota

Elmota

Script to send a WhatsApp message to yourself

Script to send a WhatsApp message to yourself

UNDOCUMENTED WHATSAPP FEATURE

Ayyash's photo
Ayyash
·Mar 21, 2022·
Listen to this article

I do not save numbers any more.

You can send a Whatsapp message to a valid international number without the need to save a contact. The API link looks like this

whatsapp://send/?phone=90873737777

So here is a quick JavaScript, in a quick HTML file:

<script>
    const url =  "whatsapp://send/?phone="; 

    function phone() {
        // get number, append, and browse to whatsapp://send/?phone=number
        // PS you can also add "&text=" parameter
        const phone = document.querySelector("#phone");
        let val = phone.value;
        // clean up
        val = val.replace(/[^\d]/gi, '');
        const _phone = url + val;
        document.location.href = _phone;

    }
</script>

<input type="text" id="phone" placeholder="Phone">
<button  onclick="phone()">Send</button>

This will open WhatsApp on desktop, or on mobile if it exists, with the phone number as the chat window. You can actually message yourself.

Deployed via the beautiful Surge.sh

Try it

PS: I could not find reference for that on WhatsApp Docs website, no idea why. Can you?

RESOURCES

 
Share this