WhatsApp Web API client with interactive messages, product catalogs, carousels, events, payments, and polls. Forked from WhiskeySockets/Baileys.
npm install xnxx-bail-pro---
---
| Feature | Description |
|---------|-------------|
| Multi-Device Support | Connect without phone always online |
| WebSocket Based | Fast and efficient real-time communication |
| Session Management | Save and restore authentication state |
| Auto Reconnect | Automatic reconnection with exponential backoff |
| Anti-Call | Auto reject calls with custom message and block option |
| iOS/Apple Support | Optimized sockets for iOS and macOS devices |
| Feature | Description |
|---------|-------------|
| Interactive Messages | Buttons, lists, and native flows |
| Media Handling | Images, videos, audio, documents, stickers |
| Product Catalogs | E-commerce ready messaging |
| Event Messages | Create and share calendar events |
| Payment Requests | Request payments with custom amounts |
| Carousel Messages | Multi-card interactive displays |
| Poll Support | Create and manage polls with real-time results |
| Poll Results | Display poll results with vote counts |
| Album Messages | Send multiple images/videos as album |
| Group Stories | Post stories to groups |
| Newsletter/Channels | Manage WhatsApp channels and broadcasts |
| Location Sharing | Share locations with rich metadata |
| Sticker Packs | Send complete sticker collections |
---
``bashNPM
npm install xnxx-bail-pro
Add to your package.json:
`json`
{
"dependencies": {
"@whiskeysockets/baileys": "npm:xnxx-bail-pro"
}
}
`javascript
// ESM (Recommended)
import makeWASocket from 'xnxx-bail-pro'
// CommonJS
const { default: makeWASocket } = require('xnxx-bail-pro')
`
---
📖 Click to expand Quick Start Guide
`javascript
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from 'xnxx-bail-pro'
async function connectToWhatsApp() {
const { state, saveCreds } = await useMultiFileAuthState('auth_session')
const sock = makeWASocket({
auth: state,
printQRInTerminal: true,
browser: ['XNXX Baileys', 'Chrome', '1.0.0']
})
sock.ev.on('connection.update', (update) => {
const { connection, lastDisconnect } = update
if(connection === 'close') {
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
if(shouldReconnect) {
connectToWhatsApp()
}
} else if(connection === 'open') {
console.log('✅ Connected to WhatsApp!')
}
})
sock.ev.on('messages.upsert', async ({ messages }) => {
for(const msg of messages) {
if(!msg.key.fromMe && msg.message) {
await sock.sendMessage(msg.key.remoteJid, {
text: 'Hello from XNXX Baileys!'
})
}
}
})
sock.ev.on('creds.update', saveCreds)
}
connectToWhatsApp()
`
---
🔐 QR Code Authentication
`javascript
import makeWASocket from 'xnxx-bail-pro'
const sock = makeWASocket({
auth: state,
printQRInTerminal: true,
browser: ['XNXX Bot', 'Chrome', '1.0.0']
})
`
📱 Pairing Code Authentication
`javascript
const sock = makeWASocket({
auth: state,
printQRInTerminal: false
})
if(!sock.authState.creds.registered) {
const phoneNumber = '1234567890' // without + or spaces
const code = await sock.requestPairingCode(phoneNumber)
console.log(Pairing code: ${code})`
}
🎯 Custom Pairing Code
`javascript`
const phoneNumber = "628XXXXX"
const code = await sock.requestPairingCode(phoneNumber.trim(), "CUSTOM01")
console.log("Your pairing code: " + code)
---
💾 Cache Group Metadata (Recommended)
`javascript
const NodeCache = require('node-cache')
const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false })
const sock = makeWASocket({
cachedGroupMetadata: async (jid) => groupCache.get(jid)
})
sock.ev.on('groups.update', async ([event]) => {
const metadata = await sock.groupMetadata(event.id)
groupCache.set(event.id, metadata)
})
`
🔄 Improve Retry & Poll Decryption
`javascript`
const sock = makeWASocket({
getMessage: async (key) => await getMessageFromStore(key)
})
🔇 Silent Mode (No Notification on Phone)
`javascript`
const sock = makeWASocket({
markOnlineOnConnect: false
})
---
💿 Avoid Scanning QR Every Time
`javascript
import makeWASocket, { useMultiFileAuthState } from 'xnxx-bail-pro'
const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys')
const sock = makeWASocket({ auth: state })
sock.ev.on('creds.update', saveCreds)
`
>
Note: For production, store auth in a database instead of files.
---
🔌 Connection Updates
`javascript`
sock.ev.on('connection.update', (update) => {
const { connection, lastDisconnect } = update
if(connection === 'close') {
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
console.log('Connection closed, reconnecting:', shouldReconnect)
if(shouldReconnect) connectToWhatsApp()
} else if(connection === 'open') {
console.log('Connection opened')
}
})
📨 New Messages
`javascript`
sock.ev.on('messages.upsert', async ({ messages }) => {
for(const msg of messages) {
console.log('New message:', msg)
}
})
🔄 Message Updates
`javascript`
sock.ev.on('messages.update', async (updates) => {
for(const update of updates) {
console.log('Message updated:', update)
}
})
📊 Decrypt Poll Votes
`javascript`
sock.ev.on('messages.update', async (event) => {
for(const { key, update } of event) {
if(update.pollUpdates) {
const pollCreation = await getMessage(key)
if(pollCreation) {
console.log('Poll update:', getAggregateVotesInPollMessage({
message: pollCreation,
pollUpdates: update.pollUpdates,
}))
}
}
}
})
---
🗄️ In-Memory Store Implementation
`javascript
import makeWASocket, { makeInMemoryStore } from 'xnxx-bail-pro'
const store = makeInMemoryStore({})
store.readFromFile('./baileys_store.json')
setInterval(() => {
store.writeToFile('./baileys_store.json')
}, 10_000)
const sock = makeWASocket({})
store.bind(sock.ev)
sock.ev.on('chats.upsert', () => {
console.log('Got chats:', store.chats.all())
})
sock.ev.on('contacts.upsert', () => {
console.log('Got contacts:', Object.values(store.contacts))
})
`
>
Important: Build your own data store for production. In-memory storage wastes RAM.
---
| Type | Format | Example |
|------|--------|---------|
| Personal Chat | [country code][phone number]@s.whatsapp.net | 1234567890@s.whatsapp.net |[group id]@g.us
| Group | | 123456789-987654321@g.us |[timestamp]@broadcast
| Broadcast List | | 1234567890@broadcast |status@broadcast
| Status | | status@broadcast |[newsletter id]@newsletter
| Newsletter | | 1234567890@newsletter |
---
💬 Text Message
`javascript`
await sock.sendMessage(jid, { text: 'Hello World!' })
↩️ Quote Message
`javascript`
await sock.sendMessage(jid, { text: 'This is a reply' }, { quoted: message })
👤 Mention User
`javascript`
await sock.sendMessage(jid, {
text: '@12345678901',
mentions: ['12345678901@s.whatsapp.net']
})
📸 Album Message
`javascript`
await sock.sendAlbumMessage(
jid,
[
{
image: { url: "https://example.jpg" },
caption: "Hello World",
},
{
video: { url: "https://example.mp4" },
caption: "Hello World",
},
],
{
quoted: message,
delay: 2000
}
)
💳 Request Payment
`javascript`
await sock.sendMessage(jid, {
requestPayment: {
currency: "USD",
amount: "10000000",
from: "123456@s.whatsapp.net",
note: "Payment Request",
background: { }
}
}, { quoted: message })
📅 Event Message
`javascript`
await sock.sendMessage(jid, {
event: {
isCanceled: false,
name: "Event Name",
description: "Event Description",
location: {
degreesLatitude: -0,
degreesLongitude: -0
},
startTime: m.messageTimestamp.low,
endTime: m.messageTimestamp.low + 86400,
}
}, { quoted: message })
🛍️ Product Message
`javascript`
await sock.sendMessage(jid, {
productMessage: {
title: "Product Title",
description: "Product Description",
thumbnail: "https://example.png",
productId: "123456789",
retailerId: "STORE",
url: "https://example.png",
}
}, { quoted: message })
🎪 Carousel Message
`javascript`
await sock.sendMessage(jid, {
carouselMessage: {
caption: "Click URL",
footer: "Powered By XNXX Baileys",
cards: [
{
headerTitle: "Card 1",
imageUrl: "https://example.com/image.jpg",
productTitle: "Premium Product",
productDescription: "Get premium access",
bodyText: "Description here",
buttons: [
{
name: "cta_call",
params: {
display_text: "Contact",
phone_number: "+1234567890"
}
}
]
}
]
}
}, { quoted: message })
🔘 Interactive Buttons
`javascript`
await sock.sendMessage(jid, {
text: "Description of Message",
title: "Title of Message",
footer: "Footer Message",
interactiveButtons: [
{
name: "quick_reply",
buttonParamsJson: JSON.stringify({
display_text: "Quick Reply",
id: "button_1"
})
},
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "Visit Website",
url: "https://example.com"
})
}
]
}, { quoted: message })
📍 Location Message
`javascript`
await sock.sendMessage(jid, {
location: {
degreesLatitude: 24.121231,
degreesLongitude: 55.1121221,
name: "Location Name",
address: "Location Address"
}
})
👥 Contact Message
`javascript
const vcard = 'BEGIN:VCARD\n'
+ 'VERSION:3.0\n'
+ 'FN:John Doe\n'
+ 'ORG:Company;\n'
+ 'TEL;type=CELL;type=VOICE;waid=1234567890:+1 234 567 890\n'
+ 'END:VCARD'
await sock.sendMessage(jid, {
contacts: {
displayName: 'John Doe',
contacts: [{ vcard }]
}
})
`
❤️ Reaction Message
`javascript`
await sock.sendMessage(jid, {
react: {
text: '❤️',
key: message.key
}
})
📊 Poll Message
`javascript`
await sock.sendMessage(jid, {
poll: {
name: 'Favorite Color?',
values: ['Red', 'Blue', 'Green', 'Yellow'],
selectableCount: 1
}
})
🖼️ Image Message
`javascript
// From URL
await sock.sendMessage(jid, {
image: { url: 'https://example.com/image.jpg' },
caption: 'Beautiful image!'
})
// From Buffer
await sock.sendMessage(jid, {
image: buffer,
caption: 'Image from buffer'
})
`
🎥 Video Message
`javascript`
await sock.sendMessage(jid, {
video: { url: './video.mp4' },
caption: 'Check this out!',
gifPlayback: false,
ptv: false
})
🎵 Audio Message
`javascript`
await sock.sendMessage(jid, {
audio: { url: './audio.mp3' },
mimetype: 'audio/mp4',
ptt: true
})
📄 Document
`javascript`
await sock.sendMessage(jid, {
document: { url: './document.pdf' },
fileName: 'document.pdf',
mimetype: 'application/pdf'
})
🎭 Sticker
`javascript`
await sock.sendMessage(jid, {
sticker: { url: './sticker.webp' }
})
🎨 Sticker Pack
`javascript`
await sock.stickerPackMessage(jid, {
name: 'My Stickers',
publisher: 'Your Bot',
description: 'Collection of stickers',
stickers: [
{ data: buffer, emojis: ['😊'] },
{ data: './sticker.png', emojis: ['😂'] },
{ data: 'https://example.com/sticker.jpg', emojis: ['❤️'] }
],
cover: buffer
}, { quoted: message });
---
🗑️ Delete Message
`javascript`
const msg = await sock.sendMessage(jid, { text: 'hello' })
await sock.sendMessage(jid, { delete: msg.key })
✏️ Edit Message
`javascript`
await sock.sendMessage(jid, {
text: 'Updated message text',
edit: originalMessage.key
})
---
📥 Download Media
`javascript
import { downloadMediaMessage, getContentType } from 'xnxx-bail-pro'
sock.ev.on('messages.upsert', async ({ messages }) => {
const msg = messages[0]
if(!msg.message) return
const messageType = getContentType(msg.message)
if(messageType === 'imageMessage') {
const buffer = await downloadMediaMessage(
msg,
'buffer',
{},
{
logger: console,
reuploadRequest: sock.updateMediaMessage
}
)
fs.writeFileSync('./download.jpeg', buffer)
}
})
`
---
➕ Create Group
`javascript`
const group = await sock.groupCreate('Group Name', [
'1234567890@s.whatsapp.net',
'0987654321@s.whatsapp.net'
])
console.log('Group created:', group.id)
👥 Add/Remove Participants
`javascript
// Add
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'add')
// Remove
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'remove')
// Promote to admin
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'promote')
// Demote from admin
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'demote')
`
⚙️ Group Settings
`javascript
// Only admins can send messages
await sock.groupSettingUpdate(groupJid, 'announcement')
// Everyone can send messages
await sock.groupSettingUpdate(groupJid, 'not_announcement')
// Only admins can edit group info
await sock.groupSettingUpdate(groupJid, 'locked')
// Everyone can edit group info
await sock.groupSettingUpdate(groupJid, 'unlocked')
`
---
✅ Check if Number Exists
`javascript`
const [result] = await sock.onWhatsApp('1234567890')
if(result?.exists) {
console.log('Number exists:', result.jid)
}
🖼️ Get Profile Picture
`javascript`
const ppUrl = await sock.profilePictureUrl(jid)
const ppUrlHD = await sock.profilePictureUrl(jid, 'image')
📸 Update Profile Picture
`javascript`
await sock.updateProfilePicture(jid, {
url: './profile.jpg'
})
💬 Get Status
`javascript`
const status = await sock.fetchStatus(jid)
console.log('Status:', status)
👁️ Presence Updates
`javascript`
await sock.presenceSubscribe(jid)
await sock.sendPresenceUpdate('available', jid)
// Options: available, unavailable, composing, recording, paused
---
🚫 Block/Unblock User
`javascript
// Block
await sock.updateBlockStatus(jid, 'block')
// Unblock
await sock.updateBlockStatus(jid, 'unblock')
`
🔒 Update Privacy Settings
`javascript
// Last seen: 'all', 'contacts', 'contact_blacklist', 'none'
await sock.updateLastSeenPrivacy('contacts')
// Online: 'all', 'match_last_seen'
await sock.updateOnlinePrivacy('all')
// Profile picture: 'all', 'contacts', 'contact_blacklist', 'none'
await sock.updateProfilePicturePrivacy('contacts')
// Groups add: 'all', 'contacts', 'contact_blacklist'
await sock.updateGroupsAddPrivacy('contacts')
`
---
📦 Archive/Unarchive Chat
`javascript`
const lastMsg = await getLastMessageInChat(jid)
await sock.chatModify({
archive: true,
lastMessages: [lastMsg]
}, jid)
🔇 Mute/Unmute Chat
`javascript
// Mute for 8 hours
await sock.chatModify({
mute: 8 60 60 * 1000
}, jid)
// Unmute
await sock.chatModify({
mute: null
}, jid)
`
📌 Pin/Unpin Chat
`javascript
// Pin
await sock.chatModify({ pin: true }, jid)
// Unpin
await sock.chatModify({ pin: false }, jid)
`
---
📢 Send Broadcast Message
`javascript`
await sock.sendMessage(jid, {
text: 'Broadcast message',
statusJidList: [
'1234567890@s.whatsapp.net',
'0987654321@s.whatsapp.net'
],
broadcast: true
})
📱 Send Status/Story
`javascript`
await sock.sendMessage('status@broadcast', {
image: { url: './story.jpg' },
caption: 'My story update!'
})
📰 Newsletter Management
`javascript
// Create newsletter
await sock.newsletterCreate('Newsletter Name', {
description: 'Newsletter description',
picture: buffer
})
// Update newsletter
await sock.newsletterUpdateMetadata(newsletterJid, {
name: 'New Name',
description: 'New description'
})
// Follow/Unfollow
await sock.newsletterFollow(newsletterJid)
await sock.newsletterUnfollow(newsletterJid)
`
---
⏱️ Disappearing Messages
`javascript
// Enable (86400 = 24h, 604800 = 7d, 7776000 = 90d)
await sock.sendMessage(jid, {
disappearingMessagesInChat: 86400
})
// Disable
await sock.sendMessage(jid, {
disappearingMessagesInChat: false
})
`
🔍 Query Message
`javascript`
const msg = await sock.loadMessage(jid, messageId)
console.log('Message:', msg)
ℹ️ Get Message Info
`javascript`
const info = await sock.messageInfo(jid, messageId)
console.log('Read by:', info.readBy.length)
console.log('Played by:', info.playedBy.length)
---

---
1️⃣ Session Management
`javascript
import { useMultiFileAuthState } from 'xnxx-bail-pro'
const { state, saveCreds } = await useMultiFileAuthState('auth_folder')
const sock = makeWASocket({ auth: state })
sock.ev.on('creds.update', saveCreds)
`
2️⃣ Store Implementation
`javascript
import { makeInMemoryStore } from 'xnxx-bail-pro'
const store = makeInMemoryStore({})
store.readFromFile('./store.json')
setInterval(() => {
store.writeToFile('./store.json')
}, 10_000)
store.bind(sock.ev)
`
3️⃣ Error Handling
`javascript`
try {
await sock.sendMessage(jid, { text: 'Hello' })
} catch(error) {
if(error.output?.statusCode === 401) {
console.log('Not authorized')
} else {
console.error('Send failed:', error)
}
}
4️⃣ Reconnection Logic
`javascript`
sock.ev.on('connection.update', async (update) => {
const { connection, lastDisconnect } = update
if(connection === 'close') {
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
if(shouldReconnect) {
console.log('Reconnecting...')
await connectToWhatsApp()
}
}
})
---
- Personal: [country_code][phone_number]@s.whatsapp.net[group_id]@g.us
- Group: [timestamp]@broadcast
- Broadcast: status@broadcast
- Status: [newsletter_id]@newsletter
- Newsletter:
All supported message types:
- conversation - TextimageMessage
- - ImagevideoMessage
- - VideoaudioMessage
- - AudiodocumentMessage
- - DocumentstickerMessage
- - StickerlocationMessage
- - LocationcontactMessage
- - ContactpollCreationMessage
- - PollreactionMessage
- - ReactioneditedMessage
- - Edited messageviewOnceMessage
- - View once mediaextendedTextMessage
- - Text with link preview
`javascript
// Connection events
'connection.update', 'creds.update'
// Message events
'messages.upsert', 'messages.update', 'messages.delete', 'message-receipt.update'
// Chat events
'chats.set', 'chats.upsert', 'chats.update', 'chats.delete'
// Contact events
'contacts.set', 'contacts.upsert', 'contacts.update'
// Group events
'groups.upsert', 'groups.update', 'group-participants.update'
// Presence events
'presence.update'
// Call events
'call'
// Blocklist events
'blocklist.set', 'blocklist.update'
`
---
Contributions are welcome! Please follow these guidelines:
1. Fork the repository
2. Create your feature branch (git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature'
3. Commit your changes ()git push origin feature/AmazingFeature`)
4. Push to the branch (
5. Open a Pull Request
---
This project is licensed under the MIT License - see the LICENSE file for details.
---
This project is NOT officially affiliated with WhatsApp or Meta. This is an independent project and should be used responsibly.
Important:
-
Follow WhatsApp's Terms of Service
-
Don't spam or send unsolicited messages
-
Respect user privacy
-
Use for legitimate purposes only
-
Be aware of WhatsApp's rate limits
---
Special thanks to:
-
WhiskeySockets - For the original Baileys library
-
All contributors - For helping improve this project
-
The community - For continuous support and feedback
---

Forged by xnx6x
Based on WhiskeySockets/Baileys
![]()
Built with ❤️ and ☕ by developers, for developers