Skip to content

Automate all your WhatsApp messages using Python 3

    Without a question, WhatsApp is the most popular smartphone app on our smartphones. Because of the constraints in place all across the world, it became one of our key modes of communication.

    Do you prefer not to be distracted from your work by the thought of wishing someone a happy birthday or reminding someone of something at a certain time? This automation is for you if that’s the case!

    You can use Python to automate this procedure with just a couple of lines of code. You must be logged into WhatsApp web (even if it is closed) using the Python3 Chrome browser. If you don’t have a Chrome browser, you can do it by following the steps below:
    1. Get the latest stable release of Chrome Driver from and extract it.
    2. Open the downloaded file and look for an application entitled chrome drive. Copy the path, which should be C:/Users/…/chromedriver.exe in Windows.
    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.

    This library takes care of everything behind the scenes, so all we have to do is write a few lines of Python code describing what message to send and when to send it, along with some other parameters.


    Install the library in your Python environment:
    pip3 install pywhatki

    If you face errors:

    python -m pip install – upgrade pip python -m pip install –upgrade Pillow=

    Import the package:

    # import pywhatkit

    Write Code:

    After we have installed the package, let us write our python code for automation.

    We will use the function sendwhatmsg() to send our message to the contact. The function asks for the following parameters:

    sendwhatmsg(phone_no: str, message: str, time_hour: int, time_min: int, wait_time: int = 20, tab_close: bool = False, close_time: int = 3)

    Mandatory Parameters:


    • Enter phone number as a string
    • It is mandatory to add the country code, otherwise you would get error
    • Example: “+911234567891”


    • Message to be sent as a string.
    • Ex: “One hour to go for the deadline”


    • The hour when you want to send a message
    • Please note that the time should be given in 24-hour format.


    # import pywhatkit pywhatkit.sendwhatmsg("+911234567891","Reminder to go to market" ,17, 00)


    # import pywhatkit pywhatkit.sendwhatmsg("+911234567891","Reminder to go to market" ,17, 00, 20, True, 10)


    After the appointed time, this is the time when your messages will be sent. It is set to 20 seconds by default, but you can alter it to suit your needs.


    Specifies that whether the previous tab should be closed or not after sending the message. It will remain open after sending the message by default. You can change it by marking it True.


    You can control the time after which the tab should be closed after delivering the message by specifying the close_time the parameter in seconds.

    Send messages to specific groups of people:
    We can send messages to group chats using the sendwhatmsg to group() method. Everything else, including modifications, is the same as before; the only difference is that instead of phone num, group id is used. Your group’s group id can be found by clicking on the invite link. Your group id is highlighted text.