Just a basic usage whatsapp bot to send simple message using express.js
- "dotenv": "^16.0.3"
- "express": "^4.18.2"
- "express-basic-auth": "^1.2.1"
- "http": "^0.0.1-security"
- "nodemon": "^2.0.20"
- "qrcode": "^1.5.1"
- "qrcode-terminal": "^0.12.0"
- "socket.io": "^4.6.0"
- "whatsapp-web.js": "^1.19.3"
-
rename file
.env.example
to.env
-
run
npm install
-
run
nodemon index.js
-
the service is running now open
http://localhost:8000
-
enter the username and password for the basic auth. You can change it in
.env
file. -
you will be redirected to main page, whatsapp will generate a qr code. Scan it using whatsapp mobile apps.
-
wait for moment until your whatsapp connected automatically, if fail just restart the service and try again.
-
Now, let's test it using postman. Click send button.
-
The success response will be like below. And do not forget to add basic authorization headers.
-
As you can see here, the message sent successfully to receiver.
There are more features from this library. You can get it here.. https://github.com/pedroslopez/whatsapp-web.js/