This repository is example from whatsapp-api from adiwajshing/Baileys This example get chat from restAPI (express) and publish message to spesific Number whatsapp
Nodejs v16
Install dependency first
npm installRun app
npm startQrcode will display in terminal after "npm start", in your whatsapp app on android/ios will set to sender.
http://localhost:port/sendMessage?chatID={regionCode}{phoneNumber}&message={message}
Example
http://localhost:port/sendMessage?chatID=621234567890&message=Hello World
http://localhost:port/sendMessageGroup?groupID={regionCode}{phoneNumber}&message={message}
Example
http://localhost:port/sendMessageGroup?groupID=621234567890&message=Hello World
- First Create New File Handler inside Folder Handle with .js Extension
- Open New File Handler and add
module.exports = async (shelterSock) => {
try{
// Your Code in Here
}catch(e){
console.log(e);
}
};
- Next Open index.js and Add the following text below (Custom Handle)
await require('./Handle/{customHandleName}')(shelterSock)
- Save and Restart
- First Open or Create New File Handler inside Folder Handle with .js Extension
module.exports = async (shelterSock, dataOrFunction) => {
try{
dataOrFunction.someFunction({});
// or
const newData = dataOrFunction;
}catch(e){
console.log(e);
}
};
- Next Open index.js and Add the following text below (Custom Handle)
await require('./Handle/{customHandleName}')(shelterSock, dataOrFunction)
- Save and Restart
[BUG] automatic restart app every 1 hour
pm2 start npm --name "whatsapi" -- start --cron-restart="0 * * * *"