Hello friends how are you, Today in this post "Send whatsapp message using python" i am going to teach you how you can Automate your whatsapp with just two line of codes in Python. If you are a computer science students then this post can help you definitely.
Suppose you want to send a message like "Happy Birthday" to your friend on his/her birthday in the midnight then you can shedule this message using two line of code of python. At the specified time it will automatically send your WhatsApp message to your friend.
Now i am going to explain it step by step so just go through this post to understand this completely.
You can also watch this video to learn it i have explained everything live in this video.
Step 1: Login to Whatsapp Web: Open any browser into your system and type "Whatsapp web" in URL then press enter and click on first link, after that you will get a screen like the below screenshot.
Here you have to scan this QR code with your whatsapp. If you don't know how to scan then open your whatsapp click on three dots which will be on right top of whatsapp screen and then select whatsapp web. Still you are facing difficulty then watch the above video.
Step 2: Install Python and Pycharm : Open any browser and type Download Python and click the first link you will get official website of python here you will get a Download button and after clicking on this button you will get exe of latest python version just install it into your system.
To install Pycharm IDE Open any browser and type Download Pycharm and click the first link you will get official website of Pycharm here you will get a black download button and after clicking on this button you will get exe of Pycharm just install it into your system.
Step 3: Create Project : Open Pycharm and you will get a screen like below if you opening it first time.
Here click on create new project you will get a screen like below
Here first you need to select directory of your project and then type a name for your project after directory name and at last click the create button to create this project. After doing this your project will look like below screenshot.
Step 4:Create Python file: Now its time to create a python file for coding. Right click on project name select new and then select Python file
After clicking on Python file you will get a popup screen like below
Here in the above screen you just need to type a name for python file in my case it is program but it is not compulsory , you can type any name for python file. After doing this you will get a screen like below
Step 5: Install library (pywhatkit) : Before doing code for this we have to first, install the library which is used to send the whatsapp message using python. To install the library click on the terminal button that will be in the left bottom of screen.
After click, a consol screen will open in which you have to type pip install pywhatkit and press enter after typing. For better understanding see the below screenshot.
Now wait for some second you will get a message like installed successfully. If you will get an error then watch the above video i have explained the solution.
Step 6: Write Python code: Now you need to type only two lines in the python file below is the code .
Here the first parameter is the whatsapp number of receiver , second parameter is message, third parameter is an hour and last is minute.
Note: in whatsapp number first type country code then one space then type number.
Step 7: Run Code: Now its time to execute this code just right click on the coding section and click on Run Program
Now you will get a message in output console like "when it will load your whatsappweb and after how many second it will send the message that you have sent." if you can't believe then watch the above video in which yon see the it live.
I hope now you can "Send whatsapp message using python". If you have any doubt regarding this post or you want something more in this post then let me know by comment below i will work on it definitely.
Request:-If you found this post helpful then let me know by your comment and share it with your friend.
If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all.
If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other.
If you like my post then share it with your friends. Thanks😊Happy Coding.
I recently made a python library that abstracts selenium and provides an easy and intuitive interface plus advanced control over the WhatsApp Web, you really wanna have a look at it, I'm pretty sure you will love it
Here is a link https://github.com/Kalebu/alright
Here how to send a message to the user
```python >>> from alright import WhatsApp >>> messenger = WhatsApp() >>> messenger.find_user('2557xxxxxz') >>> messages = ['Morning my love', 'I wish you a good night!'] >>> for message in messages: messenger.send_message(message) ``` Thank you Kalebu
1 Comments
Hi there
ReplyDeleteI recently made a python library that abstracts selenium and provides an easy and intuitive interface plus advanced control over the WhatsApp Web, you really wanna have a look at it, I'm pretty sure you will love it
Here is a link https://github.com/Kalebu/alright
Here how to send a message to the user
```python
>>> from alright import WhatsApp
>>> messenger = WhatsApp()
>>> messenger.find_user('2557xxxxxz')
>>> messages = ['Morning my love', 'I wish you a good night!']
>>> for message in messages:
messenger.send_message(message)
```
Thank you
Kalebu