After building a WhatsApp bot using the Baileys library, the next important step is keeping it online 24 hours a day. Running the bot on your computer is not reliable because it stops when your system turns off. This is where Heroku becomes very useful for developers.
Heroku is a cloud hosting platform that allows you to run Node.js applications easily without managing a server. In this guide, you will learn how to deploy your WhatsApp bot on Heroku properly and avoid the common mistakes that beginners face.
Make sure your bot runs perfectly on your local computer. Your project folder must contain:
In package.json, make sure you have a start script:
"scripts": {
"start": "node index.js"
}
Create a new repository on GitHub and upload your bot files. Heroku will fetch your code from this repository during deployment.
Login to your Heroku dashboard and create a new app. Choose any app name and select your region.
In the Deploy tab of Heroku, choose GitHub as deployment method. Connect your GitHub account and select your bot repository.
If your bot uses environment variables like SESSION_ID or PREFIX, add them in Heroku Settings → Config Vars.
Click Deploy Branch. Heroku will install dependencies and start your bot automatically.
Open Heroku logs. You will see a QR code or pairing code. Scan it using WhatsApp Linked Devices.
Heroku free dynos may sleep after inactivity. You can use uptime monitoring tools to keep it awake.
Deploying your WhatsApp bot on Heroku ensures that it runs continuously without interruption. With proper setup and configuration, you can manage your bot easily and provide reliable automation services.