Skip to content

About

WhatsApp Web automation service: a REST endpoint that validates a number, enriches the message from an external API, sends it over WhatsApp Web, then fires a follow-up cURL call. Node.js, Express and Puppeteer.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

WhatsApp Bot with API and cURL Execution

Overview

This project is a WhatsApp automation bot that allows you to send messages via WhatsApp Web using whatsapp-web.js and Puppeteer. It also supports:

  • Fetching data from an external API before sending messages.
  • Executing a cURL command after sending a message.

Features

✅ Send messages to WhatsApp numbers. ✅ Validate if a number is registered on WhatsApp. ✅ Fetch additional data from an external API and append it to the message. ✅ Execute a cURL command after sending a message. ✅ Logs errors and execution status.


Installation

1️⃣ Clone the Repository

git clone https://github.com/mhamidjamil/whatsapp-automation
cd whatsapp-automation

For headless server:

sudo apt-get update
sudo apt-get install -y \
  ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
  libatk1.0-0 libcups2 libdbus-1-3 libdrm2 libgbm1 libgtk-3-0 libnspr4 libnss3 \
  libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 xdg-utils wget

2️⃣ Install Dependencies

npm install

3️⃣ Run the Server

npm start

This will start the server on http://localhost:3008.

4️⃣ Scan the QR Code

  • When you run the server for the first time, a QR code will appear in the console.
  • Scan it using WhatsApp Web on your phone.
  • Once scanned, the bot will be ready to send messages.

API Usage

📌 Endpoint: /send

Method: POST

📥 Request Body:

{
  "number": "+923354888420",
  "message": "Hello from WhatsApp Bot!",
  "externalApiUrl": "https://jsonplaceholder.typicode.com/todos/1",
  "curlCommand": "curl -X GET http://example.com/api"
}

📤 Response:

{
  "status": "Message sent successfully!"
}

🔹 How It Works:

  1. Formats the phone number to WhatsApp format.
  2. Checks if the number is registered on WhatsApp.
  3. Fetches additional data from the given externalApiUrl and appends it to the message.
  4. Sends the message via WhatsApp Web.
  5. Executes the provided cURL command if available.

Troubleshooting

❌ Common Errors & Fixes

Error Solution
wid error: invalid wid Ensure the phone number is registered on WhatsApp.
Error sending message Restart the server and rescan the QR code.
Error executing cURL Check if the cURL command syntax is correct.

License

This project is licensed under the MIT License.


Author

Developed by Your Name. 🚀 Feel free to contribute and enhance the bot!


Contributing

  • Fork the repository.
  • Create a feature branch.
  • Open a pull request!

Enjoy automating WhatsApp messages! 📩🔥

About

WhatsApp Web automation service: a REST endpoint that validates a number, enriches the message from an external API, sends it over WhatsApp Web, then fires a follow-up cURL call. Node.js, Express and Puppeteer.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages