Modded Baileys V7 Forked From ourin-baileys — Interactive Messages, AI Rich Responses, Albums & More

A modded build of WhiskeySockets/Baileys
with native support for interactive messages, album messages, unified rich responses, newsletter helpers, status mentions, and additional business/community utilities.
This repository is a distribution/build repo for lunaaa-baileys.
It ships compiled runtime files in lib/ and protobuf artifacts in WAProto/, and is intended to be consumed directly from npm or as a vendored dependency inside the Luna-MD ecosystem.
🆕 Changelog / Updates (v2.0.2)
1. Fix additionalNodes Conflict (v2.0.2)
- Fixed an issue where supplying a custom
<biz> node in additionalNodes alongside interactive messages caused duplicate <biz> nodes in the stanza, which led to the message being silently rejected by WhatsApp.
2. Built-in VoIP (Voice Call) Engine (v9.0.0)
- Full integration of the WebRTC and WASM engines to enable native WhatsApp voice calling, eliminating the need for a separate package.
2. Fix View Once Error (Anti-Crash)
- WhatsApp (Meta) Web API no longer receives media content for View Once messages, which previously caused the socket to crash. We've added robust parsing (
viewOnceMessageV3 & ptvMessage) to gracefully handle these empty stubs without crashing your bot.
2. Decryption Retry Fix (Private Chats)
- Fixed an issue in
messages-recv.js where "Bad MAC" / decryption errors would close the connection. Combined with a proper getMessage hook in your main connection setup, the bot now seamlessly retries failed decryptions.
- Browser parameter spoofing upgraded to MacOS to prevent Error 405 (Method Not Allowed) during pairing.
3. AI Rich Implementation (ORich)
-
Added the ORich class (an extension of AIRich from message_builder.js) to generate stunning AI response layouts easily.
-
Example Usage:
import { ORich } from 'lunaaa-baileys';
const luna = new ORich(sock)
.addText('Hello from ORich AI!')
.addSuggest(['Tell me more', 'Next']);
await luna.send(jid);
Table of Contents
- lunaaa-baileys
- Modded Baileys v7 — Interactive Messages, AI Rich Responses, Albums & More
- Table of Contents
- ✨ Features
- ✅ Requirements
- 🗂️ What’s Inside This Repo
- 📦 Installation
- From NPM
- Using Alias (Recommended for Luna-MD Bots)
- 🛠️ Quick Start
- 1. Project Setup
- 2. Install Dependencies
- 3. Create
index.js
- 4. Run
- 5. Pairing Code Example
- 🏗️ Architecture
- Socket Layer Chain
- Key Modules
- Build Repo Layout
- Connection Flow
- 📡 Socket API Reference
- Connection & Authentication
- VoIP (Voice Calls)
- Message Sending
- Interactive Messages
- Album Messages
- AI Rich Response Messages
- Code Block V2 (Unified Response)
- Other Message Types
- Newsletter Methods
- Group Methods
- Community Methods
- Business Methods
- Chat & Profile Methods
- Privacy Settings
- 📡 Event Reference
- 🔧 Utility Exports
- 🏗️ Building This Package
- 🔀 Differences from Official Baileys
- 🤝 Contributing
- 📄 License
✨ Features
| Feature |
Description |
Status |
| VoIP Voice Calls |
Native VoIP engine (WASM/WebRTC) via VoipClient, single shared socket |
✅ |
| Interactive Messages |
Native flow buttons, list/select menus, button wrappers, carousel support via Dugong |
✅ |
| Album Messages |
Multi-image/video album relay with count metadata and grouped delivery |
✅ |
| Rich Response Helpers |
sendTable, sendList, sendCodeBlock, sendRichMessage, sendUnifiedResponse |
✅ |
| Unified Response V2 |
sendTableV2, sendCodeBlockV2, sendLinkV2 with Meta-AI-style unified sections |
✅ |
| Link Messages |
Rich inline links with citations, proofs, and forwarded bot context |
✅ |
| Latex Rendering Hooks |
sendLatex, sendLatexImage, sendLatexInlineImage helper APIs |
✅ |
| Payment Messages |
Request payment messages with note/sticker support |
✅ |
| Product / Catalog |
Business product messages, catalog fetch/create/update/delete, cover photo helpers |
✅ |
| Event / Poll Result |
Event message builders and poll result snapshots |
✅ |
| Newsletter Extras |
URL resolve, metadata fetch, create/update, bulk follow, admin utilities, live updates |
✅ |
| Communities & Groups |
Community CRUD, linked groups, invite workflows, join approval, labels |
✅ |
| Status Mention |
sendStatusMention() helper to mention users/groups in status flows |
✅ |
| LID & Session Handling |
LID↔PN mapping, session migration, retry/session recreation helpers |
✅ |
| Build Output Ready |
Published runtime in lib/ and protobuf artifacts in WAProto/ |
✅ |
| TypeScript Declarations |
Included .d.ts files for exported APIs and socket methods |
✅ |
✅ Requirements
- Node.js
>= 20.0.0
- ESM project (
"type": "module" in your package.json)
- A persistent auth store implementation for production use
- Optional helpers depending on your use case:
pino for logging
qrcode-terminal if you want to render QR codes in the terminal yourself
sharp, jimp, audio-decode, link-preview-js for optional media/rich utilities
[!IMPORTANT]
lunaaa-baileys is ESM-only. CommonJS projects will need migration or dynamic import wrappers.
📁 What’s Inside This Repo
This package is not the TypeScript source workspace. It contains the compiled distributable files you actually publish/use.
| Path |
Purpose |
lib/ |
Main compiled runtime, types, socket layers, utilities |
WAProto/ |
Generated protobuf runtime and typings |
package.json |
Published package metadata, dependencies, build script |
tsconfig.json |
TypeScript config used for authoring/build pipeline |
tsconfig.build.json |
Build-specific TS emit config targeting lib/ |
proto-extract/ |
Protobuf-related extraction/build assets |
If you are documenting or integrating this project, treat lib/index.js and lib/index.d.ts as the primary public surface.
📦 Installation
From NPM
npm install lunaaa-baileys
Recommended companion packages for examples in this README:
npm install pino qrcode-terminal
Using Alias (Recommended for Luna-MD Bots)
Add to package.json:
{
"dependencies": {
"luna": "npm:lunaaa-baileys@latest"
}
}
Then run:
npm install
[!TIP]
Using the alias luna allows you to import luna from 'luna' without changing existing code.
[!NOTE]
Peer dependencies such as sharp, jimp, audio-decode, and link-preview-js are optional. Install only what your bot features need.
🛠️ Quick Start
1. Project Setup
mkdir my-bot && cd my-bot
npm init -y
Ensure package.json has "type": "module":
{
"name": "my-bot",
"type": "module",
"dependencies": {
"luna": "npm:lunaaa-baileys@latest"
}
}
[!IMPORTANT]
Required: "type": "module" — lunaaa-baileys is ESM-only. Without this, imports will fail.
2. Install Dependencies
npm install lunaaa-baileys pino qrcode-terminal
3. Create index.js
import makeWASocket, {
useMultiFileAuthState,
DisconnectReason,
Browsers,
} from "lunaaa-baileys";
import pino from "pino";
import qrcode from "qrcode-terminal";
const logger = pino({ level: "silent" });
async function startBot() {
const { state, saveCreds } = await useMultiFileAuthState("./session");
const sock = makeWASocket({
auth: state,
logger,
browser: Browsers.ubuntu("Chrome"),
syncFullHistory: false,
});
sock.ev.on("creds.update", saveCreds);
sock.ev.on("connection.update", ({ connection, lastDisconnect, qr }) => {
if (qr) {
qrcode.generate(qr, { small: true });
}
if (connection === "close") {
const shouldReconnect =
lastDisconnect?.error?.output?.statusCode !==
DisconnectReason.loggedOut;
if (shouldReconnect) startBot();
}
if (connection === "open") console.log("Connected!");
});
sock.ev.on("messages.upsert", async ({ messages }) => {
const msg = messages[0];
if (!msg?.message || msg.key.fromMe) return;
const text =
msg.message.conversation || msg.message.extendedTextMessage?.text || "";
if (text === ".ping") {
await sock.sendMessage(msg.key.remoteJid, { text: "Pong!" });
}
});
}
startBot();
4. Run
node index.js
Scan the QR code, wait until the socket reaches connection: "open", then send .ping to test.
5. Pairing Code Example
If you prefer pairing code over QR:
const sock = makeWASocket({
auth: state,
logger,
browser: Browsers.windows("Chrome"),
});
sock.ev.on("connection.update", async ({ connection }) => {
if (connection === "connecting") {
const code = await sock.requestPairingCode("6283874851613");
console.log("Pairing code:", code);
}
});
You can also provide your own custom pairing code:
const code = await sock.requestPairingCode("6283874851613", "LUNABAIL");
console.log("Custom pairing code:", code);
Custom pairing codes must be exactly 8 characters.
[!WARNING]
printQRInTerminal still exists in the type surface for compatibility, but it is deprecated in the current build. Prefer handling the qr value from connection.update yourself.
🏗️ Architecture
Socket Layer Chain
Each socket layer extends the previous via composition, adding functionality from bottom to top:
makeSocket → WebSocket + Noise protocol + pre-key management
makeChatsSocket → App state sync + chat modifications + profile
makeGroupsSocket → Group CRUD + participant management
makeMessagesSendSocket → Message sending + rich messages + relay
makeMessagesRecvSocket → Message receiving + decryption + notifications
makeBusinessSocket → Product catalog + business profile
makeCommunitiesSocket → Community CRUD + sub-groups
makeNewsletterSocket → Newsletter follow/unfollow/metadata
makeWASocket ← TOP LEVEL EXPORT
Key Modules
| Module |
Path |
Description |
| Socket |
lib/Socket/ |
Connection, messaging, groups, newsletter, business, communities |
| Signal |
lib/Signal/ |
Signal protocol: 1:1 encryption, group SenderKey, LID mapping |
| WABinary |
lib/WABinary/ |
Binary node encoding/decoding, JID utilities |
| Utils |
lib/Utils/ |
Crypto, auth state, noise handler, rich messages, media |
| WAProto |
WAProto/ |
Compiled protobuf encode/decode |
| WAUSync |
lib/WAUSync/ |
User sync protocol (contact, device, LID) |
| WAM |
lib/WAM/ |
WhatsApp analytics binary encoding |
| Types |
lib/Types/ |
Full TypeScript type definitions |
Build Repo Layout
This repository does not currently expose a src/ directory in the checked-in package tree.
That means:
- Documentation should reference
lib/ as the public implementation
- API discovery is best done through:
lib/index.js
lib/index.d.ts
lib/Socket/*.d.ts
lib/Utils/*.d.ts
- Consumers should treat this repo as a ready-to-install runtime artifact, not the authoring source tree
Connection Flow
- WebSocket connect → Noise XX handshake (Curve25519 + AES-256-GCM)
- QR code or Pairing Code authentication
CB:success → upload pre-keys → send passive IQ → emit connection: 'open'
- Store own LID↔PN mapping, migrate own session
- Buffer events → process offline notifications → flush →
receivedPendingNotifications: true
📡 Socket API Reference
Connection & Authentication
const sock = makeWASocket({
auth: state, // AuthenticationState from useMultiFileAuthState
logger, // pino logger instance
browser: Browsers.ubuntu("Chrome"), // Browser identity
version: [2, 3000, 1035194821], // WA version
connectTimeoutMs: 20_000, // Connection timeout
defaultQueryTimeoutMs: 60_000, // Query timeout
retryRequestDelayMs: 250, // Retry delay
maxMsgRetryCount: 5, // Max message retry count
enableRecentMessageCache: true, // Enable message retry manager
enableAutoSessionRecreation: true,
syncFullHistory: false, // Sync full chat history
shouldIgnoreJid: (jid) => false, // Filter specific JIDs
qrTimeout: 60_000,
generateHighQualityLinkPreview: false,
});
Pairing Code Authentication:
const sock = makeWASocket({
auth: state,
logger,
browser: Browsers.windows("Chrome"),
});
sock.ev.on("connection.update", async ({ connection, qr, isNewLogin }) => {
if (qr) {
// QR code available (fallback)
}
});
// Request pairing code
const code = await sock.requestPairingCode("6283874851613");
console.log("Pairing code:", code); // e.g. "LUNA-BAIL"
Authentication State:
import { useMultiFileAuthState } from "lunaaa-baileys";
const { state, saveCreds } = await useMultiFileAuthState("./session");
// state.creds → credentials (me, platform, noise keys, etc.)
// state.keys → SignalKeyStore (pre-keys, sessions, identity keys, etc.)
// saveCreds() → persist credentials to disk
Custom Data Store / Memory Store Pattern: