Automate WhatsApp messages using Python
Automate WhatsApp messages using Python

Let’s automate WhatsApp Messages using Python: In this short tutorial, I’ll be sharing a very useful python library called “pywhatkit“. We can use pywhatkit for automating our day-to-day tasks like sending a WhatsApp message, opening a YouTube video, converting an image to ASCII art, etc. One more application worth mentioning here is the conversion of text to handwriting. I’ve already covered that topic, you can check that article here.

“The most powerful tool we have as developers is automation”

Scott Hanselman

So why don’t we use it? Automation indeed is a very powerful tool if used for the right purpose. And Python is one such amazing language that has enormous potential to help you automate your tasks. Let’s just begin with our simple yet useful automation tutorial. There’s a video tutorial as well linked with this article, so you can take help from that also.

Some pre-requisites before we continue

  • Make sure to already authenticate WhatsApp Web in your browser for the smooth functioning of the program.
    • If you don’t do this, the script will not be able to run.
  • Also just make sure you have an active internet connection while you are running this code.

Installing pywhatkit

  • Open your IDE or any code editor of your choice.
  • Now in the terminal, write “pip install pywhatkit“. (It will take some time to install pywhatkit)

**For a detailed pictorial representation of how to get started with pywhatkit, click here

Let’s Automate WhatsApp Messages

Once we have all the supporting elements ready to run, now let’s dive right into the actual code. Write this code in your python file with the following 4 parameters included:

  • Phone number of the receiver along with the country code the number belongs to.
  • The message that you want to deliver to your recipient.
  • Time in hours in 24-hour format.
  • Time in minutes at which you want to deliver the message.
import pywhatkit as py
py.sendwhatmsg("+9185********", "Hello, Welcome to the world of Automation", 18, 32)

Executing our Script

Once you’re done till here, as in you’ve all the parameters checked and ready to execute. Simply run the file in the terminal. If you are using VS Code, then click on the small triangle-shaped button on the top-right which says “Run Python File in Terminal” and you’ve done your part.

You will see that your terminal will show a message indicating the time in seconds that is left to deliver the message. Check out this screenshot for reference. So as my terminal shows, WhatsApp web will be opened on my browser automatically after 151 seconds, and a message will be delivered to the said number after 20 seconds.

WhatsApp-Automation: Running our file in Python Terminal

Here I have attached one screenshot showing that the message got successfully delivered to the mentioned number at the desired time to which I assigned it.

Whatsapp Message Delivered using Pywhatkit
WhatsApp Message Delivered using Pywhatkit

Here’s the video tutorial for automating your WhatsApp, you can check this out as well.

Automate WhatsApp using Python Tutorial


We are done with this mini project of ours. I hope you enjoyed it as much as I enjoyed writing it for you. Just think of how easy a task like this will become if you have to send some particular message to someone on a daily basis. We can further program this code according to our use case.

Automating WhatsApp Messages with Python is such an intriguing thing for me. I am sure it must be exciting for you all also. I am still exploring python and learning something new every day. Do share your journey of becoming a Pythonista with me. I would love to read about it.

I will bring a complete tutorial of “pywhatkit” next. Probably gonna explore every feature of it and then share it with you all. So stay tuned for some more automation in python.

Check out my other popular posts here:

Vaishali Rastogi

Hey There! I am Vaishali Rastogi and I am a tech-researcher. I've been doing writing for a good 4-5 years, so here I am now. Working on my own website to make people digitally aware of the updates in technology.


Arpit · June 16, 2021 at 6:45 am

Nice article Vaishali! Very interesting.

Adil · July 30, 2021 at 12:50 pm

Very good content

Robo · July 30, 2021 at 12:57 pm

Keep up the good work.

Leave a Reply

Avatar placeholder

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