top of page

I created an automated WhatsApp reply bot!

Create a program to reply to WhatsApp messages

Opening WhatsApp messages and replying to “Good Morning” texts every day or “Thank You” messages on a special occasion to so many people can be a really monotonous and time taking task. There must have been times when you have wondered if there was a way to automatically reply to messages of certain people.

By the end of this blog, your program will be able to reply to Whatsapp messages as and when they are received as shown in the video below:

I will be creating a python bot that will go through unread messages in WhatsApp and respond to them as per the response condition set. So no more monotonous texting. You can also have an AI (Artificial Intelligence) bot chatting with your friends you don’t want to be bothered by.

Remember in Silicon Valley, Gilfoyle created an automated reply bot for chatting with Dinesh! 😂

Creating the WhatsApp response bot

I will be using python for this. The steps are as follows :

  1. Read the context of WhatsApp GUI

  2. Programmatically click on unread messages and extract the message

  3. Process the message and programmatically reply to it

  4. Programmatically opening unread chats

Before starting, we would need to install open-cv, pyautogui, and pyperclip. Open your terminal and type the following commands to install the packages:

$ pip install opencv-python
$ pip install pyautogui
$ pip install pyperclip

If you are using Ubuntu (Linux), you would have to additionally install the following packages :

$ sudo apt-get install scrot
$ sudo apt install xclip

1. Read the context of WhatsApp GUI

Extract Screen Information

Create a folder named whatsapp and inside it create a file . This program will collect information about the color and position of certain elements on the screen. Add the following code :

import pyautogui as pt
from time import sleep
while True:
    posXY = pt.position()
    print(posXY, pt.pixel(posXY[0], posXY[1]))
    if posXY[0] == 0:

The above code will print the coordinates of the mouse pointer and the color it is hovering over. The program will terminate when the mouse pointer touches the x-axis. The output should look for this:

Educate the program about WhatsApp UI

Next, we have to take some snapshots to tell the program where it should drag the mouse to and where to click. Take a screenshot of the images marked with a red rectangle.