Monday 13 March 2023

Automation with Python #1 - WhatsApp

# WHATSAPP AUTOMATION

Step 1: Install pywhatkit


pip install pywhatkit


Step 2: Send a message to a contact on WhatsApp

Before we start sending messages, you have to log in to your WhatsApp account through WhatsApp Web. 

To send a message to a WhatsApp contact with Python and pywhatkit, we use the .sendwhatmsg method as shown in the code below (insert your contact number instead).


import pywhatkit
pywhatkit.sendwhatmsg('+919790215636', 'Hello Sweet Heart', 11, 56)

What this code means is “Type ‘Message 1’ and send it to contact X at 18:52”

After running the code above you’ll get a message like this:

In 10 seconds, web.WhatsApp.com will open, and after 15 seconds, a message will be delivered by Whatsapp.

After some seconds your browser will open and the message will be sent to your contact.

Please Note: When your browser opens, a message to grant access will pop up. You have to accept this message.


Bonus:

import pywhatkit
pywhatkit.sendwhatmsg_to_group("Group-id", "Group Message", 19, 2)


# EXCEL AUTOMATION

pip install openpyxl


No comments:

Post a Comment

Making Prompts for Profile Web Site

  Prompt: Can you create prompt to craft better draft in a given topic. Response: Sure! Could you please specify the topic for which you...