This is a basic implementation of a WhatsApp bot using the whatsapp-web.js library. The bot connects to WhatsApp via a QR code, initializes the client, and sends a message to a specified number.
- Generate a QR code for connecting to WhatsApp Web.
- Send a predefined message to a specific phone number.
- Node.js installed on your machine.
- A valid WhatsApp account.
-
Clone the repository:
git clone https://github.com/yourusername/your-repository.git
-
Navigate to the project directory:
cd your-repository
-
Install dependencies:
npm install whatsapp-web.js qrcode-terminal
-
Open the project in your terminal
-
Run the script:
node index.js
-
Scan the QR code displayed in your terminal using the Whatsapp app on yout phone
-
Update the
number
andmensagem
variables in the script to specify the recipient and message content:const number = '55112345678901'; // Replace with the recipient's phone number (including country code). const mensagem = 'Hello world'; // Replace with your message.
-
The bot will send the message to the specified recipient.
- The phone number should include the country code (e.g., 55112345678901).