@shurainc/baileys
v3.0.3
Published
A WebSockets library for interacting with WhatsApp Web
Maintainers
Readme
shura-baileys
shura-baileys is a maintained fork of @whiskeysockets/baileys, modified for the shurainc bot. The goal is stable production flows, practical copy-paste examples, and a few extra helper message types while staying close to the upstream API.
Update channel (changelog and notices)
- All updates, behavior changes, and breaking changes are posted here: https://whatsapp.com/channel/0029Vb8IWc3FSAsy4xaX991n
Install
This repo is published as an NPM alias for @whiskeysockets/baileys.
npm install @whiskeysockets/baileys@npm:@shurainc/[email protected]package.json
@whiskeysockets/baileys
"dependencies": {
"@whiskeysockets/baileys": "npm:@shurainc/baileys"
}Custom pairing code
const code = await sock.requestPairingCode('628xxx', 'SHURAINC');
console.log('Your pairing code:', code);Getting started
Below are practical sock.sendMessage() examples you can copy into your bot. this fork also includes a few extra helper message types (like albumMessage, eventMessage, pollResultMessage, and groupStatusMessage) to match shurainc production flows while keeping the upstream Baileys API familiar.
Status group message V2
Send group status with version 2
await sock.sendMessage(jid, {
groupStatusMessage: {
text: "shurainc baileys"
}
});Album message (multiple Images)
Send multiple images in a single album message:
await sock.sendMessage(jid, {
albumMessage: [
{ image: { url: "https://example.com/image1.jpg" }, caption: "image 1" },
{ image: { url: "https://example.com/image2.jpg" }, caption: "image 2" }
]
}, { quoted: m });Event message
Create and send WhatsApp event invitations:
await sock.sendMessage(jid, {
eventMessage: {
isCanceled: false,
name: "hello",
description: "hello",
location: {
degreesLatitude: 0,
degreesLongitude: 0,
name: "shurainc baileys"
},
joinLink: "https://call.whatsapp.com/video/shurainc",
startTime: "1763019000",
endTime: "1763026200",
extraGuestsAllowed: false
}
}, { quoted: m });Poll result message
Display poll results with vote counts:
await sock.sendMessage(jid, {
pollResultMessage: {
name: "Where are you from?",
pollVotes: [
{
optionName: "🇮🇩",
optionVoteCount: "25000"
},
{
optionName: "🇷🇺",
optionVoteCount: "20000"
}
]
}
}, { quoted: m });Location message
Send a location message with an interactive quick reply button:
await sock.sendMessage(jid, {
location: {
degreesLatitude: 0,
degreesLongitude: 0,
name: 'shurainc baileys',
},
caption: 'hello',
title: 'hello',
footer: '@shuraincbaileys',
interactiveButtons: [
{
name: 'quick_reply',
buttonParamsJson: JSON.stringify({
display_text: 'hello',
id: '.hello',
}),
},
],
hasMediaAttachment: false, // or true
});Buttons message
Send a basic buttons message (2 quick reply buttons):
await sock.sendMessage(jid, {
text: 'hello',
footer: '@shuraincbaileys',
buttons: [
{ buttonId: '.btn1', buttonText: { displayText: 'button 1' } },
{ buttonId: '.btn2', buttonText: { displayText: 'button 2' } },
],
});Buttons message with media header
Send a buttons message with an image header:
await sock.sendMessage(jid, {
image: { url: 'https://example.com/image.jpg' },
caption: 'hello',
footer: '@shuraincbaileys',
buttons: [
{ buttonId: '.btn1', buttonText: { displayText: 'button 1' } },
{ buttonId: '.btn2', buttonText: { displayText: 'button 2' } },
],
});List message (sections)
Send a list message with sections and rows:
await sock.sendMessage(jid, {
text: 'hello',
footer: '@shuraincbaileys',
buttonText: 'hello',
title: 'hello',
sections: [
{
title: 'shurainc baileys',
rows: [
{ title: 'hello', rowId: '.rowId1', description: 'shurainc baileys' },
{ title: 'hello', rowId: '.rowId2', description: 'shurainc baileys' },
],
},
],
});Simple interactive message
Send basic interactive messages with copy button functionality:
await sock.sendMessage(jid, {
interactiveMessage: {
header: "hello",
title: "hello",
footer: "@shuraincbaileys",
buttons: [
{
name: "cta_copy",
buttonParamsJson: JSON.stringify({
display_text: "copy code",
id: "123",
copy_code: "123"
})
}
]
}
}, { quoted: m });Interactive Message with Native Flow
Send interactive messages with buttons, copy actions, and native flow features:
await sock.sendMessage(jid, {
interactiveMessage: {
header: "hello",
title: "hello",
footer: "@shuraincbaileys",
image: { url: "https://example.com/image.jpg" },
nativeFlowMessage: {
messageParamsJson: JSON.stringify({
limited_time_offer: {
text: "hello",
url: "https://whatsapp.com/channel/0029Vb8IWc3FSAsy4xaX991n",
copy_code: "@shuraincbaileys",
expiration_time: Date.now() * 999
},
bottom_sheet: {
in_thread_buttons_limit: 2,
divider_indices: [1, 2, 3, 4, 5, 999],
list_title: "hello",
button_title: "hello"
},
tap_target_configuration: {
title: "hello",
description: "@shuraincbaileys",
canonical_url: "https://whatsapp.com/channel/0029Vb8IWc3FSAsy4xaX991n",
domain: "shop.example.com",
button_index: 0
}
}),
buttons: [
{
name: "single_select",
buttonParamsJson: JSON.stringify({
has_multiple_buttons: true
})
},
{
name: "call_permission_request",
buttonParamsJson: JSON.stringify({
has_multiple_buttons: true
})
},
{
name: "single_select",
buttonParamsJson: JSON.stringify({
title: "hello",
sections: [
{
title: "hello",
highlight_label: "@shuraincbaileys",
rows: [
{
title: "@shuraincbaileys",
description: "shurainc baileys",
id: "row_2"
}
]
}
],
has_multiple_buttons: true
})
},
{
name: "cta_copy",
buttonParamsJson: JSON.stringify({
display_text: "copy code",
id: "123",
copy_code: "123"
})
}
]
}
}
}, { quoted: m });Interactive message with thumbnail
Send interactive messages with thumbnail image and copy button:
await sock.sendMessage(jid, {
interactiveMessage: {
header: "hello",
title: "hello",
footer: "@shuraincbaileys",
image: { url: "https://example.com/image.jpg" },
buttons: [
{
name: "cta_copy",
buttonParamsJson: JSON.stringify({
display_text: "copy code",
id: "123",
copy_code: "123"
})
}
]
}
}, { quoted: m });Product message
Send product catalog messages with buttons and merchant information:
await sock.sendMessage(jid, {
productMessage: {
title: "sample products",
description: "product description",
thumbnail: { url: "https://example.com/image.jpg" },
productId: "P12345",
retailerId: "R12345",
url: "https://example.com/product",
body: "product details",
footer: "special price",
priceAmount1000: 30000,
currencyCode: "USD",
buttons: [
{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "buy now",
url: "https://example.com/buy"
})
}
]
}
}, { quoted: m });Groups (usage)
// create group
const group = await sock.groupCreate('My Group', ['[email protected]']);
// fetch metadata
const meta = await sock.groupMetadata(group.id);
// update subject/description
await sock.groupUpdateSubject(group.id, 'My Group v2');
await sock.groupUpdateDescription(group.id, 'group description');
// participants
await sock.groupParticipantsUpdate(group.id, ['[email protected]'], 'add');
await sock.groupParticipantsUpdate(group.id, ['[email protected]'], 'remove');
// join requests
const requests = await sock.groupRequestParticipantsList(group.id);
// approve/reject by jid from the list
// await sock.groupRequestParticipantsUpdate(group.id, [requests[0]?.jid], 'approve');
// invite links
const inviteCode = await sock.groupInviteCode(group.id);
const inviteInfo = await sock.groupGetInviteInfo(inviteCode);
await sock.groupRevokeInvite(group.id);
// settings
await sock.groupToggleEphemeral(group.id, 86400);
await sock.groupSettingUpdate(group.id, 'announcement');
await sock.groupMemberAddMode(group.id, 'all_member_add');
await sock.groupJoinApprovalMode(group.id, 'on');
// list & leave
const allGroups = await sock.groupFetchAllParticipating();
await sock.groupLeave(group.id);Newsletter (channel) usage
// create newsletter
const created = await sock.newsletterCreate('shura updates', 'baileys updates');
// update metadata
await sock.newsletterUpdateName(channelJid, 'shura updates');
await sock.newsletterUpdateDescription(channelJid, 'baileys updates');
await sock.newsletterUpdatePicture(channelJid, fs.readFileSync('./image.png'));
await sock.newsletterRemovePicture(channelJid);
// metadata & subscribers
const metadata = await sock.newsletterMetadata('jid', channelJid);
const subs = await sock.newsletterSubscribers(channelJid);
// follow / mute
await sock.newsletterFollow(channelJid);
await sock.newsletterUnfollow(channelJid);
await sock.newsletterMute(channelJid);
await sock.newsletterUnmute(channelJid);
// react & fetch messages
await sock.newsletterReactMessage(channelJid, '300', '💙');
const messages = await sock.newsletterFetchMessages(channelJid, 20, 0, 0);
const live = await sock.subscribeNewsletterUpdates(channelJid);
// admin actions
const adminCount = await sock.newsletterAdminCount(channelJid);
await sock.newsletterChangeOwner(channelJid, '[email protected]');
await sock.newsletterDemote(channelJid, '[email protected]');
// delete
await sock.newsletterDelete(channelJid);