Skip to content
/ automated-message Public template

💬 Automated Message Sending with WhatsApp Web.

License

Notifications You must be signed in to change notification settings

gsoaresdz/automated-message

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated Message Sending with WhatsApp Web

Github top language Github language count Repository size

About   |   Features   |   Technologies   |   Requirements   |   Execution   |   License   |   Author


🎯 About

This project consists of a Python script that automates sending messages to contacts on WhatsApp Web. The script uses the following libraries:

  • pandas: to import the Excel file containing contacts and messages to be sent.
  • selenium: to control the Chrome browser and interact with WhatsApp Web.
  • urllib: to encode the message before sending.

📝 IDE and Python Version

The script was developed using Visual Studio Code with Python version 3.10.4.

📝 Business Logic

The script works as follows:

  1. Imports an Excel file containing contacts and messages to be sent.
  2. Opens WhatsApp Web in the Chrome browser.
  3. Iterates through the Excel file, sending a message to each contact.
  4. The message is sent in the format: "Hi [name]! [message]".
  5. The script waits 12 seconds between each message to prevent WhatsApp from blocking the account.

📝 Steps Executed in the Code

The code is divided into two main parts:

  • Importing an Excel File
  • Automating Message Sending

📝 Importing an Excel File

The first part of the code imports an Excel file containing the contacts and messages to be sent. The file should have the following columns:

  • Person: contact's name.
  • Number: contact's phone number.
  • Message: message to be sent.

The code uses the pandas library to import the Excel file. The following snippet demonstrates how to import the file:

contatos_df = pd.read_excel(r"arquivos/Enviar.xlsx")

✨ Features

The second part of the code automates the sending of messages to the contacts listed in the Excel file. The code functions as follows:

✔️ Feature 1: Opens WhatsApp Web in the Chrome browser.

✔️ Feature 2: Iterates through the Excel file, sending a message to each contact.

✔️ Feature 3: Sends the message in the format: "Hi [name]! [message]".\

The following snippet demonstrates how a message is sent to a contact:

pessoa = contatos_df.loc[i, "Pessoa"]
numero = contatos_df.loc[i, "Número"]
texto = urllib.parse.quote(f"Hi {pessoa}! {mensagem}")
link = f"https://web.whatsapp.com/send?phone={numero}&text={texto}&/n"
navegador.get(link)
while len(navegador.find_elements(By.ID, "pane-side")) < 1:
    time.sleep(1)
time.sleep(1)
navegador.find_element(By.XPATH, '//*[@id="main"]/footer/div[1]/div/span[2]/div/div[2]/div[2]/button/span').click()

🚀 Technologies

The following tools were used in this project:

✅ Requirements

Before starting 🏁, you need to have Git and Python installed.

🏁 Execution

# Clone the project

$ git clone https://github.com/gsoaresdz/automacao-mensagem.git

📝 Notes

  • This script was developed for educational purposes. It is not recommended to use the script for mass messaging to contacts who have not authorized receiving messages.
  • The script can be modified to meet different needs. For example, you can change the time interval between message sending or add new functionalities.

📝 License

This project is licensed under the MIT License. For more details, check the [LICENSE](LICENSE file.

Made with ❤️ by gsoaresdz

Back to top

About

💬 Automated Message Sending with WhatsApp Web.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published