Giter VIP home page Giter VIP logo

inforkgodara / python-automated-bulk-whatsapp-messages Goto Github PK

View Code? Open in Web Editor NEW
165.0 1.0 63.0 4.67 MB

It is a python script to send automated bulk WhatsApp messages to multiple recipients from an excel sheet at once.

Python 100.00%
bulk-whatsapp-message python whatsapp-web inforkgodara web-whatsapp python-script bulk-messages whatsapp-bot whatsapp-bulk-messages whatsapp-automation

python-automated-bulk-whatsapp-messages's Introduction

Python Automated Bulk WhatsApp Messages

It is a python script that sends WhatsApp message automatically from WhatsApp web application with saved contact numbers. It can be configured to send advertising messages to customers. It read data from an excel sheet and send a configured message to people.

Contact me over Telegram: https://t.me/inforkgodara

Note

This is for saved contact numbers only if you want to send whatsapp bulk messages to unsaved or without saving the contact numbers. You may prefer another repository.

Important

  • WhatsApp Business released API on May 2022, no longer needed this repository. You can accomplish your same requirements through WhatsApp Business APIs.

Prerequisites

In order to run the python script, your system must have the following programs/packages installed and the contact number should be saved in your phone (You can use bulk contact number saving procedure of email). There is a way without saving the contact number but has the limitation to send the attachment.

Approach

  • User scans web QR code to log in into the WhatsApp web application.
  • The script reads a customized message from excel sheet.
  • The script reads rows one by one and searches that contact number in the web search box if the contact number found on WhatsApp then it will send a configured message otherwise It reads next row.
  • Loop execute until and unless all rows complete.

Note: If you wish to send an image instead of text you can write attachment selection python code.

Legal

  • This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by WhatsApp or any of its affiliates or subsidiaries. This is an independent and unofficial software. Use at your own risk. Commercial use of this code/repo is strictly prohibited.

Code

# Program to send bulk customized message through WhatsApp web application
# Author @inforkgodara

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
import pandas
import time

# Load the chrome driver
driver = webdriver.Chrome()
count = 0

# Open WhatsApp URL in chrome browser
driver.get("https://web.whatsapp.com/")
wait = WebDriverWait(driver, 20)

# Read data from excel
excel_data = pandas.read_excel('Customer bulk email data.xlsx', sheet_name='Customers')
message = excel_data['Message'][0]

# Iterate excel rows till to finish
for column in excel_data['Name'].tolist():
    # Locate search box through x_path
    search_box = '//*[@id="side"]/div[1]/div/label/div/div[2]'
    person_title = wait.until(lambda driver:driver.find_element_by_xpath(search_box))

    # Clear search box if any contact number is written in it
    person_title.clear()

    # Send contact number in search box
    person_title.send_keys(str(excel_data['Contact'][count]))
    count = count + 1

    # Wait for 3 seconds to search contact number
    time.sleep(3)

    try:
        # Load error message in case unavailability of contact number
        element = driver.find_element_by_xpath('//*[@id="pane-side"]/div[1]/div/span')
    except NoSuchElementException:
        # Format the message from excel sheet
        message = message.replace('{customer_name}', column)
        person_title.send_keys(Keys.ENTER)
        actions = ActionChains(driver)
        actions.send_keys(message)
        actions.send_keys(Keys.ENTER)
        actions.perform()

# Close Chrome browser
driver.quit()

Note: The script may not work in case if the HTML of web WhatsApp is changed.

Find it on youtube. https://youtu.be/NcWXpsczl3c

python-automated-bulk-whatsapp-messages's People

Contributors

inforkgodara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

python-automated-bulk-whatsapp-messages's Issues

link

Can You provide new video link the one mentioned in Readme is not working

Can we send photos or attachments using this?

Hello Bro, Firstly I want to tell you that your coding skills are very good and this script of yours works very well. Just I had a question that is if possible to send images or attachments somehow automatically using this technique? I would be glad if you make a video just like this one regarding this topic.

Problem with Script

I've installed ... There is the possibility to not disconnect from WhatsApp Web ?

Every type I must scan QRCODE

Can I "memorize" so when I exe script didn't request QRCODE ?

Thanks

having read excell issue

getting this issue while reading excel in windows

line 23, in
excel_data = pandas.read_excel('customers.xlsx', sheet_name='Customers')

please help im getting this error

Traceback (most recent call last):
File "script.py", line 45, in
person_title.send_keys(str(excel_data['Contact'][count]))
NameError: name 'count' is not defined
Screenshot (744)

Request for help

Could you help me to get custom amount too? if yes that would be greatful thanks anyways

Code not sending messages

Sir,
I am beginner in coding.
My script is opening chrome, pasting the message but not sending it....
Please help me resolve the issue.

error with selenium

Traceback (most recent call last):
File "/Users/danil/Desktop/python-automated-bulk-whatsapp-messages-master/script.py", line 30, in
person_title = wait.until(lambda driver:driver.find_element_by_xpath(search_box))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/selenium/webdriver/support/wait.py", line 86, in until
value = method(self._driver)
File "/Users/danil/Desktop/python-automated-bulk-whatsapp-messages-master/script.py", line 30, in
person_title = wait.until(lambda driver:driver.find_element_by_xpath(search_box))
AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'

this error i see after script is opened chrome((

i try to install old ver of selenium but i have another error

help please what i do wrong???

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.