How To Send Whatsapp Message Using Python

Welcome to our blog, which is named "How To Send WhatsApp Message Using Python". Python is a very interesting programming language, with the help of this language you can create very secure and large software. Python is the most used programming language in the world. Today we will know how we can send messages on WhatsApp with the help of Python, and also see which package we will need. And most of all, we will understand how easy it was to send messages in WhatsApp with the help of Python. And also we will discuss about some questions related to this which are always asked. And most of all we understand what the requirement of this project of ours is.

Requirement of this project

Requirement Details –

Operating System:Windows 7 or Above
RAM:At-least 1 GB or Above
Hard Drive:At-least 10 GB or Above
Package:Python, IDE
IDE:VS Code, PyCharm, Sublime Text,etc.(Optional)
Internet:Internet Connection Required


How To Send Whatsapp Message Using Python

Above we have seen what should be the requirement for this project. Let's assume that your computer / laptop have Python and any one IDE installed. Although no special IDE is required for this project, but coding with a better IDE helps in coding. I would recommend that you use Microsoft's Visual Studio Code for the IDE, it is free and very easy to use. Below is the link of how to download and install Python and VSCode, you can go through it and see.

Which Package is Needed

Python itself is a very large and strong programming language. In the official side of Python, you will get to read its documentation.

The package name used for the project is pywhatkit. To install it, some steps are given below, follow them-
  1. Go to pywhatkit official side
  2. Copy pip install pywhatkit
  3. Open your terminal /Command prompt
  4. Please make sure python's path is set (for verify type python and hit enter If Python's editor opens then your Python path is set, then now type exit and hit enter)
  5. Simply paste above copied code (pip install pywhatkit) and hit enter (Please make sure your internet connection is active)
  6. Hopefully your package is installed, now close the terminal by typing exit and open the Python IDE

Script To Send Whatsapp Message

In the project to send Whatsapp message, first of all open Python IDE means VS-code and type the code given below in it.

import pywhatkit
strNum=input("Please Enter Mobile:-")
strMsg=input("Please Enter your Message:-")
Hourt=int(input("Please Enter Hour time in 24 Hour format "))
minutt=int(input("Please Enter Minute time  "))
pywhatkit.sendwhatmsg(strNum,strMsg,Hourt,minutt)

Your Output will be like this

Please Enter Mobile:-+910123456789
Please Enter your Message:-Have you reached your destination
Plese Enter Hour time in 24 Hour format 14
Plese Enter Minut time  28
In 19 seconds web.whatsapp.com will open and after 20 seconds message will be delivered

Let's understand line by line, how this code of "How To Send Whatsapp Message Using Python" project works

How this code works?

In line no. 1 import pywhatkit, This line means that we are adding the package of pywhatkit to our project, as soon as this package is added, we can access all the modules of pywhatkit.

In line no. 2 strNum=input("Please Enter Mobile:-"), In this line, Python will ask the user the number of the message receiver, which means the number to which the message is to be sent. Make sure the number contains the country code.

In line no. 3 strMsg=input("Please Enter your Message:-"), This line means that Python will ask the user what message to send.

In line no. 4 Hourt=int(input("Please Enter Hour time in 24 Hour format ")), In this line, Python will ask the user the time at which the message is to be sent, but this time will be only in the hour. For example, if it is 2 o'clock in the afternoon then the time will be 14.  

In line no. 5 minutt=int(input("Please Enter Minute time  ")), In this line, Python asks the user the minute that is after the hour. For example, if the time is 2.28, then it will have 2 ie 14 hours and 28 minutes.

In line no. 6 pywhatkit.sendwhatmsg(strNum,strMsg,Hourt,minutt),  This line contains pywhatkit package and sendwhatmsg is its module. And it takes four arguments. First the mobile number where the message is to be sent. Second is the message to be sent. Third, the hour time of that time at which time is to be sent. And last is the minutes which have to be sent after the hour. 

Note:- Before running this program of Python, you should login to your WhatsApp https://web.whatsapp.com/ in your default browser.

Conclusion

Well, above we have seen almost everything about the project from "How To Send Whatsapp Message Using Python". What should be the requirement, which software / package should be there. Efforts have been made to give almost complete information, still if anything else should be added, please comment. And how did you like this post, please tell by commenting, and if this post is informative then please share it.