Send WhatsApp alert during a network fault

Send WhatsApp alert during a network fault

  • Tweet

A good network engineer must react quickly during a fault. On the market, there are several solutions to monitor the network malfunctions: HP Openview, Solarwinds, PRTG and other solutions (open source or not).

Generally, when an alert/warning is detected an event is triggered: email, SMS or text to a monitor. But why don’t you send these messages via whatsapp? It’s free and can reach everyone, everywhere!

What you need:

  • PHP with openssl extension enabled
  • WART
  • WhatsAPI-Official
  • SIM

In this tutorial, I use XAMPP Portable version 1.8.3 ( on a Windows7 64bit machine.

Note: The WhatsAPI-Official requires openssl extension enabled in the PHP settings; whitout this library the script cannot work!

Let’s start!

1. Retrieve your Whatsapp password

Download the “WART“, decompress it and execute the .exe file.


In the “Phone number” field insert your number; the number must contain the country code without the ’00’ or the ‘+’. For instance, for an italian number insert something like this “39xxxxxxxxxx’.

Click “Request Code“; you will receive a registration code in the format “yyy-yyy”. If for some reasons you will request the code again, you will receive a call with the registration code.

Insert the number received in the “Code” field without the ‘-‘ and click “Confirm Code”. A dialog box appears showing you the Whatsapp Password; save it!

Note: You can retrieve the password through the “registerTool.php” (script included in WhatsAPI-Official). The result is the same!

Remember: When you retrieve the new password for your SIM, the client on your smartphone will be disconnected!

2. Install WhatsAPI

Download the WhatsAPI-Official PHP class and decompress the archive (in my case into “E:\Portable\xampp\htdocs\WhatsAPI\”).

2a. Send a WhatsApp message to a list of numbers

Save this code into “send-message.php” (in my case saved in “E:\Portable\xampp\htdocs\WhatsAPI\examples\ folder”).

Change the variables:

  • $whatsapi_class_path
  • $username
  • $password
  • $nickname
  • $target

Now it is possible to send the message using one of these methods:

  1. Via Browser, calling the web page:

  2. Via CLI, using the command:

    php e:\Portable\xampp\htdocs\WhatsAPI\examples\send-message.php "YOUR_MESSAGE"

If all it’s fine, the numbers in the $target varialbe will receive a message!

2b. Send a whatsapp message to a group

Save this code into “send-to-group.php” (in my case in “E:\Portable\xampp\htdocs\WhatsAPI\examples\” folder).

Change the variables:

  • $whatsapi_class_path
  • $username
  • $password
  • $nickname
  • $target
  • $group_name or, if you have an existing group, $group_id

Now it is possible send a message to the group using one of these methods:

  1. Via Browser, calling the web page

  2. Via CLI, using the command:

    php e:\Portable\xampp\htdocs\WhatsAPI\examples\send-to-group.php "YOUR_MESSAGE"

If all it’s ok, the group will receive a message!

Other useful functions

To make someone admin of the group (you must be the owner of the group):

To demote an user, make an admin a normal user again:

To lock the group so anyone can’t change the profile picture or the status of the group:

To unlock the group:

To remove a group:

To add new users to a group:

To view all group_id, define the $debug to true and use the function:

I hope everything is clear! If yes, you can integrate your network monitoring tools with these scripts to send alerts during a network fault!

Note: This article is only a starting point, but with this API you can create several useful scripts! For instance, you can make a PHP BOT that can interact with the users, but for that check the “Simple CLI client.php” file!

If you want more info about WhatsAPI, see the official documentation…/WhatsAPI-Documentation.

Send WhatsApp alert during a network fault

Leave a Reply

Your email address will not be published. Required fields are marked *