@vinzsocket/baileys
v3.2.5
Published
A WebSockets library for interacting with WhatsApp Web
Readme
Harps Baileys
A lightweight WebSocket library for WhatsApp Web Multi-Device
📖 Tentang Harps Baileys
Harps Baileys (@vinzsocket/baileys) adalah fork/modifikasi dari library Baileys yang dioptimalkan untuk performa tinggi dan kemudahan penggunaan.
Repository Resmi: https://github.com/VinzSocket/Baileys
Library ini memungkinkan kamu berinteraksi langsung dengan WhatsApp Web Multi-Device menggunakan WebSocket tanpa browser.
✨ Features
🔐 Authentication
- QR Code Login
- Pairing Code (tanpa scan QR)
- Multi-Device Support
- Session Management
- Auto Reconnect
💬 Messaging
- Text, Image, Video, Audio, Document, Sticker
- Reaction, Mention, Quoted Message
- View Once, Edit Message, Revoke Message
- Location, Contact, Poll
- List Message (flat & nested multi-section)
- Interactive Message — semua Native Flow V7 button shape
- Album, Event, Product, Request Payment
- Group Status V2 (group story)
👥 Group Management
- Create Group
- Update Subject, Description, PP
- Add/Remove Member
- Promote/Demote Admin
- Group Settings
🔒 Security
- End-to-End Encryption (Signal Protocol)
- Sender Key Distribution
🔄 Synchronization
- Chat, Contact, Group, Device & History Sync
- Presence (online, typing, etc.)
🛠️ Lainnya
- Media Upload/Download
- Link Preview
- Business API Support
- Full TypeScript Support
📦 Installation
npm install @vinzsocket/baileys🔔 Changelog v3.1.9
- fix(process-message): only drop self-only protocolMessages from non-self senders
- feat(dugong): tambah nested list (
nestedListMessage) — list yang isinya ada list lagi - feat(dugong): export semua Native Flow V7 button builder (
nfButtonUrl,nfButtonCall,nfButtonCopy,nfButtonReminder,nfButtonCancelReminder,nfButtonAddress,nfButtonLocation,nfButtonQuickReply,nfButtonSingleSelect,nfButtonReviewPay,nfButtonReviewOrder,nfButtonMPM) - feat(messages-send): wire
NESTED_LISTcase kesendMessage()dengan properadditionalNodes
📨 Mengirim Pesan Interaktif
Semua interactive message dikirim lewat conn.sendMessage(). Untuk bot yang pakai simple.js, gunakan wrapper conn.sendInteractive() / conn.sendList() / conn.sendNestedList() sesuai kebutuhan.
Legacy List Message (sendList)
await conn.sendMessage(jid, {
listMessage: {
title: 'Pilih menu',
description: 'Footer pesan',
buttonText: '📋 Buka Menu',
listType: 1,
sections: [
{
title: '🎮 Kategori',
rows: [
{ rowId: 'rpg_shop', title: '🏪 Shop', description: 'Beli item' },
{ rowId: 'rpg_inv', title: '🎒 Inventory', description: 'Lihat inventory' }
]
}
]
}
})Nested List (list dalam list)
Gunakan nestedListMessage. Rows yang punya field rows sendiri akan otomatis di-flatten jadi section baru.
await conn.sendMessage(jid, {
nestedListMessage: {
title: '🛒 Pilih Kategori & Item',
buttonText: '📋 Buka Menu',
footer: 'Harps-MD Shop',
sections: [
{
title: '⚔️ Senjata',
rows: [
// flat row biasa
{ rowId: 'wpn_sword', title: '🗡️ Pedang', description: '50 ATK' },
// nested row → dijadikan section baru
{
title: '🏹 Senjata Jarak Jauh',
rows: [
{ rowId: 'wpn_bow', title: '🏹 Busur', description: '35 ATK' },
{ rowId: 'wpn_crossbow', title: '🔫 Crossbow', description: '45 ATK' }
]
}
]
},
{
title: '🛡️ Armor',
rows: [
{ rowId: 'arm_light', title: '👕 Light Armor', description: '20 DEF' },
{ rowId: 'arm_heavy', title: '🛡️ Heavy Armor', description: '50 DEF' }
]
}
]
}
})Hasil di WhatsApp: section "⚔️ Senjata" lalu section baru "🏹 Senjata Jarak Jauh" lalu "🛡️ Armor".
⚡ Native Flow V7 Button Builders
Import langsung dari library:
import {
nfButtonUrl,
nfButtonCall,
nfButtonCopy,
nfButtonReminder,
nfButtonCancelReminder,
nfButtonAddress,
nfButtonLocation,
nfButtonQuickReply,
nfButtonSingleSelect,
nfButtonReviewPay,
nfButtonReviewOrder,
nfButtonMPM
} from '@vinzsocket/baileys/lib/Socket/dugong.js'Semua Button Type
| Builder | name (proto) | Fungsi |
|---|---|---|
| nfButtonUrl | cta_url | Buka URL di browser |
| nfButtonCall | cta_call | Langsung telepon |
| nfButtonCopy | cta_copy | Salin teks/kode OTP |
| nfButtonReminder | cta_reminder | Set reminder di kalender |
| nfButtonCancelReminder | cta_cancel_reminder | Batalkan reminder |
| nfButtonAddress | address_message | Isi & kirim alamat |
| nfButtonLocation | send_location | Kirim lokasi GPS |
| nfButtonQuickReply | quick_reply | Balas cepat dengan payload |
| nfButtonSingleSelect | single_select | Dropdown / bottom sheet pilihan |
| nfButtonReviewPay | review_and_pay | Review & bayar order |
| nfButtonReviewOrder | review_order | Review order saja |
| nfButtonMPM | mpm | Tampilkan katalog produk |
Contoh: Tombol URL + Copy + Quick Reply
import { nfButtonUrl, nfButtonCopy, nfButtonQuickReply } from '@vinzsocket/baileys/lib/Socket/dugong.js'
await conn.sendMessage(jid, {
interactiveMessage: {
title: '✅ Verifikasi Akun',
footer: 'Harps-MD',
buttons: [
nfButtonUrl({
displayText: '🌐 Buka Website',
url: 'https://example.com'
}),
nfButtonCopy({
displayText: '📋 Salin Kode',
copyCode: 'ABC123'
}),
nfButtonQuickReply({
id: 'confirm_yes',
displayText: '✅ Konfirmasi'
})
]
}
})Contoh: Tombol Single-Select (Dropdown Bottom Sheet)
import { nfButtonSingleSelect } from '@vinzsocket/baileys/lib/Socket/dugong.js'
await conn.sendMessage(jid, {
interactiveMessage: {
title: '⚙️ Pilih Difficulty',
footer: 'RPG Game',
buttons: [
nfButtonSingleSelect({
displayText: '🎯 Pilih Level',
sections: [
{
title: '🟢 Mudah',
rows: [
{ id: 'diff_easy', title: 'Easy', description: 'Untuk pemula' },
{ id: 'diff_normal', title: 'Normal', description: 'Standar' }
]
},
{
title: '🔴 Susah',
rows: [
{ id: 'diff_hard', title: 'Hard', description: 'Untuk pro' },
{ id: 'diff_insane', title: 'Insane', description: 'GG' }
]
}
]
})
]
}
})Contoh: Interactive + Gambar
await conn.sendMessage(jid, {
interactiveMessage: {
title: '🎮 RPG Shop',
footer: 'Pilih item yang mau dibeli',
image: { url: 'https://example.com/shop.jpg' },
buttons: [
nfButtonQuickReply({ id: 'buy_sword', displayText: '🗡️ Beli Pedang' }),
nfButtonQuickReply({ id: 'buy_shield', displayText: '🛡️ Beli Tameng' }),
nfButtonUrl({ displayText: '📖 Lihat Katalog', url: 'https://example.com/catalog' })
]
}
})🧩 buildNestedListMessage (standalone)
Kalau mau build raw proto payload tanpa sendMessage:
import { buildNestedListMessage } from '@vinzsocket/baileys/lib/Socket/dugong.js'
const payload = buildNestedListMessage({
title: 'Menu Utama',
buttonText: '📋 Buka',
footer: 'Bot Footer',
sections: [
{
title: 'Kategori 1',
rows: [
{ rowId: 'a', title: 'Item A' },
{
title: 'Sub-kategori',
rows: [
{ rowId: 'b1', title: 'Item B1' },
{ rowId: 'b2', title: 'Item B2' }
]
}
]
}
]
})
// payload → { listMessage: { title, description, buttonText, listType, sections } }⚠️ Catatan Penting: Interactive Message Rendering
WhatsApp butuh binary node hint tambahan agar interactive/button/list message render di client. Harps-Baileys sudah otomatis inject ini lewat buildInteractiveAdditionalNodes() di messages-send.js. Jangan relay manual tanpa additionalNodes.
Kalau pakai relayMessage langsung:
import { buildInteractiveAdditionalNodes } from '@vinzsocket/baileys/lib/Utils/messages.js'
await relayMessage(jid, msg.message, {
messageId: msg.key.id,
additionalNodes: buildInteractiveAdditionalNodes(jid, msg.message)
})Node yang di-inject:
- List message →
<biz><list type="product_list" v="2"/></biz> - Interactive/button/template/product →
<biz><interactive type="native_flow" v="1"><native_flow name="mixed" v="9"/></interactive></biz> - 1:1 chat (bukan grup) → tambahan
<bot biz_bot="1"/>
🔌 Quick Start
import makeWASocket, { useMultiFileAuthState } from '@vinzsocket/baileys'
const { state, saveCreds } = await useMultiFileAuthState('./auth')
const conn = makeWASocket({
auth: state,
printQRInTerminal: true
})
conn.ev.on('creds.update', saveCreds)
conn.ev.on('messages.upsert', async ({ messages }) => {
const msg = messages[0]
if (!msg.message) return
const text = msg.message.conversation || msg.message.extendedTextMessage?.text || ''
const from = msg.key.remoteJid
if (text === '!menu') {
await conn.sendMessage(from, {
nestedListMessage: {
title: '📋 Main Menu',
buttonText: 'Buka Menu',
footer: 'Harps-MD Bot',
sections: [
{
title: '🎮 Game',
rows: [
{ rowId: 'rpg', title: '⚔️ RPG', description: 'Main RPG' },
{
title: '🏆 Kompetitif',
rows: [
{ rowId: 'pvp', title: '⚔️ PvP' },
{ rowId: 'rank', title: '📊 Ranking' }
]
}
]
}
]
}
}, { quoted: msg })
}
})📄 License
MIT — © Alvin-B2T
