This is the implementation example of whatsapp-web.js
Important
It is not guaranteed you will not be blocked by using this method. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.
Please always use the latest version of whatsapp-web.js.
Note
Node v18+
is required.
- Clone or download this repo
- Enter to the project directory
- Run
npm install
- Run Whatsapp-API
node run start
for general usenode run start:dev
run with nodemonnode run start:auto
auto run when app crash (the error log will be in the error.log file)
- Open browser and go to address
http://localhost:8000
- Scan the QR Code
- Enjoy!
http://localhost:8000/send-message
Paramaters:
number
: the recipient numbermessage
: the message
http://localhost:8000/send-media-local
Paramaters:
number
: the recipient numbercaption
(optional): file's caption
Note: Currently send-media-local sends files from a hard-coded path in app.js. You can change it if needed.
http://localhost:8000/send-media-upload
Paramaters:
number
: the recipient numberfile
: file's pathcaption
(optional): file's caption
http://localhost:8000/send-media-link
Paramaters:
number
: the recipient numberfile
: file's urlcaption
(optional): file's captiontitle
(optional): file's title/name
http://localhost:8000/send-group-message
Paramaters:
id
(optional if name given): the chat IDname
(optional): group namemessage
: the message
Note: to get the groups info (including ID & name), send a message to the API number !groups
. The API will replying with the groups info.