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 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?'); } }); } 3. Run the Bot node index.js 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!'); 2. Sending Media (Images, PDF, etc.) await client.sendImage( '123456789@c.us', './path/to/image.jpg', 'image_name', 'Caption text here' ); 3. Group Messaging await client.sendText('123456789-123456789@g.us', 'Hello Group!'); 4. Buttons and Interactive Messages await client.sendButtons( message.from, 'Choose an option:', [ { buttonText: { displayText: 'Option 1' } }, { buttonText: { displayText: 'Option 2' } } ], 'Custom footer text' ); Building a Simple Command Bot function startBot(client) { client.onMessage(async (message) => { switch (message.body.toLowerCase()) { case 'hello': await client.sendText(message.from, '

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
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?');
}
});
}
3. Run the Bot
node index.js
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!');
2. Sending Media (Images, PDF, etc.)
await client.sendImage(
'123456789@c.us',
'./path/to/image.jpg',
'image_name',
'Caption text here'
);
3. Group Messaging
await client.sendText('123456789-123456789@g.us', 'Hello Group!');
4. Buttons and Interactive Messages
await client.sendButtons(
message.from,
'Choose an option:',
[
{ buttonText: { displayText: 'Option 1' } },
{ buttonText: { displayText: 'Option 2' } }
],
'Custom footer text'
);
Building a Simple Command Bot
function startBot(client) {
client.onMessage(async (message) => {
switch (message.body.toLowerCase()) {
case 'hello':
await client.sendText(message.from, '