Skip to content

Commit 5fd67ae

Browse files
update readme
1 parent 797a82e commit 5fd67ae

File tree

2 files changed

+105
-29
lines changed

2 files changed

+105
-29
lines changed

README.md

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,32 @@
11
# WhatsApp Automation Bot
22

3-
## Introduction
4-
This repository contains two projects focused on automating the process of sending messages and file attachments through WhatsApp. Both projects use WhatsApp Web for the message delivery mechanism but leverage different tools and approaches for automation. These solutions can be used to send timely alerts based on various triggers, ensuring fast and efficient communication directly through WhatsApp.
5-
6-
---
7-
8-
## Project 1: WhatsApp-Selenium-Bot
3+
## Overview
4+
This repository is focused on automating the process of sending messages and file attachments through WhatsApp. This project use WhatsApp Web for the message delivery mechanism but leverage different tools and approaches for automation. These solutions can be used to send timely alerts based on various triggers, ensuring fast and efficient communication directly through WhatsApp.
95

10-
### Overview
11-
The **WhatsApp-Selenium-Bot** project automates sending alerts through WhatsApp using the Selenium framework. This project is designed to handle real-time data extraction, processing, and report generation. Based on certain conditions, such as temperature or humidity thresholds, it triggers alerts that are sent via WhatsApp, ensuring prompt notifications. The alerts can include both text messages and file attachments, such as detailed reports in Excel format.
6+
**Structure**:
7+
- [Introduction](#introduction)
8+
- [Message Sender](#message-sender)
9+
- [Key Features](#key-features)
10+
- [File Structure](#file-structure)
1211

13-
### Folder Structure
14-
- **Messages Folder**: Contains scripts responsible for sending alerts as text messages without attachments.
15-
- **Messages and Files Folder**: Includes the core functionality to handle both text messages and file attachments.
1612

17-
Scripts here:
18-
- Connect to databases, extract and clean data.
19-
- Generate and format Excel reports.
20-
- Send notifications and files through WhatsApp Web.
21-
22-
### Key Features
23-
- **Automated Alerts**: Automatically detects specific conditions and sends corresponding WhatsApp alerts.
24-
- **File Attachments**: The bot generates reports, such as Excel files, and sends them alongside alert messages.
25-
- **Data Processing**: Integrates data extraction, cleaning, and processing before generating and sending alerts.
13+
---
2614

27-
### Limitations
28-
- **WhatsApp Web Session**: An active WhatsApp Web session is required for the automation to function. If the session is interrupted, alerts will not be sent.
29-
- **Server Dependence**: Continuous server uptime is essential. Any server failure can result in missed alerts.
15+
## Introduction
16+
The **WhatsApp-js-Bot** project uses the `whatsapp-web.js` API to automate sending messages and files through WhatsApp. The bot initiates a session by scanning a QR code and remains active to send periodic messages and file attachments to designated WhatsApp numbers or groups. This project is highly customizable, allowing users to modify the target recipients, messages, and files to fit various use cases.
3017

3118
---
3219

33-
## Project 2: WhatsApp-js-Bot
34-
35-
### Overview
36-
The **WhatsApp-js-Bot** project uses the `whatsapp-web.js` API to automate sending messages and files through WhatsApp. The bot initiates a session by scanning a QR code and remains active to send periodic messages and file attachments to designated WhatsApp numbers or groups. This project is highly customizable, allowing users to modify the target recipients, messages, and files to fit various use cases.
20+
## Message Sender
3721

3822
### Key Features
3923
- **QR Code Login**: The bot uses WhatsApp Web by scanning a QR code to authenticate and log in.
4024
- **Send Messages and Files**: It can send both text messages and files to a target WhatsApp number or group.
4125
- **Session Keep Alive**: Includes functionality to keep the WhatsApp session active, avoiding the need for constant re-authentication.
42-
26+
27+
4328
### File Structure
4429
- **whatsapp-client.js**: Initializes the WhatsApp client, handles QR code generation, and manages sending text messages and files.
4530
- **sendMessage.js**: Defines the function that sends a text message to a specified WhatsApp number.
4631
- **sendFile.js**: Exports the function to send file attachments to a specified number or group.
47-
- **keepAlive.js**: Ensures the session stays active by periodically sending logs to prevent disconnection.
32+
- **keepAlive.js**: Ensures the session stays active by periodically sending logs to prevent disconnection.

message-sender/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# WhatsApp-js-Bot
2+
3+
This project is an automation bot for sending messages and files over WhatsApp using the `whatsapp-web.js` API. The bot scans a QR code to log in, keeps the session active, and sends messages and files periodically to a specific WhatsApp number or group.
4+
5+
---
6+
## Features
7+
8+
### `whatsapp-client.js`
9+
This is the main file that initializes the WhatsApp client. It includes the following functions:
10+
- **`qrcode`**: Generates a QR code that you need to scan with the WhatsApp app to log in.
11+
- **`sendMessage`**: Sends a text message to the target number or group.
12+
- **`sendFile`**: Sends a file to the target number or group.
13+
- **`keepAlive`**: Keeps the WhatsApp session active by sending periodic logs to avoid disconnections.
14+
15+
### `sendMessage.js`
16+
This file exports a function that sends a text message to a WhatsApp number:
17+
18+
**Parameters**:
19+
- `client`: Instance of the WhatsApp client.
20+
- `number`: WhatsApp number (in `[email protected]` format).
21+
- `message`: The text of the message to send.
22+
23+
### `sendFile.js`
24+
This file exports a function that sends a file to a WhatsApp number:
25+
26+
**Parameters**:
27+
- `client`: WhatsApp client instance.
28+
- `number`: WhatsApp number (in `[email protected]` format).
29+
- `filePath`: Local path of the file to be sent.
30+
- `fileName`: Name of the file to display on WhatsApp.
31+
32+
### `keepAlive.js`
33+
This file exports a function that keeps the WhatsApp session active:
34+
35+
**Function**:
36+
- Runs a periodic function (every 5 minutes) that keeps the session alive by printing a message to the console.
37+
---
38+
39+
## Installation
40+
41+
To run this project, make sure you have Node.js installed and follow these steps:
42+
43+
### 1. Clone the repository
44+
45+
```bash
46+
git clone https://github.com/haroldeustaquio/alert-system-whatsapp.git
47+
```
48+
49+
### 2. Go to the whatsapp-js-bot folder
50+
```bash
51+
cd whatsapp-js-bot
52+
```
53+
54+
### 3. Install dependencies:
55+
```bash
56+
npm install whatsapp-web.js qrcode-terminal fs
57+
```
58+
59+
### 4. Run the bot
60+
```bash
61+
node whatsapp-client.js
62+
```
63+
64+
### 5. Scan QR code
65+
66+
Once you run the bot, a QR code will be generated in the terminal. Scan it with the WhatsApp app to log in.
67+
68+
---
69+
70+
## Usage
71+
72+
Modify the ``whatsapp-client.js`` file with the destination number and the file you want to send:
73+
74+
- Number: You must use the format ``[email protected]`` for numbers in Peru.
75+
- Message: You can customize the text message to send.
76+
- File: Change the file path and its name if you want to send a different file.
77+
- Interval: Change the number of ms to send messages automatically
78+
79+
---
80+
81+
## Dependencies
82+
- whatsapp-web.js
83+
- qrcode-terminal
84+
- fs
85+
86+
---
87+
88+
## Additional Notes
89+
90+
- If the file does not exist or the path is incorrect, the bot will throw an error indicating that the file was not found.
91+
- To send messages to a group, replace the number with the group ID in WhatsApp.

0 commit comments

Comments
 (0)