whatsapp-multi-device-client
v1.0.0
Published
๐ Advanced WhatsApp Bot Library with Multi-Device Support & EasyBot API - The most powerful WhatsApp automation library
Maintainers
Readme
๐ WhatsApp Multi Client
The most powerful WhatsApp Bot Library with Multi-Device Support & EasyBot API
๐ฏ Perfect for beginners AND professionals
๐ง Multi-Device Load Balancing
โก 3-Line Bot Creation
๐ 120+ Features Built-in
โก Quick Start (3 Lines!)
import { quickBot } from "whatsapp-multi-client";
quickBot()
.when("hello").reply("Hi! ๐")
.start();That's it! Your WhatsApp bot is running! ๐
๐ฆ Installation
npm install whatsapp-multi-clientRequirements:
- Node.js 16+
- A WhatsApp account for the bot
๐ฏ Choose Your API
๐ข EasyBot - For Beginners
Perfect for quick bots and learning:
import { createBot } from "whatsapp-multi-client";
createBot()
.when("ping").reply("Pong! ๐")
.when("hello").reply("Hi there! ๐")
.command("time", () => new Date().toLocaleString())
.start();๐ต Advanced API - For Professionals
Full control and customization:
import { WhatsAppClient } from "whatsapp-multi-client";
const client = new WhatsAppClient();
client.setPrefix('!');
client.on('message', async (msg) => {
if (msg.text === 'hello') {
await msg.simulateTyping('Hello! How can I help?');
}
});
await client.connect();๐ก Multi-Device - For Scale
Run multiple WhatsApp accounts simultaneously:
import { MultiWhatsAppClient } from "whatsapp-multi-client";
const multiClient = new MultiWhatsAppClient({
maxDevices: 3,
loadBalancing: 'round-robin'
});
await multiClient.addDevice('bot1');
await multiClient.addDevice('bot2');
await multiClient.connect();
// Messages automatically load-balanced across devices!
await multiClient.sendMessage(chatId, { text: 'Hello from multi-device!' });โก EasyBot - For Beginners
Super Simple API
Create WhatsApp bots in minutes, not hours!
import { quickBot } from "whatsapp-multi-client";
quickBot()
.when("hello").reply("Hi! ๐")
.start();Action Chaining
Chain multiple actions elegantly:
import { createBot } from "whatsapp-multi-client";
createBot()
.when("important")
.react("โ ๏ธ")
.type(2)
.reply("This is important!")
.react("โ
")
.done()
.start();EasyBot Features
const bot = createBot()
// Simple responses
.when("hello").reply("Hi! ๐")
.when("ping").reply("Pong! ๐")
// Auto-responses
.autoReply("hi", "Hello!")
.autoReply("bye", "Goodbye!")
// Commands
.command("help", "I can help you!")
.command("time", () => new Date().toLocaleString())
// Templates with variables
.template("greeting", "Hello {name}! Today is {day}")
.when("welcome").useTemplate("greeting")
// Conditional logic
.if("is group").then("reply Hello group!")
.if("contains bot").then("react ๐ค")
// Multi-device (optional)
.enableMultiDevice(2)
.start();EasyBot Multi-Device
import { multiBot } from "whatsapp-multi-client";
multiBot(3) // 3 devices
.when("test").reply("Multi-device test!")
.command("status", "๐ Multi-device running!")
.start();Template System
bot
.template("info", "Hello {name}! Time: {time}, Date: {date}")
.template("status", "Chat: {chat} | Day: {day}")
.when("info").useTemplate("info")
.when("status").useTemplate("status");
// Available variables:
// {name} - Sender name
// {sender} - Sender JID
// {time} - Current time
// {date} - Current date
// {datetime} - Date + time
// {day} - Weekday
// {chat} - "Group" or "Private"๐ฅ Multi-Device Support
Multi-Device System
Run 2-3 WhatsApp accounts simultaneously for higher availability and load balancing!
import { MultiWhatsAppClient } from "whatsapp-multi-client";
const multiClient = new MultiWhatsAppClient({
maxDevices: 3,
loadBalancing: 'round-robin' // round-robin, random, least-used, failover
});
// Add devices
await multiClient.addDevice('bot1');
await multiClient.addDevice('bot2');
await multiClient.addDevice('bot3');
// Connect all
await multiClient.connect();Load Balancing Strategies
// Round-robin (default)
multiClient.setLoadBalancingStrategy('round-robin');
// Random selection
multiClient.setLoadBalancingStrategy('random');
// Least used device
multiClient.setLoadBalancingStrategy('least-used');Smart Messaging
// Load-balanced sending
await multiClient.sendMessage(chatId, { text: 'Hello!' });
// Broadcast to all devices
await multiClient.broadcast(chatId, { text: 'Broadcast!' });
// With failover (if one device fails)
await multiClient.sendWithFailover(chatId, { text: 'Failover!' });
// Specific device
await multiClient.sendFromDevice('bot1', chatId, { text: 'From Bot1!' });Multi-Device Events
multiClient.on('message', async (msg) => {
console.log(`Message from device: ${msg.deviceId}`);
// Reply from same device
await msg.replyFromSameDevice('Same device reply');
// Reply via load balancing
await msg.replyFromAnyDevice('Load balanced reply');
// Broadcast reply
await msg.broadcastReply('Broadcast reply');
});
// Device status events
multiClient.on('device.connected', (data) => {
console.log(`โ
Device ${data.deviceId} connected`);
});
multiClient.on('device.disconnected', (data) => {
console.log(`๐ด Device ${data.deviceId} disconnected`);
});Health Monitoring
// Get status
const status = multiClient.getStatus();
console.log(`${status.activeDevices}/${status.totalDevices} devices active`);
// Health check
const health = multiClient.getHealthCheck();
console.log(`Health: ${health.healthPercentage}% - ${health.recommendation}`);
// Device stats
const stats = multiClient.getDeviceStats();Multi-Device Benefits:
โ
Higher availability - If one account gets banned, others continue
โ
Load distribution - Spread messages across multiple accounts
โ
Rate limit bypass - WhatsApp limits per account
โ
Automatic failover - Seamless switching on failures
โ
Separate auth - Each device has its own authentication
๐ Authentication
Persistent Authentication
- โ One-time QR scan โ Always auto-connect
- โ Microsoft Edge integration - QR code in browser
- โ Terminal fallback - QR code in terminal
- โ Auto-reconnect - Automatic reconnection
const client = new WhatsAppClient({
authDir: "./auth", // Auth data storage
printQR: false, // QR in browser (true = terminal)
logLevel: "silent" // Log level
});๐ฌ Message System
Basic Messaging
// Simple reply
await msg.reply("Hello!")
// With mentions
await msg.reply("Hello @user!", [userJid])Media Messages
// Images
await msg.sendImage("path/image.jpg", "Caption", [mentions])
// Videos
await msg.sendVideo("path/video.mp4", "Caption", [mentions])
// Audio
await msg.sendAudio("path/audio.mp3")
// Stickers
await msg.sendSticker("path/sticker.webp")
// Documents
await msg.sendDocument("path/file.pdf", "filename.pdf", [mentions])Special Messages
// Location
await msg.sendLocation(latitude, longitude)
// Contact
await msg.sendContact(vcard, "Display Name")
// Emoji reaction
await msg.react("๐")
// Delete message
await msg.delete()Message Properties
msg.id // Message ID
msg.from // Sender JID
msg.text // Message text
msg.type // text, image, video, audio, etc.
msg.isGroup // true/false
msg.timestamp // Unix timestamp
msg.raw // Raw Baileys object๐ญ Typing Indicator
Manual Control
// Start/stop typing
await msg.visualWrite(true) // Typing ON
await msg.visualWrite(false) // Typing OFF
// Typing for specific time
await msg.typeFor(3000) // 3 seconds typingTyping + Reply Combined
// Fixed time
await msg.typeAndReply("Message", 2000) // 2 seconds typing
// Realistic typing
await msg.simulateTyping("Long text...", {
typingSpeed: 50, // ms per character
minTypingTime: 1000, // Minimum time
maxTypingTime: 5000, // Maximum time
mentions: [userJid] // With mentions
})๐ฅ Group Management
Group Information
// Group metadata
const metadata = await client.get.GroupMetadata(groupId)
// All participants
const participants = await client.get.GroupParticipants(groupId)
// Only admins
const admins = await client.get.GroupAdmins(groupId)User Management
// Add user
await client.add.user(groupId, [userJid], [mentions])
// Remove user
await client.kick.user(groupId, [userJid], [mentions])
// Promote to admin
await client.promote.user(groupId, [userJid], [mentions])
// Remove admin
await client.demote.user(groupId, [userJid], [mentions])Mention System
// Mention single person
await msg.replyWithMention("Hello @user!", userJid)
// Mention all in group
await msg.mentionAll("Hello everyone!")
// Get mentions from message
const mentions = msg.getMentions()
// Check if mentioned
const isMentioned = msg.isMentioned(userJid)๐ก๏ธ Permission System
Permission Checks
// Admin checks
const isAdmin = await msg.isAdmin() // Is sender admin?
const isBotAdmin = await msg.isBotAdmin() // Is bot admin?
const isOwner = await msg.isOwner() // Is sender owner?
// Chat type checks
const isGroup = msg.isGroup // Is group?
const isPrivate = msg.isPrivate() // Is private chat?
// Sender info
const senderJid = msg.getSender() // Sender JIDUsage in Commands
client.addCommand('kick', async (msg, args) => {
if (!msg.isGroup) {
return msg.reply('โ Groups only!')
}
if (!(await msg.isAdmin())) {
return msg.reply('โ Admins only!')
}
if (!(await msg.isBotAdmin())) {
return msg.reply('โ Bot needs admin rights!')
}
// Kick logic...
})๐ Statistics System
Message Statistics
// Message counts
const stats = await msg.stats.getMessageCount()
// Returns: { total: 1234, today: 56, thisWeek: 234 }
// User activity
const activity = await msg.stats.getUserActivity(userId)
// Returns: { messagesCount: 123, lastSeen: Date, isActive: true }
// Group stats (groups only)
const groupStats = await msg.stats.getGroupStats()
// Returns: { groupName, totalMembers, admins, created, description }
// Top active users
const topUsers = await msg.stats.getMostActiveUsers(5)
// Messages by type
const messageTypes = await msg.stats.getMessagesByType()
// Returns: { text: 500, image: 100, video: 50, ... }๐ฏ Command System
Prefix Setup
// Set prefix
const prefix = "!"
client.setPrefix(prefix)
// Register commands
client.addCommand('help', async (msg, args) => {
await msg.reply('Help text')
})
client.addCommand('ping', async (msg, args) => {
await msg.reply('Pong! ๐')
})Command Properties
// In message events
if (msg.isCommand) {
console.log(msg.command) // "help"
console.log(msg.args) // ["arg1", "arg2"]
console.log(msg.commandText) // "help arg1 arg2"
}Command Management
// List commands
const commands = client.getCommands()
// Remove command
client.removeCommand('help')
// Get prefix
const currentPrefix = client.getPrefix()๐ Poll Integration
Create Polls
// Simple poll
await msg.sendPoll('Favorite pizza?', ['Margherita', 'Pepperoni', 'Hawaiian'])
// Multi-selection poll
await msg.sendMultiPoll('Which colors?', ['Red', 'Blue', 'Green'], 2)Fallback System
If native polls don't work, the library automatically uses emoji fallback:
๐ **Favorite pizza?**
1๏ธโฃ Margherita
2๏ธโฃ Pepperoni
3๏ธโฃ Hawaiian
_React with the corresponding emoji!_๐ง Event System
Event Registration
// Message events
client.on('message', (msg) => {
console.log(`Message from ${msg.from}: ${msg.text}`)
})
// Command events
client.on('command', (msg) => {
console.log(`Command: ${msg.command}`)
})
// Connection events
client.on('connected', () => {
console.log('Connected!')
})
client.on('disconnected', (data) => {
console.log('Disconnected:', data.reason)
})
// Group events
client.on('group.participants.update', (update) => {
console.log('Group changed:', update)
})
// Presence events
client.on('presence.update', (update) => {
console.log('Status changed:', update)
})Event Management
// Remove event handler
client.off('message', handler)
// Emit custom event
client.emit('custom-event', data)๐ฑ QR Code System
QR Code Generation
import { generateQRCode } from "whatsapp-multi-client"
// Generate QR code
await generateQRCode()
// QR code with data
await generateQRCode(qrData)
// Close browser
await closeBrowser()Features
- โ Microsoft Edge integration - Automatic opening
- โ Terminal fallback - QR in terminal if browser fails
- โ Auto-close - Browser closes automatically after login
๐ง Utility Functions
Connection Management
// Connect
await client.connect()
// Disconnect
await client.disconnect()
// Get status
const state = client.getConnectionState()
// Returns: { isConnected: true, socket: true }Presence Management
// Global presence
await client.setOnline()
await client.setOffline()
await client.setTyping(chatId)
await client.setRecording(chatId)
await client.setPaused(chatId)Message Type Detection
const type = client.getMessageType(message)
// Returns: text, image, video, audio, document, sticker, location, contact, unknown๐ Examples
EasyBot (Beginners)
import { quickBot } from "whatsapp-multi-client";
// 3 lines = complete bot!
quickBot()
.when("hello").reply("Hi! ๐")
.start();EasyBot with Action Chaining
import { createBot } from "whatsapp-multi-client";
createBot()
.when("important")
.react("โ ๏ธ") // Reaction
.type(2) // 2 seconds typing
.reply("Important!") // Reply
.react("โ
") // Another reaction
.done() // Back to bot
.when("party")
.react("๐")
.type(1)
.reply("Party! ๐ฅณ")
.done()
.command("help", "I can help you!")
.autoReply("hi", "Hello!")
.start();EasyBot Multi-Device
import { multiBot } from "whatsapp-multi-client";
multiBot(2) // 2 devices
.when("test").reply("Multi-device test!")
.command("status", "๐ 2 devices active!")
.start();Multi-Device Bot
import { MultiWhatsAppClient } from "whatsapp-multi-client";
const multiClient = new MultiWhatsAppClient({
maxDevices: 3,
loadBalancing: 'round-robin'
});
// Add devices
await multiClient.addDevice('main-bot');
await multiClient.addDevice('backup-bot');
await multiClient.addDevice('support-bot');
// Commands for all devices
multiClient.setPrefix('!');
multiClient.addCommand('ping', async (msg) => {
await msg.replyFromSameDevice(`Pong from ${msg.deviceId}! ๐`);
});
multiClient.addCommand('status', async (msg) => {
const status = multiClient.getStatus();
await msg.replyFromSameDevice(`๐ ${status.activeDevices}/${status.totalDevices} devices active`);
});
multiClient.addCommand('broadcast', async (msg, args) => {
const message = args.join(' ');
await multiClient.broadcast(msg.from, { text: `๐ข ${message}` });
});
// Events
multiClient.on('message', async (msg) => {
if (msg.text === 'hello') {
// Load-balanced response
await multiClient.sendMessage(msg.from, {
text: `Hello from ${msg.deviceId}! ๐`
});
}
});
// Connect all devices
await multiClient.connect();
console.log("๐ Multi-device bot running!");Advanced Bot
import { WhatsAppClient } from "whatsapp-multi-client";
const client = new WhatsAppClient();
const prefix = "!";
client.setPrefix(prefix);
// Commands
client.addCommand('ping', async (msg) => {
await msg.typeAndReply('Pong! ๐', 1000);
});
client.addCommand('info', async (msg) => {
await msg.visualWrite(true);
await new Promise(r => setTimeout(r, 2000));
await msg.visualWrite(false);
await msg.reply('Bot info: Running perfectly! โ
');
});
// Events
client.on('message', async (msg) => {
if (msg.text === 'hello') {
await msg.simulateTyping('Hello! How are you?');
}
});
await client.connect();Interactive Bot
client.on('message', async (msg) => {
if (msg.text.includes('how are you')) {
await msg.visualWrite(true);
await new Promise(r => setTimeout(r, 3000));
await msg.visualWrite(false);
await msg.reply('I\'m doing great, thanks! ๐ How about you?');
}
if (msg.text.includes('poll')) {
await msg.quickType('Creating poll...');
await msg.sendPoll('How do you like the bot?', ['Great!', 'Good', 'Okay', 'Bad']);
}
});๐ฎ Available Commands (Test Bot)
!help- Show all commands!ping- Pong response!stats- Show statistics!kick @user- Kick user (admin only)!debug- Debug information!poll "Question" "Opt1" "Opt2"- Create poll!demo- Typing demo!customtype 3000 "Text"- Custom typing!slowtype "Text"- Slow typing
๐ฅ Feature Count
Total: 120+ Functions and Features!
- Message Functions: 15+
- Group Functions: 8+
- Permission Functions: 6+
- Statistics Functions: 5+
- Typing Functions: 8+
- Command System: 10+
- Event System: 8+
- QR Functions: 3+
- Utility Functions: 15+
- Multi-Device System: 20+
- ๐ EasyBot System: 25+
๐ Why Choose This Library?
๐ฏ Three APIs in One
- EasyBot - 3-line bot creation for beginners
- Advanced - Full control for professionals
- Multi-Device - Scale with multiple accounts
๐ฅ Unique Features
- Multi-Device Load Balancing - Industry first!
- Action Chaining - jQuery-style bot building
- Realistic Typing - Human-like interactions
- Edge QR Integration - Seamless authentication
- Template System - Dynamic content with variables
๐ช Production Ready
- Persistent Auth - One-time setup
- Auto Reconnection - Handles disconnections
- Health Monitoring - Track device status
- Error Handling - Graceful failure recovery
- TypeScript Support - Full type definitions
๐ Scalable Architecture
- Load Balancing - Distribute message load
- Failover System - Automatic device switching
- Rate Limit Bypass - Multiple account limits
- Plugin Ready - Extensible for v2.0
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Quick Contribute
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฎ Roadmap (v2.0)
- ๐ Plugin System - Extensible architecture
- ๐พ Database Integration - Persistent storage
- ๐ Web Dashboard - Browser-based management
- ๐ Scheduled Messages - Cron-like scheduling
- ๐ก๏ธ Advanced Moderation - Auto-spam detection
- ๐ค AI Integration - ChatGPT/Claude support
- ๐ Analytics Dashboard - Detailed insights
- ๐ฎ Game Framework - Interactive bot games
๐ Support
- โญ Star this repository if you find it helpful
- ๐ Report bugs via GitHub Issues
- ๐ก Request features via GitHub Discussions
- ๐ง Contact for commercial support
๐ Contributors
Thanks to all contributors who make this project possible! ๐
Made with โค๏ธ for WhatsApp Automation
The most powerful WhatsApp bot library - from 3-line bots to enterprise multi-device systems!
