wertybailz

A modern WhatsApp socket wrapper with extended messaging capabilities.
Installation
npm install wertybailz
Or declare in package.json:
"dependencies": {
"wertybailz": "latest"
}
Import
const {
default: makeWASocket,
} = require('wertybailz');
Connecting to WhatsApp
Via QR Code
const { default: makeWASocket } = require('wertybailz');
const client = makeWASocket({
browser: ['Ubuntu', 'Chrome', '20.00.1'],
printQRInTerminal: true,
});
Via Pairing Code
const {
default: makeWASocket,
fetchLatestWAWebVersion,
} = require('wertybailz');
const client = makeWASocket({
browser: ['Ubuntu', 'Chrome', '20.00.1'],
printQRInTerminal: false,
version: fetchLatestWAWebVersion(),
aiLabel: true,
});
const number = '628XXXXXXXXX';
const code = await client.requestPairingCode(number.trim());
console.log('Pairing code:', code);
Store / Session Data
const {
default: makeWASocket,
makeInMemoryStore,
} = require('wertybailz');
const pino = require('pino');
const store = makeInMemoryStore({
logger: pino().child({ level: 'silent', stream: 'store' }),
});
const client = makeWASocket({ });
store.bind(client.ev);
client.ev.on('contacts.upsert', () => {
console.log('New contacts:', Object.values(store.contacts()));
});
Sending Messages
Order Message
const fs = require('fs');
const thumbnail = fs.readFileSync('./thumbnail.png');
await client.sendMessage(m.chat, {
thumbnail,
message: 'Your order summary',
orderTitle: 'My Store',
totalAmount1000: 72500,
totalCurrencyCode: 'IDR',
}, { quoted: m });
Poll Result Snapshot
await client.sendMessage(m.chat, {
pollResultMessage: {
name: 'Survey Title',
options: [
{ optionName: 'Option A' },
{ optionName: 'Option B' },
],
newsletter: {
newsletterName: 'My Channel',
newsletterJid: '1@newsletter',
},
},
});
Product Message
await client.relayMessage(m.chat, {
productMessage: {
title: 'Product Name',
description: 'Short product description.',
thumbnail: { url: './product.jpg' },
productId: 'PRODUCT_ID',
retailerId: 'RETAILER_ID',
url: 'https://example.com/product',
body: 'Body text',
footer: 'Footer text',
buttons: [
{
name: 'cta_url',
buttonParamsJson: JSON.stringify({
display_text: 'View Product',
url: 'https://example.com/product',
}),
},
],
priceAmount1000: 72500,
currencyCode: 'IDR',
},
});
Group Member Label
await client.sendMessage(m.chat, {
groupLabel: {
labelText: 'Tag group members here',
},
});
Message to All Group Members
await client.sendMessageMembers(m.chat, {
extendedTextMessage: {
text: 'Hello everyone!',
},
}, {});
Simple Send Helpers
All helpers below support an optional contextInfo and quoted object.
Text
await client.sendText(m.chat, 'Hello world!', {
contextInfo: { mentionedJid: [m.chat] },
}, {
key: {
remoteJid: 'status@broadcast',
participant: m.sender,
fromMe: true,
},
message: { conversation: '\0' },
});
Image
await client.sendImage(m.chat, { url: './image.jpg' }, 'Caption here', {
contextInfo: { mentionedJid: [m.chat] },
}, {
key: {
remoteJid: 'status@broadcast',
participant: m.sender,
fromMe: true,
},
message: { conversation: '\0' },
});
Video
await client.sendVideo(m.chat, { url: './video.mp4' }, 'Caption here', {
contextInfo: { mentionedJid: [m.chat] },
}, {
key: {
remoteJid: 'status@broadcast',
participant: m.sender,
fromMe: true,
},
message: { conversation: '\0' },
});
Audio
await client.sendAudio(m.chat, { url: './audio.mp3' }, {
contextInfo: { mentionedJid: [m.chat] },
}, {
key: {
remoteJid: 'status@broadcast',
participant: m.sender,
fromMe: true,
},
message: { conversation: '\0' },
});
Location
await client.sendLocation(
m.chat,
'Location Name',
-6.2, 106.8,
'https://maps.example.com',
'6281234567890',
{ contextInfo: { mentionedJid: [m.chat] } },
{
key: {
remoteJid: 'status@broadcast',
participant: m.sender,
fromMe: true,
},
message: { conversation: '\0' },
}
);
Poll
await client.sendPoll(m.chat, 'Your question?', ['Option 1', 'Option 2', 'Option 3'], true, {
contextInfo: { mentionedJid: [m.chat] },
}, {
key: {
remoteJid: 'status@broadcast',
participant: m.sender,
fromMe: true,
},
message: { conversation: '\0' },
});
Quiz
await client.sendQuiz(
m.chat,
'Which is correct?',
['Answer A', 'Answer B', 'Answer C'],
'Answer B',
{ contextInfo: { mentionedJid: [m.chat] } },
{
key: {
remoteJid: 'status@broadcast',
participant: m.sender,
fromMe: true,
},
message: { conversation: '\0' },
}
);
Status Mention
await client.statusMention(m.chat, {
extendedTextMessage: {
text: 'Mentioned in status!',
},
});
License
GPL-3.0