This repository is focused on automating and monitoring the process of sending messages and file attachments through WhatsApp. It leverages the whatsapp-web.js
API for message delivery while introducing modular tools for both sending and tracking messages. These solutions are ideal for automating communication tasks, ensuring accurate and timely delivery.
Content:
The Message Sender
script automates the sending of messages and files through WhatsApp. It is designed for scenarios requiring periodic updates or alerts to specific numbers or groups.
- QR Code Login: Authenticate using WhatsApp Web by scanning a QR code.
- Automated Text and File Sending: Sends predefined messages and file attachments to the target number or group.
- Session Keep Alive: Uses a keep-alive mechanism to prevent session timeouts during prolonged use.
whatsapp-client.js
: Manages WhatsApp client initialization, QR code authentication, and triggers periodic sending of messages and files.sendMessage.js
: Contains the function for sending text messages to a WhatsApp number.sendFile.js
: Handles file attachments to be sent to a specific number or group.keepAlive.js
: Keeps the session active by periodically logging the connection status.
The Message Monitor
script tracks messages sent by the Message Sender
to ensure they are delivered on time. It validates timing against predefined intervals and tolerances.
- Real-Time Monitoring: Tracks outgoing messages to the target number in real time.
- Message Validation:
- Logs whether messages are sent on time, late, or not at all.
- Differentiates between missed and delayed messages for detailed tracking.
- Session Management: Ensures continuous operation by keeping the session active.
whatsapp-monitor.js
: Initializes the WhatsApp client and implements message tracking based on intervals and tolerances.sendMessage.js
: Sends alert messages for missed or late messages.keepAlive.js
: Maintains session stability during monitoring.
Ensure you have Node.js
installed on your system.
git clone https://github.com/haroldeustaquio/WhatsApp-js-Bot.git
-
For
Message Sender
:cd message-sender
-
For
Message Monitor
:cd message-monitor
npm install whatsapp-web.js qrcode-terminal fs
-
For
Message Sender
:node whatsapp-client.js
-
For
Message Monitor
:node whatsapp-monitor.js
Once the bot starts, scan the QR code displayed in the terminal with the WhatsApp app to log in.