DEV Community

Cover image for Automating WhatsApp with Venom Bot: A Complete Guide
Syed Mudasser Anayat
Syed Mudasser Anayat

Posted on

Automating WhatsApp with Venom Bot: A Complete Guide

If you're a developer looking to automate WhatsApp messages, manage customer communication, or build a chatbot using JavaScript, Venom Bot is your new best friend. In this blog, we’ll explore what Venom Bot is, how it works, how to set it up, and demonstrate real-world use cases—like sending messages, receiving chats, and even creating a simple command-response bot.


What is Venom Bot?

Venom Bot is a powerful and easy-to-use Node.js library that uses the WhatsApp Web protocol to automate and interact with WhatsApp. It's based on puppeteer, which launches a headless browser to emulate a user interacting with WhatsApp Web.

It allows you to:

  • Send and receive messages
  • Read QR codes for authentication
  • Automate responses (chatbot)
  • Create group messages
  • Send media (images, videos, documents)

Use Cases

  • Customer Support Bots
  • Order Notifications
  • Appointment Reminders
  • WhatsApp-based CRM tools

Installation & Setup

1. Create a Node.js Project

mkdir venom-whatsapp-bot
cd venom-whatsapp-bot
npm init -y
npm install venom-bot
Enter fullscreen mode Exit fullscreen mode

2. Basic Bot Setup (index.js)

const venom = require('venom-bot');

venom
  .create()
  .then((client) => startBot(client))
  .catch((error) => console.log(error));

function startBot(client) {
  client.onMessage(async (message) => {
    if (message.body === 'hi' && message.isGroupMsg === false) {
      await client.sendText(message.from, 'Hello! How can I assist you today?');
    }
  });
}
Enter fullscreen mode Exit fullscreen mode

3. Run the Bot

node index.js
Enter fullscreen mode Exit fullscreen mode

You’ll see a QR code in the terminal. Scan it with your WhatsApp to authenticate.


Features Walkthrough

1. Sending Text Messages

await client.sendText('123456789@c.us', 'Hello, this is a test message!');
Enter fullscreen mode Exit fullscreen mode

2. Sending Media (Images, PDF, etc.)

await client.sendImage(
  '123456789@c.us',
  './path/to/image.jpg',
  'image_name',
  'Caption text here'
);
Enter fullscreen mode Exit fullscreen mode

3. Group Messaging

await client.sendText('123456789-123456789@g.us', 'Hello Group!');
Enter fullscreen mode Exit fullscreen mode

4. Buttons and Interactive Messages

await client.sendButtons(
  message.from,
  'Choose an option:',
  [
    { buttonText: { displayText: 'Option 1' } },
    { buttonText: { displayText: 'Option 2' } }
  ],
  'Custom footer text'
);
Enter fullscreen mode Exit fullscreen mode

Building a Simple Command Bot

function startBot(client) {
  client.onMessage(async (message) => {
    switch (message.body.toLowerCase()) {
      case 'hello':
        await client.sendText(message.from, '👋 Hello there!');
        break;
      case 'help':
        await client.sendText(
          message.from,
          'Commands:\n1. hello\n2. help\n3. info'
        );
        break;
      case 'info':
        await client.sendText(message.from, 'This is a demo Venom Bot.');
        break;
      default:
        await client.sendText(
          message.from,
          "Sorry, I didn't understand. Type 'help' for options."
        );
    }
  });
}
Enter fullscreen mode Exit fullscreen mode

Production Tips

  • Always use a VPS (like DigitalOcean or AWS) for reliability.
  • Use venom.create({ headless: true }) to prevent opening a visible browser.
  • Secure sessions: Use session tokens to preserve authentication.
  • Error handling: Listen to events like client.onStateChange or client.onAck.

Limitations & Legal Notes

  • Venom Bot is based on unofficial WhatsApp Web APIs, so there’s always a chance of breakage.
  • You must comply with WhatsApp’s terms of service. Avoid spammy behavior.

Conclusion

Venom Bot offers a fast and flexible way to automate WhatsApp with Node.js. Whether you’re building a personal assistant, customer support bot, or alert system, Venom provides a developer-friendly API to get started quickly.

🔧 From a QR-authenticated session to sending interactive messages, Venom makes WhatsApp automation simple. Just remember to use it ethically and responsibly.

Top comments (7)

Collapse
 
mohsen_aghakarami_8d1700d profile image
Mohsen Aghakarami

hi , can use many session in one bot ?

Collapse
 
syed_mudasseranayat_e251 profile image
Syed Mudasser Anayat

Yes you can

Collapse
 
majid_shafiee_848a817cdd2 profile image
majid shafiee

hi
unfortunately modules are deprecated .!

Collapse
 
syed_mudasseranayat_e251 profile image
Syed Mudasser Anayat
Collapse
 
edwin_paul_c52c02dcfcd756 profile image
Edwin Paul

Tenia un bot cob venom, pero dejo de funcionar que sucedio

Collapse
 
majid_shafiee_848a817cdd2 profile image
majid shafiee

hi
Is it possible to run venom with old Node.js
or any other way to run it without update modules?
thanks

Collapse
 
syed_mudasseranayat_e251 profile image
Syed Mudasser Anayat

Yes — it may be possible, but it depends on which version of “Venom” you mean and how old your Node.js version is. It also depends on whether the module uses features unsupported in older Node.js