Automated Bulk WhatsApp Messaging using Python

We can automate WhatsApp to send messages by running a python script. In this tutorial, we will learn the simplest way of doing so using the pywhatkit module which utilizes the web.whatsapp.com webpage to automate message sending to any number on WhatsApp.

Whatsapp automation using Python

Now let’s setup pywhatkit module and write the code to send WhatsApp message automatically.

Install pywhatkit module:

To install the pywhatkit module, we can use the pip command:

pip install pywhatkit

This command will download the pywhatkit module. It will take some time as it will download some related modules too.

Using pywhatkit module:

To use this python module to send message automatically on WhatsApp at a set time, we need chrome browser and you must have your WhatsApp logged into web.whatsapp.com website.

If you do not have chrome browser, then you can follow the following steps:

  1. Download and extract the current stable release of chrome driver from https://chromedriver.chromium.org/
  2. Open the downloaded file and search for an application named chrome drive, copy its path, for windows, it should look like this - C:/Users/…/chromedriver.exe.
  3. Then call pywhatkit.add_driver_path(path) and pass the copied path as an argument, if the path is valid, a black window along with chrome will open and close.
  4. Now call pywhatkit.load_QRcode() function and scan the QR code.

After following the above steps, you do not have to do anything, just run the final script to send whatsapp message.

To see the setup steps, you can use the pywhatkit.manual() method in your python script.

The code is super simple,

import pywhatkit as kit

kit.sendwhatmsg("+919*********", "I love studytonight.com!", 18, 21)

In the above code, we have specified the mobile number on which we want to send the message, then the message, and then the time at which the message has to be sent. This module follows the 24 hrs time format, hence the time 18:21 is 06:21 PM.

OUTPUT

In 702 seconds web.whatsapp.com will open and after 60 seconds message will be delivered

Also, you should provide atleast 4-5 minutes future time from the current time while running the script, because if you will set the time 1-2 minute from current time, then the module will give error.

Conclusion:

So that’s it. You can use this script to automate WhatsApp to send Birthday wishes to your friends and family, to send daily morning message to your parents or use it for some business idea. As developers, we should look for ways to minimize our efforts and maximize the output.

If you face any issue while running this script, do share it with us in the comment section below.

Thank you for reading!

#python #whatsapp

Automated Bulk WhatsApp Messaging using Python
134.65 GEEK