Automate your Whatsapp Business with Streamlit without Twilio [Web App]

Image Source:

In the quest to automate every tedious task that a business does every day, I came up with a use case that would any business to automate sending a text to their new customers, here the tedious task being saving the customer contacted and pasting the same message all over again, it is not that of a tedious task if the number of people to text to is less, yet if its a large number it is indeed quite tedious.

There are quite a lot of libraries that help in the automation of WhatsApp messages. For instance, with the help of the selenium chrome web driver, we can send texts to people, yet it does require a bit of coding knowledge to actually run it, but here with the power of streamlit for the user input, and pywhatkit for sending texts, which upon deployment, can actually be given to any person for automating the text.

here, we take input from the user for the phone number and text message, that is to be sent. Users can input any number of phone numbers each separated by comma (,) that they want to send the same message, and just click enter and the app would automatically open WhatsApp web and send the phone numbers the message (User will have login their phone via QR code on beforehand).

Import relevant libraries ie streamlit for user input on the front end, datetime to get the current time, and pywhatkit for automation.

Placeholders at the front end to gather the user input

Upon clicking the submit button, our phone numbers list would loop through each number and send the message. here I am using +968 as country code, we could replace it with any country code you wish. The function pywhatkit.sendwhatmsg takes input phone number, message, time of an hour, and time of minute in 24-hour format to send the message. Since we are in the loop I am adding one minute of extra time (ie i=i+1) to avoid the WhatsApp ban. Upon delivery of all messages, you will receive a message from streamlit success component stating “message sent”.

Connect with me on LinkedIn for more automation fun.

“Automation applied to an inefficient operation will magnify the inefficiency.” — Bill Gates.

Data Analyst Seeking Cure for lack of melatonin owing to the love of DATA