Giter Site home page Giter Site logo

inforkgodara / whatsapp-bulk-messages-with-document-file Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 16 KB

It is a python script that sends WhatsApp messages automatically from the WhatsApp web application with documents like pdf, images, video, etc.

Home Page: https://www.youtube.com/@inforkgodara

Python 100.00%
automation digital-marketing python python-automation whatsapp whatsapp-automation whatsapp-bot whatsapp-bulk-messages whatsapp-bulk-sender whatsapp-chat

whatsapp-bulk-messages-with-document-file's Introduction

whatsapp-bulk-messages-with-document-file

It is a python script that sends WhatsApp messages automatically from the WhatsApp web application with documents like pdf, images, video, etc.

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

Important Note

  • This repo is only for the educational purpose not meant for commercial uses.

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 as well as documents file also needed to be kept with the same name that is in excel sheet.

  • Python 3.11.5: Download it from https://www.python.org/downloads
  • Chrome v79: Download it from https://chrome.google.com
  • Pandas : Run in command prompt pip install pandas
  • Xlrd : Run in command prompt pip install xlrd
  • Selenium: Run in command prompt pip install selenium
  • Web Driver: Run in command prompt pip install webdriver_manager
  • Openpyxl: Run in command prompt pip install openpyxl

Approach

  • First need to clone this respiratory.
  • Generate documents and paste into invoices directory.
  • Run python script script.py using py script.py in the terminal.
  • The script opens WhatsApp web using chrome.
  • User needs to scan QR code from his/her phone.
  • Enter in path where invoices saved. This can be fixed in code as a one time task.
  • The search the phone number in search bar and send message with document file from excel sheet.
  • Once all the message will be sent chrome driver will wait to enter again in order to close browser.

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 messages through WhatsApp web from an excel sheet with documents file like pdf, images, video, etc.
# Author @inforkgodara

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import pyautogui
import pandas
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get('https://web.whatsapp.com')
# path = '\\\\storage-server\\invoices\\'
path = input("Enter PATH: ")
time.sleep(3)
excel_data = pandas.read_excel('invoice details.xlsx', sheet_name='invoices')
count = 0

for column in excel_data['Shop'].tolist():
    whatsapp_message = 'Hi Dear Customer, This is YOUR_COMPANY_NAME *{} {}* is the amount of invoice number *{}* that you purchased today in our store. Thank you!'.format(excel_data['Amount'][count],excel_data['Currency'][count],excel_data['InvoiceNumber'][count])
    try:
        # contact number selection
        search_box = WebDriverWait(driver, 4).until(EC.element_to_be_clickable((By.CLASS_NAME, '_2vDPL')))
        search_box.click()

        pyautogui.write(str(excel_data['Phone'][count]), interval=0)

        pyautogui.hotkey('enter')

        # attach selection
        attach_button = WebDriverWait(driver, 4).until(EC.element_to_be_clickable((By.CLASS_NAME, '_1OT67')))
        attach_button.click()

        # documents selection
        attach_document = WebDriverWait(driver, 35).until(EC.element_to_be_clickable((By.CLASS_NAME, '_2UNQo')))
        attach_document.click()

        # select file
        time.sleep(1)
        pyautogui.write(path+ '\\' + str(excel_data['InvoiceNumber'][count])+'.pdf')
        pyautogui.press('enter')

        # close attachment selection
        WebDriverWait(driver, 35).until(EC.element_to_be_clickable((By.CLASS_NAME, 'aft2yglh')))

        # write message
        pyautogui.write(whatsapp_message)

        # send button selection
        send_button = WebDriverWait(driver, 35).until(EC.element_to_be_clickable((By.CLASS_NAME, '_3wFFT')))
        send_button.click()
        time.sleep(1)
        try:
            pyautogui.press('esc')
        except Exception as e:
            print(e)
        break
    except Exception as e:
        time.sleep(1)
        try:
            pyautogui.press('esc')
        except Exception as e:
            print(e)

    count = count + 1
    time.sleep(1)
    # break

input("End")

Note: The script may not work in case if the HTML of web WhatsApp is changed. So in order to make it work you need to update the class whenever whatsapp changes the its HTML.

whatsapp-bulk-messages-with-document-file's People

Contributors

inforkgodara avatar

Watchers

 avatar

Forkers

yosbel-penate

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.