Sending WhatsApp Messages Instantly with Python and pywhatkit
WhatsApp has become an essential communication tool for billions of people worldwide. Wouldn’t it be cool if you could automate sending WhatsApp messages programmatically? In this blog, we’ll explore how to do just that using Python and the pywhatkit
library.
Introduction to pywhatkit
pywhatkit
is a Python library that provides a simple interface to interact with WhatsApp through automation. With this library, you can send text messages, search on Google, play YouTube videos, and perform various other tasks seamlessly.
Prerequisites
Before we get started, ensure you have the following:
- Python installed on your system.
- An active WhatsApp account linked to your phone.
Installing pywhatkit
To install the pywhatkit
library, use the following pip command:
pip install pywhatkit
Sending Instant WhatsApp Messages
Now that we have pywhatkit
installed, let's dive into sending instant WhatsApp messages. Below is a Python script that takes the recipient's phone number and the message as inputs and sends the message instantly:
import pywhatkit
phone=input("Enter Phone Number: ")
message=input("Enter message: ")
pywhatkit.sendwhatmsg_instantly(phone,message,10)
In this script, we use the sendwhatmsg_instantly()
function provided by pywhatkit
. It takes three arguments: the recipient's phone number (including the country code), the message to be sent, and the waiting time in seconds (here, 10 seconds).
How the Script Works
- The script prompts the user to enter the recipient’s phone number and the message they want to send.
- It then calls the
sendwhatmsg_instantly()
function frompywhatkit
and passes the phone number, message, and the waiting time (10 seconds). - The
sendwhatmsg_instantly()
function opens WhatsApp Web in your default browser, logs in to your WhatsApp account, and sends the specified message to the provided phone number instantly.
Conclusion
Congratulations! You have successfully learned how to use Python and the pywhatkit
library to send instant WhatsApp messages. Automation with Python opens up endless possibilities, and with pywhatkit
, you can make your communication more efficient and fun. Experiment further with the library to explore other exciting features it offers!
Happy learning!!!!