01 logo

Automate Whatsapp with 2 lines of code using Python

Developers make life easy

By HVPublished 3 years ago 2 min read
3

Installing Python

First of all, we need to install Python. Open the official page of Python and download the latest version of python.

You have to download different files of Python based on your Operating System(Windows or Mac).After Downloading the file open it and start installing python.

Python basically provides a default IDE which we can use to write, edit, and modify our Python Code. So there is no need to Install another IDE. Open the Python IDE and start writing your code.

How to Automate Whatsapp Using Python

Python is the most popular programming language among developers because of its features like open source, accessibility, ease of use, among others. Python also has a huge number of libraries and modules which are contributed by the community .

Python is widely used in scientific and numeric computing and is used as a support language for software engineers. It is used in management, testing, and in other ways.

Python can Automate Whatsapp by running a script. To run this module we need to install pywhatkit module. pywhatkit is the module that automates the Whatsapp to send message to any number on Whatsapp. pywhatkit uses web.whatsapp.com webpage to automate the messages.

We just need to write a two-line code to send messages from one number to another automatically. Now, start installing the pywhatkit module and write the code.

Installing the pywhatkit module

To install the pywhatkit module, we can use pip command .

pip install pywhatkit

The above command will download the pywhatkit module. This will take some time because it will download all the files in the module .

Python Automation Script

import pywhatkit

pywhatkit.sendwhatmsg("+91*********","Happy Birthday to my Baby", 19,30)

Understanding the Python script

First, we need to import the module. Then use pywhatkit.sendwhatmsg() method to automate and send the WhatsApp messages from one person to another person at a particular time.

The sendwhatmsg() method should consist of four inputs.

First input is the phone number of the person to whom you want to send a message

Second input is the Message that you want to send.

Third input is a number at which hour(24 Hour format) you want to send the message.

Fourth input is also a number at which minute you want to send the message.

To use this Python Script you hould have chrome installed and your whatsapp should be logged into web.whatsapp.com website.

Conclusion

Hence, You can use this Python Script to Automate Whatsapp to send Anniversary wishes, Birthday wishes, send daily morning messages or use in some business to improve efficiency.

Try running the above if you find any errors please do comment down.

how to
3

About the Creator

HV

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.