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

@nozez-lab/baileys

v1.2.2

Published

Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.

Readme

⚡ @nozez-lab/baileys


📋 Table of Contents


✨ What's Different

@nozez-lab/baileys adalah library WhatsApp yang dikustomisasi untuk kebutuhan bot modern:

  • Native Interactive Messages — Buttons, Lists, Native Flows, Carousels, Templates
  • Album Support — Kirim gambar/video dalam satu album
  • Sticker Pack — Kirim sticker dalam satu paket
  • Pairing Code — Koneksi mudah tanpa QR Code
  • No Obfuscation — Kode bersih, mudah dibaca dan diaudit
  • No Auto-Follow — Tidak ada behavior channel (newsletter) otomatis

🔧 Internal Fixes

  • 🖼️ Perbaikan upload media ke newsletter (bug upstream)
  • 🔄 Reimplementasi makeInMemoryStore dengan adaptasi minimal ESM untuk Baileys v7
  • 📦 FFmpeg dijalankan dengan spawn bukan exec untuk keamanan proses
  • 🗃️ Penambahan @napi-rs/image sebagai backend image processing di getImageProcessingLibrary()
  • 💬 Dukungan quote message di dalam channel (newsletter)
  • 🎀 Dukungan custom button icon pada interactive messages

📦 Installation

Via package.json:

{
  "dependencies": {
    "@nozez-lab/baileys": "latest"
  }
}

Via terminal:

# Dari NPM
npm install @nozez-lab/baileys@latest

# Dari GitHub
npm install github:nozez-lab/baileys

🔌 Import (ESM & CJS)

// ESM
import { makeWASocket } from '@nozez-lab/baileys'

// CJS (Node.js 24+)
const { makeWASocket } = require('@nozez-lab/baileys')

🚀 Quick Start

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

const PHONE_NUMBER = '628xxxxxxxxxx'
const logger = pino({ level: 'silent' })

async function startBot() {
  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(PHONE_NUMBER)
      console.log('🔗 Pairing Code:', code)
    }

    if (connection === 'close') {
      const shouldReconnect =
        new Boom(lastDisconnect?.error)?.output?.statusCode !== DisconnectReason.loggedOut
      if (shouldReconnect) startBot()
    }

    if (connection === 'open') {
      console.log('✅ Connected to WhatsApp')
    }
  })

  sock.ev.on('messages.upsert', async ({ messages }) => {
    for (const msg of messages) {
      if (!msg.message) continue
      console.log('📩 New message:', msg)
    }
  })
}

startBot()

🔐 Auth State

[!NOTE] Kamu bisa menggunakan useSingleFileAuthState atau useSqliteAuthState sebagai alternatif dari useMultiFileAuthState. useSingleFileAuthState sudah memiliki mekanisme cache internal, sehingga tidak perlu membungkus state.keys dengan makeCacheableSignalKeyStore.


🗄️ Data Store

[!CAUTION] Sangat disarankan untuk membuat data store sendiri. Menyimpan seluruh riwayat chat di memori dapat menyebabkan penggunaan RAM yang berlebihan.

import {
  makeWASocket,
  makeInMemoryStore,
  delay,
  DisconnectReason,
  useMultiFileAuthState
} from '@nozez-lab/baileys'
import pino from 'pino'

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

async function startBot() {
  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('✉️ Chats:', store.chats.all())
  })

  store.readFromFile(STORE_PATH)
  setInterval(() => store.writeToFile(STORE_PATH), 180_000)
}

startBot()

🪪 WhatsApp IDs

| Tipe | Format | |------|--------| | Personal | [email protected] | | LID | 12699999999@lid | | Group | [email protected] | | Meta AI | 11111111111@bot | | Broadcast | [timestamp]@broadcast | | Status | status@broadcast |


✉️ Sending Messages

[!NOTE] Dapatkan jid dari message.key.remoteJid.

📝 Text

// Pesan teks biasa
sock.sendMessage(jid, { text: 'Halo! 👋' }, { quoted: message })

// Dengan link preview
sock.sendMessage(jid, {
  text: 'Cek ini! https://github.com/nozez-lab/baileys',
  linkPreview: {
    'matched-text': 'https://github.com/nozez-lab/baileys',
    title: '⚡ @nozez-lab/baileys',
    description: 'WhatsApp bot library by Nozez',
    previewType: 0
  }
})

🔔 Mention

// Mention user tertentu
sock.sendMessage(jid, {
  text: 'Halo @628123456789!',
  mentions: ['[email protected]']
}, { quoted: message })

// Mention semua anggota grup
sock.sendMessage(jid, {
  text: 'Halo @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 (1h), 604800 (7d), 2592000 (30d)
  type: 1      // 2 untuk unpin
})

➡️ Forward Message

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

👤 Contact

const vcard = [
  'BEGIN:VCARD',
  'VERSION:3.0',
  'FN:Nozez',
  'ORG:NozezLab;',
  'TEL;type=CELL;type=VOICE;waid=628123456789:+62 812-3456-789',
  'END:VCARD'
].join('\n')

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

📍 Location

sock.sendMessage(jid, {
  location: {
    degreesLatitude: -6.2,
    degreesLongitude: 106.8,
    name: 'Jakarta, Indonesia'
  }
}, { quoted: message })

📅 Event

sock.sendMessage(jid, {
  event: {
    name: '🎉 Community Meetup',
    description: 'Kumpul bareng komunitas Nozez!',
    startDate: new Date(Date.now() + 3600000),
    endDate: new Date(Date.now() + 28800000),
    location: {
      name: 'Jakarta',
      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: 'Gabung ke grup kita yuk!',
    jid: '[email protected]',
    subject: 'NozezLab Community'
  }
}, { quoted: message })

🛍️ Product

import { randomUUID } from 'crypto'

sock.sendMessage(jid, {
  image: { url: './product.jpg' },
  body: 'Cek produk ini!',
  footer: '@nozez-lab/baileys',
  product: {
    currencyCode: 'IDR',
    description: 'Produk pilihan terbaik',
    priceAmount1000: 50_000_000,
    productId: randomUUID(),
    productImageCount: 1,
    title: 'Premium Package',
    url: 'https://github.com/nozez-lab/baileys'
  },
  businessOwnerJid: '[email protected]'
})

📊 Poll

sock.sendMessage(jid, {
  poll: {
    name: '🔥 Vote sekarang!',
    values: ['Ya', 'Tidak'],
    selectableCount: 1,
    endDate: new Date(Date.now() + 28800000)
  }
}, { quoted: message })

🖼️ Media Messages

🖼️ Image

sock.sendMessage(jid, {
  image: { url: './gambar.jpg' },
  caption: 'Gambar keren! ✨'
}, { quoted: message })

🎥 Video

sock.sendMessage(jid, {
  video: { url: './video.mp4' },
  caption: 'Video keren!'
}, { quoted: message })

📃 Sticker

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

💽 Audio

sock.sendMessage(jid, {
  audio: { url: './audio.mp3' },
  mimetype: 'audio/mp4',
  ptt: true // true = pesan suara, false = file audio
}, { quoted: message })

🗂️ Document

sock.sendMessage(jid, {
  document: { url: './file.pdf' },
  mimetype: 'application/pdf',
  fileName: 'dokumen.pdf',
  caption: 'Ini dokumennya'
}, { quoted: message })

🖼️ Album

sock.sendMessage(jid, {
  album: [
    { image: { url: './foto1.jpg' }, caption: 'Foto 1' },
    { image: { url: './foto2.jpg' }, caption: 'Foto 2' },
    { video: { url: './video.mp4' }, caption: 'Video' }
  ]
}, { quoted: message })

👉 Interactive Messages

📘 Buttons

sock.sendMessage(jid, {
  image: { url: './banner.jpg' },
  body: 'Pilih menu di bawah ini:',
  footer: '@nozez-lab/baileys',
  buttons: [
    { id: '#menu', text: '📋 Menu Utama' },
    { id: '#info', text: 'ℹ️ Info' },
    { id: '#help', text: '🆘 Bantuan' }
  ]
}, { quoted: message })

📋 List

sock.sendMessage(jid, {
  body: 'Pilih salah satu opsi:',
  footer: '@nozez-lab/baileys',
  button: '📋 Lihat Menu',
  list: [
    {
      title: '🔧 Tools',
      rows: [
        { id: '#ping', title: 'Ping', description: 'Cek koneksi bot' },
        { id: '#info', title: 'Info', description: 'Info bot' }
      ]
    },
    {
      title: '🎮 Fun',
      rows: [
        { id: '#game', title: 'Game', description: 'Main game' }
      ]
    }
  ]
}, { quoted: message })

🗄️ Interactive

sock.sendMessage(jid, {
  body: 'Selamat datang!',
  footer: 'Powered by @nozez-lab/baileys',
  nativeFlowButtons: [
    {
      name: 'quick_reply',
      buttonParamsJson: JSON.stringify({ display_text: '⚡ Mulai', id: '#start' })
    },
    {
      name: 'cta_url',
      buttonParamsJson: JSON.stringify({
        display_text: '🔗 GitHub',
        url: 'https://github.com/nozez-lab/baileys'
      })
    }
  ]
}, { quoted: message })

♻️ Modify Messages

🗑️ Delete

// Hapus untuk semua
sock.sendMessage(jid, { delete: message.key })

✏️ Edit

sock.sendMessage(jid, {
  edit: message.key,
  text: 'Pesan yang sudah diedit ✏️'
})

🧰 Utilities

🔑 Custom Pairing Code

const code = await sock.requestPairingCode('628xxxxxxxxxx', 'NOZEZBOT')
console.log('🔑 Pairing Code:', code)

🖼️ Image Processing

import { getImageProcessingLibrary } from '@nozez-lab/baileys'

const lib = await getImageProcessingLibrary()
console.log('Library yang digunakan:', lib)

📣 Newsletter (Channel)

// Buat newsletter
const newsletter = await sock.createNewsLetter({
  name: 'Nozez Updates',
  description: 'Update terbaru dari Nozez',
  picture: fs.readFileSync('./logo.jpg')
})

// Kirim pesan ke newsletter
sock.sendMessage(newsletter.id, { text: '📢 Pengumuman baru!' })

👥 Group Management

// Buat grup
const group = await sock.groupCreate('Nama Grup', ['[email protected]'])

// Tambah anggota
await sock.groupParticipantsUpdate(group.id, ['[email protected]'], 'add')

// Kick anggota
await sock.groupParticipantsUpdate(group.id, ['[email protected]'], 'remove')

// Promosi admin
await sock.groupParticipantsUpdate(group.id, ['[email protected]'], 'promote')

👤 Profile Management

// Update nama
await sock.updateProfileName('Nozez Bot')

// Update status
await sock.updateProfileStatus('Ditenagai oleh @nozez-lab/baileys ⚡')

// Update foto profil
await sock.updateProfilePicture(sock.user.id, { url: './foto.jpg' })

🔏 Privacy

// Atur last seen
await sock.updateLastSeenPrivacy('contacts')

// Atur online
await sock.updateOnlinePrivacy('match_last_seen')

// Atur foto profil
await sock.updateProfilePicturePrivacy('contacts')

🔗 Fork Base

Proyek ini adalah fork dari:

WhiskeySockets/Baileys

Semua kredit untuk proyek asli tetap diberikan sepenuhnya. Fork ini menambahkan fitur-fitur tambahan yang dibutuhkan untuk pengembangan bot WhatsApp modern.


📣 Credits

| Kontribusi | Penulis | |-----------|---------| | Library Baileys Original | WhiskeySockets | | Fork & Kustomisasi | Nozez |