This project is a simple WhatsApp automation script using Puppeteer. It leverages Puppeteer's capabilities to send messages on WhatsApp.
- Launches a headless browser with Puppeteer.
- Navigates to WhatsApp Web (https://web.whatsapp.com).
- Waits for the user to scan the QR code and log in.
- Sends a series of messages to a specified chat, demonstrating message automation.
- Ends with a fun message to inform the recipient that it's just a demo project (Optional).
-
Clone the repository and install dependencies:
git clone https://github.com/sunjay-dev/whatsapp-bot-with-puppeteer.git cd whatsapp-bot-with-puppeteer npm install
-
Run the script:
node script.js
-
When WhatsApp Web opens:
- Scan the QR code using your phone.
- Press Enter on terminal.
- Let the script automatically send messages after login.
This script uses the Windows Chrome path by default:
const options = {
headless: false, // Set to true to run in the background
executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', // Replace with path to your Chrome
};
Depending on your operating system, the Chrome path will be different:
-
On Windows:
C:\Program Files\Google\Chrome\Application\chrome.exe
Right-click the Chrome shortcut → Properties → copy the path from the Target field.
-
On macOS:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
-
On Linux: Run this command in the terminal:
which google-chrome
Once you find the correct path, update the executablePath
value in your script accordingly.
This script is for educational and demonstrative purposes only. Use automation responsibly and always respect the terms of service of any platform you interact with.
Feel free to contribute by opening issues or submitting pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.