npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dnuzi/baileys

v0.0.6

Published

WhatsApp Web API Library Modification By DanuZz.

Readme

@dnuzi/baileys

npm version License: MIT Node.js Version Downloads ESM only

@dnuzi/baileys is a cutting-edge, open-source Node.js library for seamless WhatsApp automation and integration. Built on WebSocket technology, it bypasses browser dependencies to deliver lightweight, high-performance connections. Ideal for developers crafting bots, chat automations, customer service platforms, and dynamic communication tools.

Developer: @DanuZz | Package: npmjs.com/package/@dnuzi/baileys


🙏 Credits & Attribution

[!NOTE] This project stands on the shoulders of those who came before it. Proper credit matters — always.

📦 Upstream & Original Authors

| Project | Author | Role | |---|---|---| | Baileys | @WhiskeySockets | Original upstream library |

✨ About This Fork

This fork builds upon @itsliaaa/baileys with a focus on production readiness and transparency.

Full credit for the foundational fork goes to @itsliaaa — this project would not exist without their work.

[!IMPORTANT] If you fork or redistribute this project, please:

  • ✅ Keep original attributions intact
  • ✅ Credit @itsliaaa for the fork base
  • ✅ Credit @WhiskeySockets for the upstream library
  • 🚫 Do not claim others' work as your own
  • 🚫 Do not rename and reupload without meaningful changes and proper credit

Made with 🤍 — because open source thrives on honesty.

⚙️ Changes from Upstream

🛠️ Internal Adjustments

  • 🖼️ Fixed an issue where media could not be sent to newsletters due to an upstream issue.
  • 📁 Reintroduced makeInMemoryStore with a minimal ESM adaptation and small adjustments for Baileys v7.
  • 📦 Switched FFmpeg execution from exec to spawn for safer process handling.
  • 🗃️ Added @napi-rs/image as a supported image processing backend in getImageProcessingLibrary(), offering a balance between performance and compatibility.

📨 Message Handling & Compatibility

  • 👉 Added support for sending interactive message types (button, list, interactive, template, carousel).
  • 📩 Added support for:
    • 🖼️ Album messages
    • 👤 Group status messages
    • 🎞️ Status mention messages
    • 📦 Sticker pack messages
    • 🗓️ Event messages [NEW]
    • ✨ Rich response messages [NEW]
    • 🧾 Messages with code blocks [NEW]
    • 📋 Messages with tables [NEW]
    • 📊 Poll update messages [NEW]
    • 💭 Button/list/flow response messages [NEW]
    • 💳 Payment-related messages (request payment, payment invite, order, invoice)
  • 📰 Simplified sending messages with ad thumbnails via externalAdReply without requiring manual contextInfo.
  • 💭 Added support for quoting messages inside channels (newsletters).

🧩 Additional Message Options

  • 👁️ Added optional boolean flags:
    • 🤖 ai — AI icon on message
    • 📣 mentionAll — Mention all group participants without requiring JIDs [NEW]
    • 🔧 ephemeral, groupStatus, viewOnce, viewOnceV2, viewOnceV2Extension, interactiveAsTemplate — Message wrappers
    • 🔒 secureMetaServiceLabel — Secure meta service label on message [NEW]
    • 📄 raw — Build your message manually (DO NOT USE FOR EXPLOITATION)

📋 Index


📥 Installation

# npm
npm install @dnuzi/baileys

# yarn
yarn add @dnuzi/baileys

# pnpm
pnpm add @dnuzi/baileys

Via package.json:

{
  "dependencies": {
    "@dnuzi/baileys": "latest"
  }
}

Requirements: Node.js ≥ 20.x


🧩 Import (ESM & CJS)

// ESM
import { makeWASocket } from '@dnuzi/baileys'

// CJS (tested and working on Node.js 24 ✅)
const { makeWASocket } = require('@dnuzi/baileys')

🌐 Connect to WhatsApp

import { makeWASocket, delay, DisconnectReason, useMultiFileAuthState } from '@dnuzi/baileys'
import { Boom } from '@hapi/boom'
import pino from 'pino'

const myPhoneNumber = '9488888888888'
const logger = pino({ level: 'silent' })

const connectToWhatsApp = async () => {
  const { state, saveCreds } = await useMultiFileAuthState('session')

  const sock = makeWASocket({ logger, auth: state })

  sock.ev.on('creds.update', saveCreds)

  sock.ev.on('connection.update', async (update) => {
    const { connection, lastDisconnect } = update
    if (connection === 'connecting' && !sock.authState.creds.registered) {
      await delay(1500)
      const code = await sock.requestPairingCode(myPhoneNumber)
      console.log('🔗 Pairing code:', code)
    } else if (connection === 'close') {
      const shouldReconnect = new Boom(lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
      console.log('⚠️ Connection closed, reconnecting:', shouldReconnect)
      if (shouldReconnect) connectToWhatsApp()
    } else if (connection === 'open') {
      console.log('✅ Successfully connected to WhatsApp')
    }
  })

  sock.ev.on('messages.upsert', async ({ messages }) => {
    for (const message of messages) {
      if (!message.message) continue
      console.log('🔔 Got new message:', message)
      await sock.sendMessage(message.key.remoteJid, { text: '👋🏻 Hello world' })
    }
  })
}

connectToWhatsApp()

🗄️ Implementing a Data Store

[!CAUTION] Keeping an entire chat history in memory can lead to excessive RAM usage. Build your own data store for production.

import { makeWASocket, makeInMemoryStore, useMultiFileAuthState } from '@dnuzi/baileys'
import pino from 'pino'

const storePath = './store.json'
const logger = pino({ level: 'silent' })

const connectToWhatsApp = async () => {
  const { state, saveCreds } = await useMultiFileAuthState('session')
  const sock = makeWASocket({ logger, auth: state })

  const store = makeInMemoryStore({ logger, socket: sock })
  store.bind(sock.ev)

  sock.ev.on('creds.update', saveCreds)

  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))
  })

  // Read store from file on startup
  store.readFromFile(storePath)

  // Auto-save every 3 minutes
  setInterval(() => store.writeToFile(storePath), 180000)
}

connectToWhatsApp()

🪪 WhatsApp IDs (JID) Formats

| Type | Format | |------|--------| | Private chat | [email protected] | | LID | 12699999999@lid | | Group | [email protected] | | Meta AI | 11111111111@bot | | Broadcast | [timestamp]@broadcast | | Stories | status@broadcast | | Newsletter | 1234XXXX@newsletter |


✉️ Sending Messages

[!NOTE] You can get the jid from message.key.remoteJid.

🔠 Text

sock.sendMessage(jid, {
  text: '👋🏻 Hello'
}, {
  quoted: message
})

🔔 Mention

// Regular mention
sock.sendMessage(jid, {
  text: '👋🏻 Hello @948123456789',
  mentions: ['[email protected]']
}, {
  quoted: message
})

// Mention all (no JIDs needed)
sock.sendMessage(jid, {
  text: '👋🏻 Hello @all',
  mentionAll: true
}, {
  quoted: message
})

😁 Reaction

sock.sendMessage(jid, {
  react: {
    key: message.key,
    text: '✨'
  }
})

📌 Pin Message

sock.sendMessage(jid, {
  pin: message.key,
  time: 86400, // 86400 (1d), 604800 (7d), 2592000 (30d)
  type: 1      // 0 to unpin
})

➡️ Forward Message

sock.sendMessage(jid, {
  forward: message,
  force: true // Optional
})

👤 Contact

const vcard = 'BEGIN:VCARD\n'
            + 'VERSION:3.0\n'
            + 'FN:DanuZz\n'
            + 'ORG:Waitress;\n'
            + 'TEL;type=CELL;type=VOICE;waid=948123456789:+62 8123 4567 89\n'
            + 'END:VCARD'

sock.sendMessage(jid, {
  contacts: {
    displayName: 'Dnuzi',
    contacts: [{ vcard }]
  }
}, {
  quoted: message
})

📍 Location

sock.sendMessage(jid, {
  location: {
    degreesLatitude: 24.121231,
    degreesLongitude: 55.1121221,
    name: '👋🏻 I am here'
  }
}, {
  quoted: message
})

🗓️ Event

sock.sendMessage(jid, {
  event: {
    name: '🎶 Meet & Mingle Party',
    description: 'Meet & Mingle Party is a fun, casual gathering to connect, chat, and build new relationships within the community.',
    call: 'audio', // Or "video", this field is optional
    startDate: new Date(Date.now() + 3600000),
    endDate: new Date(Date.now() + 28800000),
    isCancelled: false,        // Optional
    isScheduleCall: false,     // Optional
    extraGuestsAllowed: false, // Optional
    location: {
      name: 'Sri Lanka',
      degreesLatitude: -6.2,
      degreesLongitude: 106.8
    }
  }
}, {
  quoted: message
})

👥 Group Invite

const inviteCode = groupUrl.split('chat.whatsapp.com/')[1]?.split('?')[0]

sock.sendMessage(jid, {
  groupInvite: {
    inviteCode,
    inviteExpiration: Date.now() + 86400000,
    text: '👋🏻 Hello, we invite you to join our group.',
    jid: '[email protected]',
    subject: '@dnuzi/baileys',
  }
}, {
  quoted: message
})

🛍️ Product

import { randomUUID } from 'crypto'

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  body: '👋🏻 Check my product here!',
  footer: '@dnuzi/baileys',
  product: {
    currencyCode: 'IDR',
    description: '🛍️ Interesting product!',
    priceAmount1000: 70_000_000,
    productId: randomUUID(),
    productImageCount: 1,
    salePriceAmount1000: 65_000_000,
    signedUrl: 'https://npmjs.com/package/@dnuzi/baileys',
    title: '📦 My Product (Premium)',
    url: 'https://npmjs.com/package/@dnuzi/baileys'
  },
  businessOwnerJid: '[email protected]'
})

📊 Polls

// Regular poll
sock.sendMessage(jid, {
  poll: {
    name: '🔥 Voting time',
    values: ['Yes', 'No'],
    selectableCount: 1,
    toAnnouncementGroup: false
  }
}, {
  quoted: message
})

// Quiz (newsletter only)
sock.sendMessage('1211111111111@newsletter', {
  poll: {
    name: '🔥 Quiz',
    values: ['Yes', 'No'],
    correctAnswer: 'Yes',
    pollType: 1
  }
})

// Poll result
sock.sendMessage(jid, {
  pollResult: {
    name: '📝 Poll Result',
    votes: [
      { name: 'Nice', voteCount: 10 },
      { name: 'Nah', voteCount: 2 }
    ],
    pollType: 0 // 1 for quiz
  }
})

// Poll update
sock.sendMessage(jid, {
  pollUpdate: {
    metadata: {},
    key: message.key,
    vote: {
      enclv: /* <Buffer> */,
      encPayload: /* <Buffer> */
    }
  }
}, {
  quoted: message
})

💭 Button Response

// Using buttonsResponseMessage
sock.sendMessage(jid, {
  type: 'plain',
  buttonReply: {
    id: '#Menu',
    displayText: '✨ Interesting Menu'
  }
}, {
  quoted: message
})

// Using interactiveResponseMessage
sock.sendMessage(jid, {
  flowReply: {
    format: 0,
    text: '💭 Response',
    name: 'menu_options',
    paramsJson: JSON.stringify({
      id: '#Menu',
      description: '✨ Interesting Menu'
    })
  }
}, {
  quoted: message
})

// Using listResponseMessage
sock.sendMessage(jid, {
  listReply: {
    title: '📄 See More',
    description: '✨ Interesting Menu',
    id: '#Menu'
  }
}, {
  quoted: message
})

// Using templateButtonReplyMessage
sock.sendMessage(jid, {
  type: 'template',
  buttonReply: {
    id: '#Menu',
    displayText: '✨ Interesting Menu',
    index: 1
  }
}, {
  quoted: message
})

🎞️ Status Mention

sock.sendMessage([jidA, jidB, jidC], {
  text: 'Hello! 👋🏻'
})

📁 Sending Media Messages

[!NOTE] For media, you can pass a Buffer, { stream: Readable }, or { url: string } (local path or HTTP/HTTPS URL).

🖼️ Image

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '🔥 Superb'
}, {
  quoted: message
})

🎥 Video

sock.sendMessage(jid, {
  video: { url: './path/to/video.mp4' },
  gifPlayback: false, // true → send as GIF
  ptv: false,         // true → Picture-in-Picture (PTV)
  caption: '🔥 Superb'
}, {
  quoted: message
})

📃 Sticker

sock.sendMessage(jid, {
  sticker: { url: './path/to/sticker.webp' }
}, {
  quoted: message
})

💽 Audio

sock.sendMessage(jid, {
  audio: { url: './path/to/audio.mp3' },
  ptt: false // true → Voice Note
}, {
  quoted: message
})

🗂️ Document

sock.sendMessage(jid, {
  document: { url: './path/to/document.pdf' },
  mimetype: 'application/pdf',
  caption: '✨ My work!'
}, {
  quoted: message
})

🖼️ Album (Image & Video)

sock.sendMessage(jid, {
  album: [{
    image: { url: './path/to/image.jpg' },
    caption: '1st image'
  }, {
    video: { url: './path/to/video.mp4' },
    caption: '1st video'
  }, {
    image: { url: './path/to/image.jpg' },
    caption: '2nd image'
  }, {
    video: { url: './path/to/video.mp4' },
    caption: '2nd video'
  }]
}, {
  quoted: message
})

📦 Sticker Pack

[!IMPORTANT] If sharp or @napi-rs/image is not installed, cover and stickers must already be in WebP format.

sock.sendMessage(jid, {
  cover: { url: './path/to/cover.webp' },
  stickers: [
    { data: { url: './path/to/s1.webp' } },
    { data: { url: './path/to/s2.webp' } },
    { data: { url: './path/to/s3.webp' } }
  ],
  name: '📦 My Sticker Pack',
  publisher: '🌟 DanuZz',
  description: '@dnuzi/baileys'
}, {
  quoted: message
})

👉 Sending Interactive Messages

1️⃣ Buttons

// Simple buttons
sock.sendMessage(jid, {
  text: '👆🏻 Buttons!',
  footer: '@dnuzi/baileys',
  buttons: [{
    text: '👋🏻 SignUp',
    id: '#SignUp'
  }]
}, {
  quoted: message
})

// Buttons with media & native flow sections
sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '👆🏻 Buttons and Native Flow!',
  footer: '@dnuzi/baileys',
  buttons: [{
    text: '👋🏻 Rating',
    id: '#Rating'
  }, {
    text: '📋 Select',
    sections: [{
      title: '✨ Section 1',
      rows: [{
        header: '',
        title: '💭 Secret Ingredient',
        description: '',
        id: '#SecretIngredient'
      }]
    }, {
      title: '✨ Section 2',
      highlight_label: '🔥 Popular',
      rows: [{
        header: '',
        title: '🏷️ Coupon',
        description: '',
        id: '#CouponCode'
      }]
    }]
  }]
}, {
  quoted: message
})

2️⃣ List

[!NOTE] List messages only work in private chat (@s.whatsapp.net).

sock.sendMessage(jid, {
  text: '📋 List!',
  footer: '@dnuzi/baileys',
  buttonText: '📋 Select',
  title: '👋🏻 Hello',
  sections: [{
    title: '🚀 Menu 1',
    rows: [{
      title: '✨ AI',
      description: '',
      rowId: '#AI'
    }]
  }, {
    title: '🌱 Menu 2',
    rows: [{
      title: '🔍 Search',
      description: '',
      rowId: '#Search'
    }]
  }]
}, {
  quoted: message
})

3️⃣ Interactive (Native Flow)

// Native Flow
sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '🗄️ Interactive!',
  footer: '@dnuzi/baileys',
  optionText: '👉🏻 Select Options',   // Wraps all native flow into a single list
  optionTitle: '📄 Select Options',
  offerText: '🏷️ Newest Coupon!',
  offerCode: '@dnuzi/baileys',
  offerUrl: 'https://npmjs.com/package/@dnuzi/baileys',
  offerExpiration: Date.now() + 3_600_000,
  nativeFlow: [{
    text: '👋🏻 Greeting',
    id: '#Greeting',
    icon: 'review' // Optional
  }, {
    text: '📞 Call',
    call: '948123456789'
  }, {
    text: '📋 Copy',
    copy: '@dnuzi/baileys'
  }, {
    text: '🌐 Source',
    url: 'https://npmjs.com/package/@dnuzi/baileys',
    useWebview: true // Optional
  }, {
    text: '📋 Select',
    sections: [{
      title: '✨ Section 1',
      rows: [{ header: '', title: '🏷️ Coupon', description: '', id: '#CouponCode' }]
    }, {
      title: '✨ Section 2',
      highlight_label: '🔥 Popular',
      rows: [{ header: '', title: '💭 Secret Ingredient', description: '', id: '#SecretIngredient' }]
    }],
    icon: 'default' // Optional
  }],
  interactiveAsTemplate: false // Optional
}, {
  quoted: message
})

4️⃣ Carousel

sock.sendMessage(jid, {
  text: '🗂️ Interactive with Carousel!',
  footer: '@dnuzi/baileys',
  cards: [{
    image: { url: './path/to/image.jpg' },
    caption: '🖼️ Image 1',
    footer: '🏷️ Pinterest',
    nativeFlow: [{
      text: '🌐 Source',
      url: 'https://npmjs.com/package/@dnuzi/baileys',
      useWebview: true
    }]
  }, {
    image: { url: './path/to/image.jpg' },
    caption: '🖼️ Image 2',
    footer: '🏷️ Pinterest',
    offerText: '🏷️ New Coupon!',
    offerCode: '@dnuzi/baileys',
    offerUrl: 'https://npmjs.com/package/@dnuzi/baileys',
    offerExpiration: Date.now() + 3_600_000,
    nativeFlow: [{
      text: '🌐 Source',
      url: 'https://npmjs.com/package/@dnuzi/baileys'
    }]
  }, {
    image: { url: './path/to/image.jpg' },
    caption: '🖼️ Image 3',
    footer: '🏷️ Pinterest',
    optionText: '👉🏻 Select Options',
    optionTitle: '📄 Select Options',
    offerText: '🏷️ New Coupon!',
    offerCode: '@dnuzi/baileys',
    offerExpiration: Date.now() + 3_600_000,
    nativeFlow: [{
      text: '🛒 Product',
      id: '#Product',
      icon: 'default'
    }, {
      text: '🌐 Source',
      url: 'https://npmjs.com/package/@dnuzi/baileys'
    }]
  }]
}, {
  quoted: message
})

5️⃣ Hydrated Template

sock.sendMessage(jid, {
  title: '👋🏻 Hello',
  image: { url: './path/to/image.jpg' },
  caption: '🫙 Template!',
  footer: '@dnuzi/baileys',
  templateButtons: [{
    text: '👉🏻 Tap Here',
    id: '#Order'
  }, {
    text: '🌐 Source',
    url: 'https://npmjs.com/package/@dnuzi/baileys'
  }, {
    text: '📞 Call',
    call: '948123456789'
  }]
}, {
  quoted: message
})

✨ Rich & Structured Messages

✨ Rich Response

[!NOTE] richResponse[] is a representation of submessages[] inside richResponseMessage. You can still use the original submessages[] field directly — the helper below is optional.

sock.sendMessage(jid, {
  richResponse: [{
    text: 'Example Usage',
  }, {
    language: 'javascript',
    code: [{
      highlightType: 0,
      codeContent: 'console.log("Hello, World!")'
    }]
  }, {
    text: 'Pretty simple, right?\n'
  }, {
    text: 'Comparison between Node.js, Bun, and Deno',
  }, {
    title: 'Runtime Comparison',
    table: [{
      isHeading: true,
      items: ['', 'Node.js', 'Bun', 'Deno']
    }, {
      isHeading: false,
      items: ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)']
    }, {
      isHeading: false,
      items: ['Performance', '4/5', '5/5', '4/5']
    }]
  }, {
    text: 'Does this help clarify the differences?'
  }]
})

[!TIP] You can add syntax highlighting by importing tokenizeCode directly from the package.

import { tokenizeCode } from '@dnuzi/baileys'

const language = 'javascript'
const code = 'console.log("Hello, World!")'

sock.sendMessage(jid, {
  richResponse: [{
    text: 'Example Usage',
  }, {
    language,
    code: tokenizeCode(code, language)
  }, {
    text: 'Pretty simple, right?'
  }]
})

🧾 Message with Code Block

[!NOTE] This feature already includes a built-in tokenizer.

sock.sendMessage(jid, {
  headerText: '## Example Usage',
  contentText: '---',
  code: 'console.log("Hello, World!")',
  language: 'javascript',
  footerText: 'Pretty simple, right?'
})

🌏 Message with Inline Entities

sock.sendMessage(jid, {
  headerText: '## Check Out!',
  contentText: '---',
  links: [{
    text: '1. Google',
    title: 'Popular Search Engine',
    url: 'https://www.google.com/'
  }, {
    text: '2. YouTube',
    title: 'Popular Streaming Platform',
    url: 'https://www.youtube.com/'
  }, {
    text: '3. @dnuzi/baileys',
    title: 'WhatsApp Automation Library',
    url: 'https://npmjs.com/package/@dnuzi/baileys'
  }],
  footerText: '---'
})

📋 Message with Table

sock.sendMessage(jid, {
  headerText: '## Comparison between Node.js, Bun, and Deno',
  contentText: '---',
  title: 'Runtime Comparison',
  table: [
    ['', 'Node.js', 'Bun', 'Deno'],
    ['Engine', 'V8 (C++)', 'JavaScriptCore (C++)', 'V8 (C++)'],
    ['Performance', '4/5', '5/5', '4/5']
  ],
  noHeading: false, // Optional
  footerText: 'Does this help clarify the differences?'
})

💳 Sending Payment Messages

1️⃣ Payment Invite

sock.sendMessage(jid, {
  paymentInviteServiceType: 3 // 1, 2, or 3
})

2️⃣ Invoice

[!NOTE] Invoice messages are not fully supported yet.

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  invoiceNote: '🏷️ Invoice'
})

3️⃣ Order

sock.sendMessage(jid, {
  orderText: '🛍️ Order',
  thumbnail: fs.readFileSync('./path/to/image.jpg') // Must be Buffer
}, {
  quoted: message
})

4️⃣ Request Payment

sock.sendMessage(jid, {
  text: '💳 Request Payment',
  requestPaymentFrom: '[email protected]'
})

👁️ Other Message Options

1️⃣ AI Label

[!NOTE] Only works in private chat (@s.whatsapp.net).

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '🤖 AI Labeled!',
  ai: true
}, {
  quoted: message
})

2️⃣ Ephemeral

[!NOTE] Wraps message into ephemeralMessage.

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '👁️ Ephemeral',
  ephemeral: true
})

3️⃣ External Ad Reply

[!NOTE] Adds an ad thumbnail to messages (may not be displayed on all WhatsApp versions).

sock.sendMessage(jid, {
  text: '📰 External Ad Reply',
  externalAdReply: {
    title: '📝 Did you know?',
    body: '❓ I dont know',
    thumbnail: fs.readFileSync('./path/to/image.jpg'), // Must be Buffer
    largeThumbnail: false,
    url: 'https://npmjs.com/package/@dnuzi/baileys' // Optional
  }
}, {
  quoted: message
})

4️⃣ Group Status

[!NOTE] Only works in group chat (@g.us).

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '👥 Group Status!',
  groupStatus: true
})

5️⃣ Raw

sock.sendMessage(jid, {
  extendedTextMessage: {
    text: '📃 Built manually from scratch using the raw WhatsApp proto structure',
    contextInfo: {
      externalAdReply: {
        title: '@dnuzi/baileys',
        thumbnail: fs.readFileSync('./path/to/image.jpg'),
        sourceApp: 'whatsapp',
        showAdAttribution: true,
        mediaType: 1
      }
    }
  },
  raw: true
}, {
  quoted: message
})

6️⃣ Secure Meta Service Label

sock.sendMessage(jid, {
  text: '🏷️ Just a label!',
  secureMetaServiceLabel: true
})

7️⃣ View Once

[!NOTE] Wraps message into viewOnceMessage.

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '👁️ View Once',
  viewOnce: true
})

8️⃣ View Once V2

[!NOTE] Wraps message into viewOnceMessageV2.

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '👁️ View Once V2',
  viewOnceV2: true
})

9️⃣ View Once V2 Extension

[!NOTE] Wraps message into viewOnceMessageV2Extension.

sock.sendMessage(jid, {
  image: { url: './path/to/image.jpg' },
  caption: '👁️ View Once V2 Extension',
  viewOnceV2Extension: true
})

♻️ Modify Messages

🗑️ Delete Messages

sock.sendMessage(jid, {
  delete: message.key
})

✏️ Edit Messages

// Edit plain text
sock.sendMessage(jid, {
  text: '✨ I mean, nice!',
  edit: message.key
})

// Edit media caption
sock.sendMessage(jid, {
  caption: '✨ I mean, here is the image!',
  edit: message.key
})

🧰 Additional Utilities

🏷️ Find User ID (JID / LID)

[!NOTE] The ID must contain numbers only (no +, (), or -) and must include the country code.

// By phone number
const ids = await sock.findUserId('[email protected]')

// By LID
const ids = await sock.findUserId('43411111111111@lid')

console.log(ids)
// Output: { phoneNumber: '[email protected]', lid: '43411111111111@lid' }
// On failure: { phoneNumber: '...', lid: 'id-not-found' }

🔑 Custom Pairing Code

[!NOTE] Phone number must contain numbers only, no +, (), or -.

const phoneNumber = '9481111111111'
const customPairingCode = 'STARFALL'

await sock.requestPairingCode(phoneNumber, customPairingCode)
console.log('🔗 Pairing code:', customPairingCode)

🖼️ Image Processing

[!NOTE] Automatically uses the best available image processing library: sharp, @napi-rs/image, or jimp.

import { getImageProcessingLibrary } from '@dnuzi/baileys'
import { readFile } from 'fs/promises'

const lib = await getImageProcessingLibrary()
const bufferOrFilePath = './path/to/image.jpg'
const width = 512
let output

// If sharp is installed
if (lib.sharp?.default) {
  const img = lib.sharp.default(bufferOrFilePath)
  output = await img.resize(width).jpeg({ quality: 80 }).toBuffer()
}

// If @napi-rs/image is installed
else if (lib.image?.Transformer) {
  const inputBuffer = Buffer.isBuffer(bufferOrFilePath)
    ? bufferOrFilePath
    : await readFile(bufferOrFilePath)
  const img = new lib.image.Transformer(inputBuffer)
  output = await img.resize(width, undefined, 0).jpeg(50)
}

// If jimp is installed
else if (lib.jimp?.Jimp) {
  const img = await lib.jimp.Jimp.read(bufferOrFilePath)
  output = await img
    .resize({ w: width, mode: lib.jimp.ResizeStrategy.BILINEAR })
    .getBuffer('image/jpeg', { quality: 50 })
}

// Fallback
else {
  throw new Error('No image processing library available')
}

console.log('✅ Process completed!')
console.dir(output, { depth: null })

📣 Newsletter Management

// Create
sock.newsletterCreate('@dnuzi/baileys', '📣 Fresh updates weekly')

// Get info
const metadata = await sock.newsletterMetadata('1231111111111@newsletter')
console.dir(metadata, { depth: null })

// Get subscribers count
const subscribers = await sock.newsletterSubscribers('1231111111111@newsletter')
console.dir(subscribers, { depth: null })

// Follow and Unfollow
sock.newsletterFollow('1231111111111@newsletter')
sock.newsletterUnfollow('1231111111111@newsletter')

// Mute and Unmute
sock.newsletterMute('1231111111111@newsletter')
sock.newsletterUnmute('1231111111111@newsletter')

// Demote admin
sock.newsletterDemote('1231111111111@newsletter', '[email protected]')

// Change owner
sock.newsletterChangeOwner('1231111111111@newsletter', '[email protected]')

// Update name & description
sock.newsletterUpdateName('1231111111111@newsletter', '📦 @dnuzi/baileys')
sock.newsletterUpdateDescription('1231111111111@newsletter', '📣 Fresh updates weekly')

// Update / remove photo
sock.newsletterUpdatePicture('1231111111111@newsletter', { url: './image.jpg' })
sock.newsletterRemovePicture('1231111111111@newsletter')

// React to a message
sock.newsletterReactMessage('1231111111111@newsletter', '100', '💛')

// Get admin count
const count = await sock.newsletterAdminCount('1231111111111@newsletter')

// Get all subscribed newsletters
const newsletters = await sock.newsletterSubscribed()
console.dir(newsletters, { depth: null })

// Fetch messages
const messages = sock.newsletterFetchMessages('jid', '1231111111111@newsletter', 50, 0, 0)
console.dir(messages, { depth: null })

// Delete newsletter
sock.newsletterDelete('1231111111111@newsletter')

👥 Group Management

// Create and add participants
const group = await sock.groupCreate('@dnuzi/baileys', ['[email protected]'])
console.dir(group, { depth: null })

// Get info
const metadata = await sock.groupMetadata(jid)
console.dir(metadata, { depth: null })

// Invite management
sock.groupInviteCode(jid)
sock.groupRevokeInvite(jid)
sock.groupAcceptInvite(inviteCode)
sock.groupLeave(jid)

// Get group info from invite link
const group = await sock.groupGetInviteInfo('https://chat.whatsapp.com/ABC123')
console.log('👥 Got group info from link:', group)

// Members
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'add')
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'remove')
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'promote')
sock.groupParticipantsUpdate(jid, ['[email protected]'], 'demote')

// Accept join requests
sock.groupRequestParticipantsUpdate(jid, ['[email protected]'], 'approve')

// Update info
sock.groupUpdateSubject(jid, '📦 @dnuzi/baileys')
sock.groupUpdateDescription(jid, 'Updated description')
sock.updateProfilePicture(jid, { url: './image.jpg' })
sock.removeProfilePicture(jid)

// Settings
sock.groupSettingUpdate(jid, 'announcement')      // Admin only chat
sock.groupSettingUpdate(jid, 'not_announcement')  // Open chat
sock.groupSettingUpdate(jid, 'locked')            // Admin only info edit
sock.groupSettingUpdate(jid, 'unlocked')          // All can edit info
sock.groupMemberAddMode(jid, 'admin_add')         // Admin only can add
sock.groupMemberAddMode(jid, 'all_member_add')    // All can add

// Disappearing messages
sock.groupToggleEphemeral(jid, 86400) // Enable (1 day)
sock.groupToggleEphemeral(jid, 0)     // Disable

// Approval mode
sock.groupJoinApprovalMode(jid, 'on')
sock.groupJoinApprovalMode(jid, 'off')

// Fetch all participating groups
const groups = await sock.groupFetchAllParticipating()
console.dir(groups, { depth: null })

// Get pending join requests
const requests = await sock.groupRequestParticipantsList(jid)
console.dir(requests, { depth: null })

// Update bot member label
sock.updateMemberLabel(jid, '@dnuzi/baileys')

👤 Profile Management

// Get profile picture URL
const url = await sock.profilePictureUrl(jid, 'image')
console.log('🖼️ Got profile url:', url)

// Update / remove profile picture
sock.updateProfilePicture(jid, buffer)
sock.updateProfilePicture(jid, { url })
sock.removeProfilePicture(jid)

// Update name and status
sock.updateProfileName('My Name')
sock.updateProfileStatus('Available')

// Presence
sock.sendPresenceUpdate('available', jid)
sock.presenceSubscribe(jid)

// Read receipts
sock.readMessages([message.key])
sock.sendReceipt(jid, participant, [messageId], 'read')

// Block / Unblock
sock.updateBlockStatus(jid, 'block')
sock.updateBlockStatus(jid, 'unblock')

// Fetch blocklist
const blocked = await sock.fetchBlocklist()
console.dir(blocked, { depth: null })

// Modify chats
sock.chatModify({ archive: true, lastMessageOrig: message, lastMessage: message }, jid)

// Star messages
sock.star(jid, [{ id: messageId, fromMe: true }], true)

// Contacts
sock.addOrEditContact(jid, { displayName: 'DanuZz' })
sock.removeContact(jid)

// Labels
sock.addChatLabel(jid, labelId)
sock.removeChatLabel(jid, labelId)
sock.addMessageLabel(jid, messageId, labelId)

// App state sync
sock.resyncAppState(['regular', 'critical_block'], true)

// Business profile
const profile = await sock.getBusinessProfile(jid)
console.dir(profile, { depth: null })

🔐 Privacy Management

// Last seen
sock.updateLastSeenPrivacy('all')
sock.updateLastSeenPrivacy('contacts')
sock.updateLastSeenPrivacy('contact_blacklist')
sock.updateLastSeenPrivacy('nobody')

// Online status
sock.updateOnlinePrivacy('all')
sock.updateOnlinePrivacy('match_last_seen')

// Profile picture
sock.updateProfilePicturePrivacy('contacts')

// Status
sock.updateStatusPrivacy('contacts')

// Read receipts
sock.updateReadReceiptsPrivacy('all')
sock.updateReadReceiptsPrivacy('none')

// Groups
sock.updateGroupsAddPrivacy('all')
sock.updateGroupsAddPrivacy('contacts')

// Messages
sock.updateMessagesPrivacy('all')
sock.updateMessagesPrivacy('contacts')
sock.updateMessagesPrivacy('nobody')

// Calls
sock.updateCallPrivacy('everyone')

// Default disappearing mode
sock.updateDefaultDisappearingMode(86400)

// Link previews
sock.updateDisableLinkPreviewsPrivacy(true)

📡 Events

sock.ev.on('connection.update', (update) => {})
sock.ev.on('creds.update', (update) => {})
sock.ev.on('messaging-history.set', (update) => {})
sock.ev.on('messaging-history.status', (update) => {})
sock.ev.on('chats.upsert', (update) => {})
sock.ev.on('chats.update', (update) => {})
sock.ev.on('chats.delete', (update) => {})
sock.ev.on('chats.lock', (update) => {})
sock.ev.on('lid-mapping.update', (update) => {})
sock.ev.on('presence.update', (update) => {})
sock.ev.on('contacts.upsert', (update) => {})
sock.ev.on('contacts.update', (update) => {})
sock.ev.on('messages.delete', (update) => {})
sock.ev.on('messages.update', (update) => {})
sock.ev.on('messages.media-update', (update) => {})
sock.ev.on('messages.upsert', (update) => {})
sock.ev.on('messages.reaction', (update) => {})
sock.ev.on('message-receipt.update', (update) => {})
sock.ev.on('groups.upsert', (update) => {})
sock.ev.on('groups.update', (update) => {})
sock.ev.on('group-participants.update', (update) => {})
sock.ev.on('group.join-request', (update) => {})
sock.ev.on('group.member-tag.update', (update) => {})
sock.ev.on('blocklist.set', (update) => {})
sock.ev.on('blocklist.update', (update) => {})
sock.ev.on('call', (update) => {})
sock.ev.on('labels.edit', (update) => {})
sock.ev.on('labels.association', (update) => {})
sock.ev.on('newsletter.reaction', (update) => {})
sock.ev.on('newsletter.view', (update) => {})
sock.ev.on('newsletter-participants.update', (update) => {})
sock.ev.on('newsletter-settings.update', (update) => {})
sock.ev.on('settings.update', (update) => {})

📦 Fork Base

[!NOTE] This fork is based on Baileys (GitHub)


📣 Credits

[!IMPORTANT] This fork uses Protocol Buffer definitions maintained by WPP Connect via wa-proto

Full credit goes to the original Baileys maintainers and contributors:

Additional enhancements and modifications by DanuZz

Credits are mandatory and must remain unchanged in any form of redistribution or fork.


📄 License

MIT © DanuZz — See LICENSE for details.


📞 Support & Contact

Built with ❤️ for the WhatsApp dev community. Let's automate the future! 🚀