@zassxd/baileys
v1.7.1
Published
Baileys is a lightweight JavaScript library for interacting with the WhatsApp Web API using WebSocket.
Maintainers
Readme
📚 Table of Contents
🌟 Features
- ✅ Multi-Device Support
- 🔄 Real-Time Messaging (text, media, polls, buttons)
- 🛠️ Group & Channel Management (create, modify, invite)
- 🔒 End-to-End Encryption
- 📦 Session Persistence
🔥 Updated New (08 Oktober 2025)
- 🍟 Convert LID Mentions to JID
- 🤖 Convert Sender LID to JID
- 👥 Convert Group ID LID to JID
- 🩸 Fixed All Bug LID (participant - mentionedJid - sender - admins group)
🌱 Owner’s Notice
Proyek ini bersifat publik, sehingga siapa pun dapat menggunakan atau melakukan rename untuk keperluan pribadi. Namun, penggunaan untuk tujuan komersial atau sekadar pencarian nama tidak diperkenankan.
Proyek ini dikembangkan berdasarkan libary Whiskeysocket, dengan perbaikan dan peningkatan yang dilakukan oleh administrator.
Tujuan utama dari proyek ini adalah untuk memudahkan pengguna serta memperbaiki kesalahan bot yang sebelumnya sering dialami.
Saat ini proyek masih dalam tahap Beta, sehingga kemungkinan masih terdapat bug atau kendala tak terduga saat proses instalasi maupun eksekusi.
Jika Anda mengalami masalah yang berlanjut, silakan hubungi kami melalui kontak yang telah tersedia.
Terimakasih, salam hangat, zass!
⚡ Contact Admin
📜 License
- This project is licensed for personal and non-commercial use only.
- Redistribution, modification, or renaming for personal purposes is allowed.
- Commercial use, resale, or name-hunting is strictly prohibited.
🤝 Contribution Guidelines
We welcome contributions to improve this project. To contribute:
- Fork the repository
- Create a new branch for your feature or fix
- Submit a pull request with a clear explanation of the changes
All contributions will be reviewed before merging.
📥 Installation
npm install @zassxd/baileys
# or
yarn add @zassxd/baileys🚀 Quick Start
const {
default: makeWASocket,
useMultiFileAuthState,
} = require('@zassxd/baileys');
const {
state,
saveCreds
} = await useMultiFileAuthState("./path/to/sessions/folder")
/*
* const sock = makeWASocket({ printQRInTerminal: true });
* code to get WhatsApp web connection
* QR code or pairing code type available
*/
sock.ev.on('messages.upsert', ({ messages }) => {
console.log('New message:', messages[0].message);
});📖 Documentation
🔌 Connecting Account
const sock = makeWASocket({
printQRInTerminal: true, // true to display QR Code
auth: state
})const sock = makeWASocket({
printQRInTerminal: false, // false so that the pairing code is not disturbed
auth: state
})
if (!sock.authState.creds.registered) {
const number = "62xxxx"
// use default pairing code (default 1-8)
const code = await sock.requestPairingCode(number)
// use customer code pairing (8 digit)
const customCode = "ABCD4321"
const code = await sock.requestPairingCode(number, customCode)
console.log(code)
}📡 Handling Events
sock.ev.on('messages.upsert', ({ messages }) => {
console.log('New message:', messages[0].message);
});sock.ev.on('messages.update', (m) => {
if (m.pollUpdates) console.log('Poll vote:', m.pollUpdates);
});📨 Sending Messages
/**
* Sends a message using the WhatsApp socket connection.
*
* @param {string} jid - The JID (Jabber ID) of the recipient/user.
* This is the unique identifier for the WhatsApp user/group.
* @param {Object} content - The message content to be sent. Can be any valid message type
* (text, image, video, document, etc.) with required parameters.
* @param {Object} [options] - Optional parameters for message generation and sending.
* Can include properties like:
* - quoted: Message to reply to
* - ephemeral: If message should disappear after viewing
* - mediaUpload: Media upload options
* - etc.
* @returns {Promise<Object>} A promise that resolves with the sent message info or
* rejects with an error if sending fails.
*/
const jid = ''; // Recipient's JID (WhatsApp ID) or LID
const content = {}; // Message content object
const options = {}; // Optional message options
// Send the message using the WhatsApp socket connection
sock.sendMessage(jid, content, options)// Simple Text
await sock.sendMessage(jid, { text: 'Hello!' });// Text with link preview
await sock.sendMessage(jid, {
text: 'Visit https://example.com',
linkPreview: {
'canonical-url': 'https://example.com',
title: 'Example Domain',
description: 'A demo website',
jpegThumbnail: fs.readFileSync('preview.jpg')
}
});// With Quoted Reply
await sock.sendMessage(jid, { text: 'Hello Shiroko!' }, { quoted: message });// With local file buffer
await sock.sendMessage(jid, {
image: fs.readFileSync('shiroko.jpg'),
caption: 'My wife!',
mentions: ['[email protected]'] // Tag users
});// With URL
await sock.sendMessage(jid, {
image: { url: 'https://example.com/shiroko.jpg' },
caption: 'Emh ayang nya zass'
});// With Local File
await sock.sendMessage(jid, {
video: fs.readFileSync('video.mp4'),
caption: 'Funny clip!'
});// With URL File
await sock.sendMessage(jid, {
video: { url: 'https://example.com/video.mp4' },
caption: 'Streamed video'
});// View Once Message
await sock.sendMessage(jid, {
video: fs.readFileSync('secret.mp4'),
viewOnce: true // Disappears after viewing
});// Regular audio
await sock.sendMessage(jid, {
audio: fs.readFileSync('audio.mp3'),
ptt: false // For music
});// Push-to-talk (PTT)
await sock.sendMessage(jid, {
audio: fs.readFileSync('voice.ogg'),
ptt: true, // WhatsApp voice note
waveform: [0, 1, 0, 1, 0] // Optional waveform
});const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
+ 'VERSION:3.0\n'
+ 'FN:Jeff Singh\n' // full name
+ 'ORG:Ashoka Uni\n' // the organization of the contact
+ 'TELtype=CELLtype=VOICEwaid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number
+ 'END:VCARD'
await sock.sendMessage(jid, {
contacts: {
displayName: 'Your Name',
contacts: [{ vcard }]
}
})await sock.sendMessage(jid, {
react: {
text: '👍', // use an empty string to remove the reaction
key: message.key
}
})| Time | Seconds | |-------|----------------| | 24h | 86.400 | | 7d | 604.800 | | 30d | 2.592.000 |
// Pin Message
await sock.sendMessage(jid, {
pin: {
type: 1, // 2 to remove
time: 86400,
key: message.key
}
})// Keep message
await sock.sendMessage(jid, {
keep: {
key: message.key,
type: 1 // or 2 to remove
}
})// Static location
await sock.sendMessage(jid, {
location: {
degreesLatitude: 37.422,
degreesLongitude: -122.084,
name: 'Google HQ'
}
});// Thumbnail location
await sock.sendMessage(jid, {
location: {
degreesLatitude: 37.422,
degreesLongitude: -122.084,
name: 'Google HQ',
jpegThumbnail: fs.readFileSync('preview.jpg')
}
});// Live location (updates in real-time)
await sock.sendMessage(jid, {
location: {
degreesLatitude: 37.422,
degreesLongitude: -122.084,
accuracyInMeters: 10
},
live: true, // Enable live tracking
caption: 'I’m here!'
});await sock.sendMessage(jid, {
call: {
name: 'Here is call message',
type: 1 // 2 for video
}
})await sock.sendMessage(jid, {
event: {
isCanceled: false, // or true
name: 'Here is name event',
description: 'Short description here',
location: {
degreesLatitude: 0,
degreesLongitude: 0,
name: 'Gedung Tikus Kantor'
},
startTime: 17..., // timestamp date
endTime: 17..., // timestamp date
extraGuestsAllowed: true // or false
}
})await sock.sendMessage(jid, {
order: {
orderId: '123xxx',
thumbnail: fs.readFileSync('preview.jpg'),
itemCount: '123',
status: 'INQUIRY', // INQUIRY || ACCEPTED || DECLINED
surface: 'CATALOG',
message: 'Here is order message',
orderTitle: 'Here is title order',
sellerJid: '[email protected]'',
token: 'token_here',
totalAmount1000: '300000',
totalCurrencyCode: 'IDR'
}
})// Create a poll
await sock.sendMessage(jid, {
poll: {
name: 'Favorite color?',
values: ['Red', 'Blue', 'Green'],
selectableCount: 1 // Single-choice
}
});// Poll results (snapshot)
await sock.sendMessage(jid, {
pollResult: {
name: 'Favorite color?',
values: [['Red', 10], ['Blue', 20]] // [option, votes]
}
});await sock.sendMessage(jid, {
product: {
productId: '123',
title: 'Cool T-Shirt',
description: '100% cotton',
price: 1999, // In cents (e.g., $19.99)
currencyCode: 'USD',
productImage: fs.readFileSync('shirt.jpg')
}
});await sock.sendMessage(jid, {
payment: {
note: 'Here is payment message',
currency: 'USD', // optional
offset: 0, // optional
amount: '100000', // optional
expiry: 0, // optional
from: '[email protected]', // optional
image: { // optional
placeholderArgb: "your_background", // optional
textArgb: "your_text", // optional
subtextArgb: "your_subtext" // optional
}
}
})await sock.sendMessage(jid, {
paymentInvite: {
type: 1, // 1 || 2 || 3
expiry: 0
}
})await sock.sendMessage(jid, {
adminInvite: {
jid: '172xxx@newsletter',
name: 'Newsletter Title',
caption: 'Undangan admin channel saya',
expiration: 86400,
jpegThumbnail: fs.readFileSync('preview.jpg') // optional
}
})await sock.sendMessage(jid, {
groupInvite: {
jid: '[email protected]',
name: 'Group Name!',
caption: 'Invitation To Join My Whatsapp Group',
code: 'xYz3yAtf...', // code invite link
expiration: 86400,
jpegThumbnail: fs.readFileSync('preview.jpg') // optional
}
})// Request phone number
await sock.sendMessage(jid, {
requestPhoneNumber: {}
})// Share phone number
await sock.sendMessage(jid, {
sharePhoneNumber: {}
})// Reply List Message
await sock.sendMessage(jid, {
buttonReply: {
name: 'Hii',
description: 'description',
rowId: 'ID'
},
type: 'list'
})// Reply Button Message
await sock.sendMessage(jid, {
buttonReply: {
displayText: 'Hii',
id: 'ID'
},
type: 'plain'
})// Reply Template Message
await sock.sendMessage(jid, {
buttonReply: {
displayText: 'Hii',
id: 'ID',
index: 1 // number id button reply
},
type: 'template'
})// Reply Interactive Message
await sock.sendMessage(jid, {
buttonReply: {
body: 'Hii',
nativeFlows: {
name: 'menu_options',
paramsJson: JSON.stringify({ id: 'ID', description: 'description' })
version: 1 // 2 | 3
}
},
type: 'interactive'
})await sock.sendStatusMentions({
image: {
url: 'https://example.com/image.jpg'
},
caption: 'Nice day!'
}, ["[email protected]", "[email protected]"])await sock.sendAlbumMessage(jid,
[{
image: { url: 'https://example.com/image.jpg' },
caption: 'Hello World'
},
{
image: fs.readFileSync('image.jpg'),
caption: 'Hello World'
},
{
video: { url: 'https://example.com/video.mp4' },
caption: 'Hello World'
},
{
video: fs.readFileSync('video.mp4'),
caption: 'Hello World'
}],
{ quoted: message, delay: 3000 })This is an interactive chat created based on Proto WhatsApp business data, if the message does not work then there may be a change in the buttonParamsJson structure.
// Headers Text
await sock.sendMessage(jid, {
text: 'Here is body message',
title: 'Here is title',
subtitle: 'Here is subtitle',
footer: '© WhatsApp Baileys',
viewOnce: true,
shop: {
surface: 1, // 2 | 3 | 4
id: 'facebook_store_name'
}
})// Headers Image
await sock.sendMessage(jid, {
image: {
url: 'https://www.example.com/image.jpg'
},
caption: 'Here is body message',
title: 'Here is title',
subtitle: 'Here is subtitle',
footer: '© WhatsApp Baileys',
shop: {
surface: 1, // 2 | 3 | 4
id: 'facebook_store_name'
},
hasMediaAttachment: true, // or false
viewOnce: true
})// Headers Video
await sock.sendMessage(jid, {
video: {
url: 'https://www.example.com/video.mp4'
},
caption: 'Here is body message',
title: 'Here is title',
subtitle: 'Here is subtitle',
footer: '© WhatsApp Baileys',
shop: {
surface: 1, // 2 | 3 | 4
id: 'facebook_store_name'
},
hasMediaAttachment: true, // or false
viewOnce: true
})// Headers Document
await sock.sendMessage(jid, {
document: {
url: 'https://www.example.com/document.pdf'
},
mimetype: 'application/pdf',
jpegThumbnail: await sock.resize('https://www.example.com/thumbnail.jpg', 320, 320),
caption: 'Here is body message',
title: 'Here is title',
subtitle: 'Here is subtitle',
footer: '© WhatsApp Baileys',
shop: {
surface: 1, // 2 | 3 | 4
id: 'facebook_store_name'
},
hasMediaAttachment: false, // or true,
viewOnce: true
})// Headers Location
await sock.sendMessage(jid, {
location: {
degressLatitude: -0,
degressLongitude: 0,
name: 'Example Location'
},
caption: 'Here is body message',
title: 'Here is title',
subtitle: 'Here is subtitle',
footer: '© WhatsApp Baileys',
shop: {
surface: 1, // 2 | 3 | 4
id: 'facebook_store_name'
},
hasMediaAttachment: false, // or true
viewOnce: true
})// Headers Product
await sock.sendMessage(jid, {
product: {
productImage: {
url: 'https://www.example.com/product.jpg'
},
productId: '23942543532047956', // catalog business ID
title: 'Example Product',
description: 'Example Product Description',
currencyCode: 'IDR',
priceAmount1000: '2000000',
retailerId: 'ExampleRetailer',
url: 'https://www.example.com/product',
productImageCount: 1
},
businessOwnerJid: '[email protected]',
caption: 'Here is body message',
title: 'Here is title',
subtitle: 'Here is subtitle',
footer: '© WhatsApp Baileys',
shop: {
surface: 1, // 2 | 3 | 4
id: 'facebook_store_name'
},
hasMediaAttachment: false, // or true
viewOnce: true
})await sock.sendMessage(jid, {
text: 'Here is body message',
title: 'Here is title',
subtile: 'Here is subtitle',
footer: '© WhatsApp baileys',
cards: [{
image: { url: 'https://www.example.com/image.jpg' }, // or buffer
title: 'The title cards',
body: 'The body cards',
footer: '© WhatsApp',
buttons: [{
name: 'quick_reply',
buttonParamsJson: JSON.stringify({
display_text: 'Display Text',
id: '123'
})
},
{
name: 'cta_url',
buttonParamsJson: JSON.stringify({
display_text: 'Display Text',
url: 'https://www.example.com'
})
}]
},
{
video: { url: 'https://www.example.com/video.mp4' }, // or buffer
title: 'The title cards 2',
body: 'The body cards 2',
footer: '© WhatsApp',
buttons: [{
name: 'quick_reply',
buttonParamsJson: JSON.stringify({
display_text: 'Display Text',
id: 'ID'
})
},
{
name: 'cta_url',
buttonParamsJson: JSON.stringify({
display_text: 'Display Text',
url: 'https://www.example.com'
})
}]
}]
})Native flow messages are used to display various types of button messages, even for flow dialogs. These buttons are easy to use and are often able to accommodate many parameters.
// Headers text
await sock.sendMessage(jid, {
text: 'This is body message!',
title: 'This is title',
subtitle: 'This is subtitle',
footer: '© WhatsApp Baileys',
interactive: native_flow_button
})// Headers image
await sock.sendMessage(jid, {
image: { url: 'https://www.example.com/image.jpg' },
caption: 'This is body message!',
title: 'This is title',
subtitle: 'This is subtitle',
footer: '© WhatsApp Baileys',
hasMediaAttachment: true,
interactive: native_flow_button
})// Headers Video
await sock.sendMessage(jid, {
video: { url: 'https://www.example.com/video.mp4' },
caption: 'This is body message!',
title: 'This is title',
subtitle: 'This is subtitle',
footer: '© WhatsApp Baileys',
hasMediaAttachment: true,
interactive: native_flow_button
})// Headers Document
await sock.sendMessage(jid, {
document: { url: 'https://www.example.com/document.pdf' },
jpegThumbnail: fs.readFileSync('preview.jpg'),
mimetype: 'application/pdf',
caption: 'This is body message!',
title: 'This is title',
subtitle: 'This is subtitle',
footer: '© WhatsApp Baileys',
hasMediaAttachment: true,
interactive: native_flow_button
})// Headers Location
await sock.sendMessage(jid, {
location: {
degressLatitude: -0,
degressLongitude: 0,
name: 'Here is name location'
},
caption: 'This is body message!',
title: 'This is title',
subtitle: 'This is subtitle',
footer: '© WhatsApp Baileys',
hasMediaAttachment: true,
interactive: native_flow_button
})// Headers Product
await sock.sendMessage(jid, {
product: {
productImage: {
url: 'https://www.example.com/product.jpg'
},
productId: '23942543532047956', // catalog business ID
title: 'Example Product',
description: 'Example Product Description',
currencyCode: 'IDR',
priceAmount1000: '2000000',
retailerId: 'ExampleRetailer',
url: 'https://www.example.com/product',
productImageCount: 1
},
businessOwnerJid: '[email protected]',
caption: 'This is body message!',
title: 'This is title',
subtitle: 'This is subtitle',
footer: '© WhatsApp Baileys',
hasMediaAttachment: true,
interactive: native_flow_button
})const native_flow_button = [{
name: 'quick_reply',
buttonParamsJson: JSON.stringify({
display_text: 'Quick Reply',
id: '123'
})
}]const native_flow_button = [{
name: 'cta_url',
buttonParamsJson: JSON.stringify({
display_text: 'Action URL',
url: 'https://www.example.com',
merchant_url: 'https://www.example.com'
})
}]const native_flow_button = [{
name: 'cta_copy',
buttonParamsJson: JSON.stringify({
display_text: 'Action Copy',
copy_code: '12345678'
})
}]const native_flow_button = [{
name: 'cta_call',
buttonParamsJson: JSON.stringify({
display_text: 'Action Call',
phone_number: '628xxx'
})
}]const native_flow_button = [{
name: 'cta_catalog',
buttonParamsJson: JSON.stringify({
business_phone_number: '628xxx'
})
}]const native_flow_button = [{
name: 'cta_reminder',
buttonParamsJson: JSON.stringify({
display_text: 'Action Reminder'
})
}]const native_flow_button = [{
name: 'cta_cancel_reminder',
buttonParamsJson: JSON.stringify({
display_text: 'Action Unreminder'
})
}]const native_flow_button = [{
name: 'address_message',
buttonParamsJson: JSON.stringify({
display_text: 'Form Location'
})
}]const native_flow_button = [{
name: 'send_location',
buttonParamsJson: JSON.stringify({
display_text: 'Send Location'
})
}]const native_flow_button = [{
name: 'open_webview',
buttonParamsJson: JSON.stringify({
title: 'URL Web View',
link: {
in_app_webview: true, // or false
url: 'https://www.example.com'
}
})
}]const native_flow_button = [{
name: 'mpm',
buttonParamsJson: JSON.stringify({
product_id: '23942543532047956'
})
}]const native_flow_button = [{
name: 'wa_payment_transaction_details',
buttonParamsJson: JSON.stringify({
transaction_id: '12345848'
})
}]const native_flow_button = [{
name: 'automated_greeting_message_view_catalog',
buttonParamsJson: JSON.stringify({
business_phone_number: '628xxx',
catalog_product_id: '23942543532047956'
})
}]const native_flow_button = [{
name: 'galaxy_message',
buttonParamsJson: JSON.stringify({
mode: 'published',
flow_message_version: '3',
flow_token: '1:1307913409923914:293680f87029f5a13d1ec5e35e718af3',
flow_id: '1307913409923914',
flow_cta: 'Here is button form',
flow_action: 'navigate',
flow_action_payload: {
screen: 'QUESTION_ONE',
params: {
user_id: '123456789',
referral: 'campaign_xyz'
}
},
flow_metadata: {
flow_json_version: '201',
data_api_protocol: 'v2',
flow_name: 'Lead Qualification [en]',
data_api_version: 'v2',
categories: ['Lead Generation', 'Sales']
}
})
}]const native_flow_button = [{
name: 'single_select',
buttonParamsJson: JSON.stringify({
title: 'Selection Button',
sections: [{
title: 'Title 1',
highlight_label: 'Highlight label 1',
rows: [{
header: 'Header 1',
title: 'Title 1',
description: 'Description 1',
id: 'Id 1'
},
{
header: 'Header 2',
title: 'Title 2',
description: 'Description 2',
id: 'Id 2'
}
]
}]
})
}]await sock.sendMessage(jid, {
product: {
productId: '123',
title: 'Cool T-Shirt',
description: '100% cotton',
price: 1999, // In cents (e.g., $19.99)
currencyCode: 'USD',
productImage: fs.readFileSync('shirt.jpg')
}
});This message button may not work if WhatsApp prohibits the free and open use of the message button. Use a WhatsApp partner if you still want to use the message button.
// Button Headers Text
await sock.sendMessage(jid, {
text: 'Choose an option:',
buttons: button_params,
footer: '© WhatsApp Baileys'
});// Button Headers Image
await sock.sendMessage(jid, {
image: fs.readFileSync('image.jpg'),
caption: 'Choose an option:',
buttons: button_params,
footer: '© WhatsApp Baileys'
});// Button Headers Video
await sock.sendMessage(jid, {
video: fs.readFileSync('video.mp4'),
caption: 'Choose an option:',
buttons: button_params,
footer: '© WhatsApp Baileys'
});// Button Headers Location
await sock.sendMessage(jid, {
location: {
degreesLatitude: 37.422,
degreesLongitude: -122.084
},
caption: 'Choose an option:',
buttons: button_params,
footer: '© WhatsApp Baileys'
});// Button Params Default
const button_params = [{
buttonId: 'id1',
buttonText: {
displayText: 'Option 1'
},
type: 1
},{
buttonId: 'id2',
buttonText: {
displayText: 'Option 2'
},
type: 1
}]// Button Params NativeFlow
const button_params = [{
buttonId: 'id1',
buttonText: {
displayText: 'Option 1'
},
type: 1
},{
buttonId: 'flow',
buttonText: {
displayText: 'flow'
},
nativeFlowInfo: {
name: 'cta_url',
buttonParamsJson: JSON.stringify({
display_text: 'Visit URL',
url: 'https://web.whatsapp.com',
merchant_url: 'https://web.whatsapp.com'
})
},
type: 2
}]// Single Select
await sock.sendMessage(jid, {
text: 'Menu:',
sections: [
{ title: 'Food', rows: [
{ title: 'Pizza', rowId: 'pizza' },
{ title: 'Burger', rowId: 'burger' }
]}
],
buttonText: 'Browse'
});// Product List
await sock.sendMessage(jid, {
title: 'Here is title product',
text: 'Text message',
footer: '© WhatsApp Baileys',
buttonText: 'Select Menu',
productList: [{
title: 'Product Collection',
products: [{
productId: '23942543532047956' // catalog business ID
}]
}],
businessOwnerJid: '[email protected]',
thumbnail: { url: 'https://www.example.com/file' }
})📣 Newsletter
// code can't have "https://whatsapp.com/channel/", only code
const newsletter = await sock.newsletterMetadata("invite", "0029Vb6w7eO9sBIEUYRgeC30")
console.log("Newsletter metadata:", newsletter)// from jid newsletter
const newsletter = await sock.newsletterMetadata("jid", "120363421570647022@newsletter")
console.log("Newsletter metadata:", newsletter)await sock.newsletterFollow("120363421570647022@newsletter")await sock.newsletterUnfollow("120363421570647022@newsletter")await sock.newsletterMute("120363421570647022@newsletter")await sock.newsletterUnmute("120363421570647022@newsletter")// Allow all emoji
await sock.newsletterReactionMode("120363421570647022@newsletter", "ALL")// Allow special emoji (👍, ❤️, 😯, 😢, 🙏)
await sock.newsletterReactionMode("120363421570647022@newsletter", "BASIC")// No reaction allowed
await sock.newsletterReactionMode("120363421570647022@newsletter", "NONE")await sock.newsletterUpdateDescription("120363421570647022@newsletter", "News description here!")await sock.newsletterUpdateName("120363421570647022@newsletter", "New newsletter name!")// Change
await sock.newsletterUpdatePicture("120363421570647022@newsletter", { url: 'https://example.com/image.jpg' })// Remove
await sock.newsletterRemovePicture("120363421570647022@newsletter")const newsletter = await sock.newsletterCreate("Here is name newsletter!", "Here is description!", { url: 'https://example.com/image.jpg' })
console.log("Here is data new created newsletter:", newsletter)const list_newsletter = await sock.newsletterFetchAllParticipating()
console.log("Your list newsletter join:", list_newsletter)await sock.newsletterChangeOwner("120363421570647022@newsletter", "123@lid")await sock.newsletterDemote("120363421570647022@newsletter", "123@lid")await sock.newsletterReactMessage("120363421570647022@newsletter", "12", "🦖")🛠️ Groups
const group = await sock.groupCreate("New Group Title", ["[email protected]", "[email protected]"]);
console.log("New group create data:", group)// only allow admins to send messages
await sock.groupSettingUpdate(jid, 'announcement')// allow everyone to send messages
await sock.groupSettingUpdate(jid, 'not_announcement')// allow everyone to modify the group's settings -- like display picture etc.
await sock.groupSettingUpdate(jid, 'unlocked')// only allow admins to modify the group's settings
await sock.groupSettingUpdate(jid, 'locked')// add member
await sock.groupParticipantsUpdate(jid, ['[email protected]', '[email protected]'], 'add')
// remove member
await sock.groupParticipantsUpdate(jid, ['[email protected]', '[email protected]'], 'remove')
// promote member (admins)
await sock.groupParticipantsUpdate(jid, ['[email protected]', '[email protected]'], 'promote')
// demote member (unadmins)
await sock.groupParticipantsUpdate(jid, ['[email protected]', '[email protected]'], 'demote')await sock.groupUpdateSubject(jid, 'New Subject Title!')await sock.groupUpdateDescription(jid, 'New Description!')await sock.groupLeave(jid)// to create link with code use "https://chat.whatsapp.com/" + code
const code = await sock.groupInviteCode(jid)
console.log('group code: ' + code)const code = await sock.groupRevokeInvite(jid)
console.log('New group code: ' + code)// code can't have "https://chat.whatsapp.com/", only code
const response = await sock.groupAcceptInvite(code)
console.log('joined to: ' + response)const response = await sock.groupGetInviteInfo(code)
console.log('group information: ' + response)const metadata = await sock.groupMetadata(jid)
console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)const response = await sock.groupAcceptInviteV4(jid, groupInviteMessage)
console.log('joined to: ' + response)const response = await sock.groupRequestParticipantsList(jid)
console.log(response)// Approve
const response = await sock.groupRequestParticipantsUpdate(jid, ['[email protected]', '[email protected]'], 'approve')// Reject
const response = await sock.groupRequestParticipantsUpdate(jid, ['[email protected]', '[email protected]'], 'reject')const response = await sock.groupFetchAllParticipating()
console.log(response)- Ephemeral can be:
| Time | Seconds | |-------|----------------| | Remove | 0 | | 24h | 86.400 | | 7d | 604.800 | | 90d | 7.776.000 |
await sock.groupToggleEphemeral(jid, 86400)// Everyone Member
await sock.groupMemberAddMode(jid, 'all_member_add')// Only Admin
await sock.groupMemberAddMode(jid, 'admin_add')🔒 Privacy
// Change
await sock.updateProfilePicture(jid, { url: 'https://example.com/image.jpg' })// Remove
await sock.removeProfilePicture(jid)// Block
await sock.updateBlockStatus(jid, 'block');// Unblock
await sock.updateBlockStatus(jid, 'unblock');const privacySettings = await sock.fetchPrivacySettings(true)
console.log('privacy settings: ' + privacySettings)const response = await sock.fetchBlocklist()
console.log(response)// Everyone
await sock.updateLastSeenPrivacy("all")// Contacts
await sock.updateLastSeenPrivacy("contacts")// Contacts Blacklist
await sock.updateLastSeenPrivacy("contact_blacklist")// Hide
await sock.updateLastSeenPrivacy("none")// Everyone
await sock.updateOnlinePrivacy("all")// Match last seen
await sock.updateOnlinePrivacy("match_last_seen")// Everyone
await sock.updateProfilePicturePrivacy("all")// Contacts
await sock.updateProfilePicturePrivacy("contacts")// Contacts Blacklist
await sock.updateProfilePicturePrivacy("contact_blacklist")// Hide
await sock.updateProfilePicturePrivacy("none")// Everyone
await sock.updateStatusPrivacy("all")// Contacts
await sock.updateStatusPrivacy("contacts")// Contacts Blacklist
await sock.updateStatusPrivacy("contact_blacklist")// Hide
await sock.updateStatusPrivacy("none")// Show
await sock.updateReadReceiptsPrivacy("all")// Hide
await sock.updateReadReceiptsPrivacy("none")// Everyone
await sock.updateGroupsAddPrivacy("all")// Contacts
await sock.updateGroupsAddPrivacy("contacts")// Contacts Blacklist
await sock.updateGroupsAddPrivacy("contact_blacklist")| Time | Seconds | |-------|----------------| | Remove | 0 | | 24h | 86.400 | | 7d | 604.800 | | 90d | 7.776.000 |
await sock.updateDefaultDisappearingMode(86400)⚙️ Advanced
const sock = makeWASocket({ logger: { level: 'debug' } });sock.ws.on('CB:presence', (json) => console.log('Sockets update:', json));
// for any message with tag 'edge_routing'
sock.ws.on('CB:edge_routing', (node) => console.log('Sockets update:', node));
// for any message with tag 'edge_routing' and id attribute = abcd
sock.ws.on('CB:edge_routing,id:abcd', (node) => console.log('Sockets update:', node));
// for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info
sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node) => console.log('Sockets update:', node));⚠️ Disclaimer
This project is not affiliated with WhatsApp/Meta. Use at your own risk.
Refer to WhatsApp's Terms for compliance.
🔗 Full Documentation
Explore all features in the Baileys GitHub Wiki
