Sending WhatsApp Messages from the Command Line: A Step-by-Step Guide

You can utilize the Mudslide console client to send WhatsApp messages directly from the command line or within scripts, which is especially convenient for system administrators who wish to dispatch notifications through automation processes.

Mudslide is built on the Baileys library, an unofficial open-source solution enabling interaction with the WhatsApp Web API via WebSockets, and is available on GitHub.

To begin, ensure that your machine has Node.js (along with the NPM package manager) and Git client installed. Guidance on installing Node.js can be found here, while Git can be acquired via an MSI installer or through the WinGet command:

winget install --id Git.Git -e --source winget

Once your setup is complete, install the Mudslide package and its dependencies using the command:

npm install -g mudslide

To execute Mudslide from the command line, utilize the npx tool. Start by checking the available options:

npx mudslide -v

The Mudslide client requires you to authenticate it as a secondary WhatsApp client. To login, run:

npx mudslide login

This command will generate a QR code for scanning with the WhatsApp app on your smartphone (navigate to Settings -> Linked Devices -> Link a device).

Upon successful authentication, you will receive a notification in the command prompt:

Success: Logged in

To test your setup, send a message to yourself:

npx mudslide send me "Hello World"

Additionally, to message another user, use their phone number (saving the number in contacts beforehand is not necessary):

npx mudslide send 4998765432188 "Hello World"

You can also send messages in one of your WhatsApp groups using the group ID format or tweak the command to introduce line breaks:

npx mudslide send 4998765432188 "HelloWorld"

Mudslide allows sending images and files too, support for formats like PNG, JPG, and PDF is included:

npx mudslide send-image 4998765432100 C:srcimage123.jpgnpx mudslide send-file 4998765432100 C:srcscan.pdf

You can even share location coordinates:

npx mudslide@latest send-location me 48.159731 11.560668

For messaging groups:

npx mudslide send-group 12345678910 "Hello"

Check your authentication status whenever needed by running:

npx mudslide me

To log out and delete the session data, use:

npx mudslide logout

Compiled versions of Mudslide are also available for download for other platforms, such as Linux.

By employing the Mudslide client, it’s possible to send WhatsApp messages directly from scripts or monitoring systems without relying on browsers or automation tools like Selenium.

For other related scripting instructions, explore:


Posted

in

, , ,

by

Tags: