In this blog, we are going to automate WhatsApp using Python pywhatkit module. We will guide you with the easiest way to use pywhatkit module which utilizes WhatsApp web to send automated whatsapp messages using python . Python offers quite a wide range of libraries to help with our work. Pywhatkit is one of those libraries that will help in sending WhatsApp messages. It has several other features too:
- Send WhatsApp message
- Play a YouTube video
- Perform a google search
- Information about a particular topic
AUTOMATE WHATSAPP USING PYTHON Pywhatkit:
Installation and Setup :
pip install pywhatkit
When using the library Pywhatkit, you need to be logged in web.whatsapp.com website and have a chrome browser to set a whatsapp message at a given time.
If google chrome is missing from your device you need to follow these simple steps:
- Download and extract the chrome from https://chromedriver.chromium.org/.
- Then go to the downloaded file and search for chrome drive application copy its path.
- Then call the pywhatkit.add_driver_path(path) and pass the copied path. If the path is right a window will appear with the chrome.
- Now scan the code by calling on the function pywhatkit.load_QRcode().
Let’s Code & Automate Whatsapp using pywhatkit:
After following the above steps, pywhatkit module should be installed and configured correctly. Now we are close of sending a automated message using python in just 2-3 lines of code .
You can also use pywhatkit.manual() to see the setup steps in your python script.
pywhatkit.sendmsg(“receiver mobile number”,”message”,hours,minutes) Parameters: Receiver mobile number: The Receiver’s mobile number must be in string format and the country code must be mentioned before the mobile number. Message: Message to be sent(Must be in string format). Hours: This module follows the 24 hrs time format. Minutes: Mention minutes of the scheduled time for the message(00-59).
import pywhatkit pywhatkit.sendwhatmsg("+919*********", "I love hackanons.com!", 20, 30)
Also, provide 3-5 minutes in the future for the message to be sent because if you will give 1-2 minutes it will give error.
How it works ? [Automate WhatsApp using Python pywhatkit]
Pywhatkit library is working on the basis of whatsapp.web.com in which they are automating the browser and sending the message. This library is very helpful. For instance, if you have to send thousands of messages. Then you can easily create a list of phone number and message on which you can add a ‘For loop’. By doing this you can run this function again and again. Now you can open your WhatsApp Web and check the message which was scheduled to be sent.
So that’s it for this post, you can use this python script to automate daily Good Morning messages for your loved one’s or another use case can be to automate the sending of marketing leads on WhatsApp business. In the end, I would like to remember Mark Benny’s Quote.
“The most powerful tool we have as developers is automation.”Mark Benny’s
Happy Whatsapp Automation using Python pywhatkit.