How to Send WhatsApp Message using Python | Just 2 lines

You can automate the WhatsApp message with just 2 lines of python code and also you can schedule to send a message at midnight while you will be sleeping with just two lines of python. Let’s move on to an awesome project. Before getting into this we will have python and pywhatkit packages. In this case, I will use pycharm IDE

How to install pycharm in windows: https://iterathon.tech//how-to-install-the-pycharm-in-windows/

After opening a pycharm click on a new project and you can give it any name like an Auto Whatsapp message or sweet message to someone. In this project, I give an Auto Whatsapp message as a name.

Once you give it a name and click on the create. It takes few seconds to create the project, On the current project there are some existing files are found in ide so, delete all those files using Ctrl+A and Backspace. Now Python is ready to code before that we need one awesome python packages called pywhatkit.

Link to Pywhatkit package: https://pypi.org/project/pywhatkit/

After getting into the link. You need to copy the magical word to install pywhatkit. That is pip install pywhatkit.

Again go to the pycharm and click terminal then paste the magical word pip install pywhatkit. It takes few seconds to install packages. Once the package gets installed and go to your project Auto Whatsapp message.

To send a Whatsapp message at a specific time or At midnight when you have slept use these 2 lines of python code to send an automatic WhatsApp message to your girlfriend or Boyfriend. This is Easy and crazy. Let’s move on

import pywhatkit
pywhatkit.sendwhatmsg(phone_num,message,time_hour,time_min,wait_time,print_wait_time,tab_close)

The parameters are

phone_num (required) – Phone number of the target with country code
message (required) – Message that you want to send
time_hour (required) – Hours at which you want to send messages in 24-hour format
time_min (required) – Minutes at which you want to send a message
wait_time (optional, val = 20) – Seconds after which the message will be sent after opening the web
print_wait_time (optional, val = True) – Will print the remaining time if set to true
tab_close (optional, val = False) – True if you want to close the tab after sending the message

You can also send instant WhatsApp messages using this package or modules. It also only 2 lines of code to send instantly.

import pywhatkit
pywhatkit.sendwhatmsg_instantly(phone_num,message)

The parameters are

phone_num (required) – Phone number of the target with country code
message (required) – Message that you want to send instantly

Previous Post

Important interview questions in python: https://iterathon.tech//important-interview-questions-in-python/

LEARN LITTLE BY LITTLE TO CHANGE THE TECH WORD

Similar Posts

Leave a Reply

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