SMD HOST BLOG HEROKU DEPLOYMENT

How to Deploy WhatsApp Bot on Heroku (Complete Step by Step Guide)

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.

What You Need Before Deployment

Step 1: Prepare Your Bot Project

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"
}

Step 2: Upload Bot to GitHub

Create a new repository on GitHub and upload your bot files. Heroku will fetch your code from this repository during deployment.

Step 3: Create New App on Heroku

Login to your Heroku dashboard and create a new app. Choose any app name and select your region.

Step 4: Connect Heroku with GitHub

In the Deploy tab of Heroku, choose GitHub as deployment method. Connect your GitHub account and select your bot repository.

Step 5: Set Environment Variables

If your bot uses environment variables like SESSION_ID or PREFIX, add them in Heroku Settings → Config Vars.

Step 6: Deploy the Bot

Click Deploy Branch. Heroku will install dependencies and start your bot automatically.

Step 7: Pair WhatsApp

Open Heroku logs. You will see a QR code or pairing code. Scan it using WhatsApp Linked Devices.

Common Errors and Fixes

Keeping Bot Alive

Heroku free dynos may sleep after inactivity. You can use uptime monitoring tools to keep it awake.

Conclusion

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.