Send WhatsApp messages programmatically using this Node.js project!
This project allows you to send WhatsApp messages programmatically using the WhatsApp Web API and the whatsapp-web.js
library. It provides a simple Node.js server with API endpoints to send messages to individual contacts or groups on WhatsApp.
- Clone this repository to your local machine:
git clone https://github.com/PauloPenalva/whatsapp.git
- Install the required dependencies:
cd whatsapp
npm install
- Before running the project, you need to set up the environment variables. Create a
.env
file in the project root directory and add the following:
PORT=3333
- To start the server, run the following command:
npm start
- Open your web browser and navigate to
http://localhost:3333
. You should see a QR code displayed. Scan this QR code using the WhatsApp app on your phone to log in and authenticate the WhatsApp Web session.
- URL:
/groups
- Method:
GET
- Description: Retrieve a list of all WhatsApp groups you are a member of.
- URL:
/send-message
- Method:
POST
- Description: Send a WhatsApp message to an individual contact or a group.
{
"to": "recipient_number",
"message": "your_message_here",
"isGroup": true
}
to
: The recipient's phone number in international format (e.g., +551234567890) or the group ID with the@g.us
suffix for groups.message
: The message content you want to send.isGroup
: Set totrue
if the recipient is a group,false
if it's an individual contact.
{
"status": true,
"message": "Message sent successfully"
}
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request. For major changes, please open an issue first to discuss your ideas.
This project is licensed under the MIT License.