Tutorial: Send automatic WhatsApp messages from Python

WhatsApp is the most popular mobile messaging application around the world, above its closest competitor (Telegram) its simplicity has made it easy for anyone to use.

Many companies use WhatsApp to promote their services or maintain communication with their customers, either to provide service or to sell them directly..

WhatsApp offers a version for companies and a web version available from the browser, but there are situations where it is necessary to automate certain processes and these versions are not enough.

In this short but important tutorial we will teach you how to automate the sending of WhatsApp messages using Python.

The first thing we will do is install the library pywhatki available from PYPI and installable with the following command:

pip install pywhatkit

Before executing the code it is necessary to be logged in to the web version of WhatsApp.


It is necessary to import the library to be able to send the messages, once that is done we must use the following line of code

pywhatkit.sendmsg (“recipient's mobile number”, “message”, hours, minutes)

  • Receiver's mobile number: the recipient's mobile number must be in string format and the country code must be mentioned before the mobile number.
  • Message: Message to send (must be in string format).
  • Hours: This module follows the format of 24 hours.
  • Minutes: Mention the minutes of the scheduled time for the message (00-59).

So, if you need to send a WhatsApp message to a specific number it is necessary to indicate the target WhatsApp number, the desired message, and include the hour and minute where the message should be sent.

You can see the complete code here:

When the code is executed, a window will open where the message will be sent via WhatsApp web, and you will receive the message.

In this way, If you want to send advertising messages to different WhatsApp numbers, you should only create a list with all the numbers and execute the previous code.

2 thoughts on “Tutorial: Send automatic WhatsApp messages from Python”

Leave a Reply

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

six − three =