New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

surabails

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

surabails

A WebSockets library for interacting with WhatsApp Web

latest
npmnpm
Version
1.6.0
Version published
Weekly downloads
3
-57.14%
Maintainers
1
Weekly downloads
 
Created
Source

Install

package.json

"dependencies": {
    "baileys": "npm:surabails"
}

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 surabails 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: "surabails"
     }
});

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: "surabails" 
        }, 
        joinLink: "https://call.whatsapp.com/video/surabails", 
        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: 'surabails',
  },
  caption: 'hello',
  title: 'hello',
  footer: 'surabails',
  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: 'surabails',
  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: 'surabails',
  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: 'surabails',
  buttonText: 'hello',
  title: 'hello',
  sections: [
    {
      title: 'surabails',
      rows: [
        { title: 'hello', rowId: '.rowId1', description: 'surabails' },
        { title: 'hello', rowId: '.rowId2', description: 'surabails' },
      ],
    },
  ],
});

Simple interactive message

Send basic interactive messages with copy button functionality:

await sock.sendMessage(jid, {
    interactiveMessage: {
        header: "hello",
        title: "hello",
        footer: "surabails",
        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: "surabails",      
        image: { url: "https://example.com/image.jpg" },      
        nativeFlowMessage: {        
            messageParamsJson: JSON.stringify({          
                limited_time_offer: {            
                    text: "hello",            
                    url: "https://whatsapp.com/channel/0029Vb8IWc3FSAsy4xaX991n",            
                    copy_code: "surabails",            
                    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: "surabails",            
                    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: "surabails",                  
                                rows: [                    
                                    {                      
                                        title: "surabails",                      
                                        description: "surabails",                      
                                        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: "surabails",
        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', ['628xxx@s.whatsapp.net']);

// 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, ['628xxx@s.whatsapp.net'], 'add');
await sock.groupParticipantsUpdate(group.id, ['628xxx@s.whatsapp.net'], '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, '628xxx@s.whatsapp.net');
await sock.newsletterDemote(channelJid, '628xxx@s.whatsapp.net');

// delete
await sock.newsletterDelete(channelJid);

Keywords

whatsapp

FAQs

Package last updated on 28 Feb 2026

Related posts