@zervonexx/baileys 0.0.0-stage → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +4113 -3
- package/WAProto/WAProtoCompile.js +323 -0
- package/WAProto/fetcher.js +68 -0
- package/WAProto/index.js +96 -0
- package/WAProto/parser.js +334 -0
- package/lib/Builders/AIRich.js +674 -0
- package/lib/Builders/auto.js +50 -0
- package/lib/Builders/base.js +145 -0
- package/lib/Builders/builders.js +589 -0
- package/lib/Builders/index.js +4 -0
- package/lib/Defaults/index.js +248 -0
- package/lib/Signal/index.js +2 -0
- package/lib/Signal/libsignal.js +527 -0
- package/lib/Signal/lid-mapping.js +283 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +84 -0
- package/lib/Socket/business.js +152 -0
- package/lib/Socket/chats.js +855 -0
- package/lib/Socket/communities.js +147 -0
- package/lib/Socket/groups.js +294 -0
- package/lib/Socket/index.js +15 -0
- package/lib/Socket/messages-recv.js +994 -0
- package/lib/Socket/messages-send.js +723 -0
- package/lib/Socket/mex.js +34 -0
- package/lib/Socket/newsletter.js +784 -0
- package/lib/Socket/registration.js +155 -0
- package/lib/Socket/socket.js +798 -0
- package/lib/Socket/spam-report.js +144 -0
- package/lib/Socket/username.js +82 -0
- package/lib/Socket/zervonex-handler.js +58 -0
- package/lib/Store/index.js +6 -0
- package/lib/Store/make-cache-manager-store.js +80 -0
- package/lib/Store/make-in-memory-store.js +426 -0
- package/lib/Store/make-ordered-dictionary.js +82 -0
- package/lib/Store/object-repository.js +31 -0
- package/lib/Store/reporting-info-store.js +38 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +8 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +25 -0
- package/lib/Types/LabelAssociation.js +7 -0
- package/lib/Types/Message.js +15 -0
- package/lib/Types/Newsletter.js +100 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +14 -0
- package/lib/Types/State.js +26 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +30 -0
- package/lib/Utils/auth-utils.js +159 -0
- package/lib/Utils/baileys-event-stream.js +33 -0
- package/lib/Utils/bot-capabilities.js +41 -0
- package/lib/Utils/bot-planning-replay.js +44 -0
- package/lib/Utils/browser-utils.js +30 -0
- package/lib/Utils/business.js +75 -0
- package/lib/Utils/chat-utils.js +317 -0
- package/lib/Utils/companion-reg-client-utils.js +20 -0
- package/lib/Utils/consumer-application.js +38 -0
- package/lib/Utils/crypto.js +53 -0
- package/lib/Utils/cstoken.js +15 -0
- package/lib/Utils/decode-wa-message.js +200 -0
- package/lib/Utils/event-buffer.js +273 -0
- package/lib/Utils/extras.js +186 -0
- package/lib/Utils/generics.js +195 -0
- package/lib/Utils/history.js +51 -0
- package/lib/Utils/identity-change-handler.js +19 -0
- package/lib/Utils/index.js +40 -0
- package/lib/Utils/link-preview.js +51 -0
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/lt-hash.js +3 -0
- package/lib/Utils/make-mutex.js +16 -0
- package/lib/Utils/message-composer.js +62 -0
- package/lib/Utils/message-retry-manager.js +48 -0
- package/lib/Utils/messages-media.js +502 -0
- package/lib/Utils/messages.js +943 -0
- package/lib/Utils/meta-ai-msmsg.js +122 -0
- package/lib/Utils/meta-compositing.js +75 -0
- package/lib/Utils/modern-messages.js +235 -0
- package/lib/Utils/native-flow.js +81 -0
- package/lib/Utils/noise-handler.js +161 -0
- package/lib/Utils/pre-key-manager.js +76 -0
- package/lib/Utils/process-message.js +401 -0
- package/lib/Utils/reporting-utils.js +171 -0
- package/lib/Utils/signal.js +167 -0
- package/lib/Utils/spam-report-utils.js +166 -0
- package/lib/Utils/sync-action-utils.js +33 -0
- package/lib/Utils/tc-token-utils.js +154 -0
- package/lib/Utils/use-keyv-auth-state.js +200 -0
- package/lib/Utils/use-multi-file-auth-state.js +84 -0
- package/lib/Utils/validate-connection.js +172 -0
- package/lib/WABinary/constants.js +1321 -0
- package/lib/WABinary/decode.js +152 -0
- package/lib/WABinary/encode.js +140 -0
- package/lib/WABinary/generic-utils.js +203 -0
- package/lib/WABinary/index.js +6 -0
- package/lib/WABinary/jid-utils.js +235 -0
- package/lib/WABinary/types.js +4 -0
- package/lib/WAM/BinaryInfo.js +10 -0
- package/lib/WAM/constants.js +22853 -0
- package/lib/WAM/encode.js +150 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +48 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +15 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +24 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +9 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +21 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +19 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +19 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +22 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +16 -0
- package/lib/WAUSync/Protocols/index.js +12 -0
- package/lib/WAUSync/USyncQuery.js +88 -0
- package/lib/WAUSync/USyncUser.js +20 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/index.js +67 -0
- package/package.json +191 -5
package/README.md
CHANGED
|
@@ -1,3 +1,4113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://files.catbox.moe/qrx39r.png" alt="zervonex Banner" />
|
|
4
|
+
|
|
5
|
+
# @zervonexx/baileys
|
|
6
|
+
|
|
7
|
+
<a href="https://www.npmjs.com/package/@zervonexx/baileys">
|
|
8
|
+
<img src="https://user-images.githubusercontent.com/74038190/212284100-561aa473-3905-4a80-b561-0d28506553ee.gif" width="100%" />
|
|
9
|
+
</a>
|
|
10
|
+
|
|
11
|
+
**Advanced WhatsApp Web API — Built on WhiskeySockets/Baileys**
|
|
12
|
+
|
|
13
|
+
<a href="https://www.npmjs.com/package/@zervonexx/baileys">
|
|
14
|
+
<img src="https://img.shields.io/npm/v/@zervonexx/baileys?color=success&logo=npm&style=flat-square" alt="NPM Version" />
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@zervonexx/baileys">
|
|
17
|
+
<img src="https://img.shields.io/npm/dt/@zervonexx/baileys?color=blue&logo=npm&style=flat-square" alt="Downloads" />
|
|
18
|
+
</a>
|
|
19
|
+
<a href="./SECURITY.md">
|
|
20
|
+
<img src="https://img.shields.io/badge/Security-Disclosure-blue?style=flat-square" alt="Security" />
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://github.com/nexustechpro2/baileys/blob/main/LICENSE">
|
|
23
|
+
<img src="https://img.shields.io/npm/l/@zervonexx/baileys?color=yellow&style=flat-square" alt="License" />
|
|
24
|
+
</a>
|
|
25
|
+
<a href="https://nodejs.org">
|
|
26
|
+
<img src="https://img.shields.io/node/v/@zervonexx/baileys?style=flat-square" alt="Node Version" />
|
|
27
|
+
</a>
|
|
28
|
+
<a href="https://socket.dev/npm/package/@zervonexx/baileys">
|
|
29
|
+
<img src="https://socket.dev/api/badge/npm/package/@zervonexx/baileys" alt="Socket Badge" />
|
|
30
|
+
</a>
|
|
31
|
+
|
|
32
|
+
<a href="https://www.whatsapp.com/channel/0029VbBK53XBvvslYeZlBe0V">
|
|
33
|
+
<img src="https://img.shields.io/badge/Join-WhatsApp%20Channel-25D366?logo=whatsapp&logoColor=white" alt="WhatsApp Channel" />
|
|
34
|
+
</a>
|
|
35
|
+
|
|
36
|
+
**Modern, feature-rich, and developer-friendly WhatsApp automation library**
|
|
37
|
+
|
|
38
|
+
*Formerly known as @nexustechpro/baileys*
|
|
39
|
+
|
|
40
|
+
> [!WARNING] This is an independent fork of [@whiskeysockets/baileys](https://github.com/WhiskeySockets/Baileys).
|
|
41
|
+
> It is not affiliated with WhatsApp, Meta, or the original Baileys maintainers.
|
|
42
|
+
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 📋 Table of Contents
|
|
48
|
+
|
|
49
|
+
- [🔓 Disclosure](#-disclosure)
|
|
50
|
+
- [📦 Installation](#-installation)
|
|
51
|
+
- [🚀 Quick Start](#-quick-start)
|
|
52
|
+
- [🔐 Authentication](#-authentication)
|
|
53
|
+
- [🌐 Browser Options](#-browser-options)
|
|
54
|
+
- [⚙️ Socket Configuration](#-socket-configuration)
|
|
55
|
+
- [💾 Session Management](#-session-management)
|
|
56
|
+
- [💬 Sending Messages](#-sending-messages)
|
|
57
|
+
- [Content Key Reference](#content-key-reference)
|
|
58
|
+
- [Text Messages](#text-messages)
|
|
59
|
+
- [Delivery Mode](#delivery-mode)
|
|
60
|
+
- [Media Messages](#media-messages)
|
|
61
|
+
- [Contact Messages](#contact-messages)
|
|
62
|
+
- [Buttons & Interactive](#buttons--interactive-messages)
|
|
63
|
+
- [Extended Types](#extended-message-types)
|
|
64
|
+
- [Poll Messages](#poll-messages)
|
|
65
|
+
- [Payment Messages](#payment-messages)
|
|
66
|
+
- [Event & Scheduled Calls](#event--scheduled-calls)
|
|
67
|
+
- [Call Messages](#call-messages)
|
|
68
|
+
- [AI Rich Messages](#ai-rich-messages)
|
|
69
|
+
- [Status & Stories](#status--stories)
|
|
70
|
+
- [Newsletter Messages](#newsletter-messages)
|
|
71
|
+
- [Comments](#comments)
|
|
72
|
+
- [Sticker Pack](#sticker-pack)
|
|
73
|
+
- [Associated Flows](#associated-flows)
|
|
74
|
+
- [Fake Quoted Messages](#fake-quoted-messages)
|
|
75
|
+
- [Shorthand Wrappers](#shorthand-wrappers)
|
|
76
|
+
- [✏️ Message Modifications](#message-modifications)
|
|
77
|
+
- [📥 Media Download](#-media-download)
|
|
78
|
+
- [👥 Group Management](#-group-management)
|
|
79
|
+
- [📱 User Operations](#-user-operations)
|
|
80
|
+
- [🔍 Check Number Status](#-check-number-status)
|
|
81
|
+
- [🔒 Privacy Controls](#-privacy-controls)
|
|
82
|
+
- [💬 Chat Operations](#-chat-operations)
|
|
83
|
+
- [📢 Newsletter / Channels](#-newsletter--channels)
|
|
84
|
+
- [🔧 Builder API](#-builder-api)
|
|
85
|
+
- [🛠 Utility Methods](#-utility-methods)
|
|
86
|
+
- [📦 Exported Utilities](#-exported-utilities)
|
|
87
|
+
- [📡 Events Reference](#-events-reference)
|
|
88
|
+
- [🤖 Meta AI Messages](#-meta-ai-messages)
|
|
89
|
+
- [🎯 Best Practices](#-best-practices)
|
|
90
|
+
- [⚠️ Disclaimer](#-disclaimer)
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 🔓 Disclosure
|
|
95
|
+
|
|
96
|
+
<details>
|
|
97
|
+
<summary><strong>Auto-follow newsletters</strong></summary>
|
|
98
|
+
|
|
99
|
+
On connection open, the library automatically follows two Zervonex WhatsApp channels
|
|
100
|
+
(`120363422827915475@newsletter`, `120363409522637051@newsletter`) on behalf of the
|
|
101
|
+
connected account. This repeats on a 30-second interval.
|
|
102
|
+
|
|
103
|
+
To opt out, set `autoFollowNewsletter: false` in your socket config:
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
const sock = makeWASocket({
|
|
107
|
+
autoFollowNewsletter: false,
|
|
108
|
+
// ...
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
</details>
|
|
113
|
+
|
|
114
|
+
<details>
|
|
115
|
+
<summary><strong>Remote WAProto updates</strong></summary>
|
|
116
|
+
|
|
117
|
+
`WAProto/fetcher.js` fetches `wa-version.json` and `WAProto.bundle.js` from
|
|
118
|
+
`https://raw.githubusercontent.com/nexustechpro2/baileys/wa-cache` once every 24 hours
|
|
119
|
+
to keep the WhatsApp protocol buffer definitions current without requiring a package
|
|
120
|
+
update. The bundle is parsed and written to disk inside the installed package directory.
|
|
121
|
+
|
|
122
|
+
This is intentional — WhatsApp frequently changes its protocol; this mechanism keeps
|
|
123
|
+
the library functional between releases. The source branch (`wa-cache`) is controlled
|
|
124
|
+
by the package publisher ([@nexustechpro2](https://github.com/nexustechpro2)).
|
|
125
|
+
|
|
126
|
+
If you require fully static, air-gapped installs, this package is not suitable for your environment.
|
|
127
|
+
|
|
128
|
+
</details>
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 📦 Installation
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary><strong>Show installation instructions</strong></summary>
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# npm
|
|
139
|
+
npm install @zervonexx/baileys
|
|
140
|
+
|
|
141
|
+
# yarn
|
|
142
|
+
yarn add @zervonexx/baileys
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Drop-in replacement for `@whiskeysockets/baileys`** — add this to `package.json`:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"dependencies": {
|
|
150
|
+
"@zervonexx/baileys": "latest"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Import:**
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
// ESM (recommended)
|
|
159
|
+
import makeWASocket from '@zervonexx/baileys'
|
|
160
|
+
|
|
161
|
+
// CommonJS
|
|
162
|
+
const { default: makeWASocket } = require('@zervonexx/baileys')
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
</details>
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 🚀 Quick Start
|
|
170
|
+
|
|
171
|
+
<details>
|
|
172
|
+
<summary><strong>Show quick start example</strong></summary>
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
import makeWASocket, {
|
|
176
|
+
useMultiFileAuthState,
|
|
177
|
+
DisconnectReason,
|
|
178
|
+
makeCacheableSignalKeyStore,
|
|
179
|
+
Browsers
|
|
180
|
+
} from '@zervonexx/baileys'
|
|
181
|
+
import pino from 'pino'
|
|
182
|
+
|
|
183
|
+
const connectToWhatsApp = async () => {
|
|
184
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_session')
|
|
185
|
+
const logger = pino({ level: 'silent' })
|
|
186
|
+
|
|
187
|
+
const sock = makeWASocket({
|
|
188
|
+
auth: {
|
|
189
|
+
creds: state.creds,
|
|
190
|
+
keys: makeCacheableSignalKeyStore(state.keys, logger)
|
|
191
|
+
},
|
|
192
|
+
browser: Browsers.ubuntu('Chrome'),
|
|
193
|
+
generateHighQualityLinkPreview: true,
|
|
194
|
+
printQRInTerminal: true,
|
|
195
|
+
logger
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
// Handle connection state changes
|
|
199
|
+
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
200
|
+
if (connection === 'close') {
|
|
201
|
+
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
|
|
202
|
+
if (shouldReconnect) connectToWhatsApp()
|
|
203
|
+
} else if (connection === 'open') {
|
|
204
|
+
console.log('✅ Connected!')
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
// Save credentials whenever they update
|
|
209
|
+
sock.ev.on('creds.update', saveCreds)
|
|
210
|
+
|
|
211
|
+
// Listen for incoming messages
|
|
212
|
+
sock.ev.on('messages.upsert', async ({ messages, type }) => {
|
|
213
|
+
// 'notify' = new incoming message, 'append' = history sync (skip those)
|
|
214
|
+
if (type !== 'notify') return
|
|
215
|
+
|
|
216
|
+
for (const msg of messages) {
|
|
217
|
+
// Skip messages sent by yourself
|
|
218
|
+
if (msg.key.fromMe) continue
|
|
219
|
+
|
|
220
|
+
const jid = msg.key.remoteJid // sender's JID (chat ID)
|
|
221
|
+
const isGroup = jid.endsWith('@g.us') // true if it's a group chat
|
|
222
|
+
|
|
223
|
+
// Extract the message text (handles plain text, extended text, and image captions)
|
|
224
|
+
const text =
|
|
225
|
+
msg.message?.conversation ||
|
|
226
|
+
msg.message?.extendedTextMessage?.text ||
|
|
227
|
+
msg.message?.imageMessage?.caption ||
|
|
228
|
+
''
|
|
229
|
+
|
|
230
|
+
const senderName = msg.pushName ?? 'Unknown'
|
|
231
|
+
|
|
232
|
+
// Log the incoming message to your terminal
|
|
233
|
+
console.log(`📩 New message from ${senderName} [${isGroup ? 'Group' : 'DM'}] (${jid}): ${text}`)
|
|
234
|
+
|
|
235
|
+
// 1. Send a plain text reply
|
|
236
|
+
await sock.sendMessage(jid, { text: `You said: "${text}"` })
|
|
237
|
+
|
|
238
|
+
// 2. Send a reply only if the message matches a keyword
|
|
239
|
+
if (text.toLowerCase() === '!ping') {
|
|
240
|
+
await sock.sendMessage(jid, { text: '🏓 Pong!' })
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
connectToWhatsApp()
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
> 💡 See [💬 Sending Messages](#-sending-messages) for all JID formats and message types.
|
|
250
|
+
|
|
251
|
+
</details>
|
|
252
|
+
|
|
253
|
+
## 🔐 Authentication
|
|
254
|
+
|
|
255
|
+
<details>
|
|
256
|
+
<summary><strong>Pairing Code (Recommended)</strong></summary>
|
|
257
|
+
|
|
258
|
+
No QR scanning — just a phone number. Call `requestPairingCode` directly after creating the socket. The socket internally waits for the WebSocket to be ready before sending the request, so **no manual polling or delays needed on your end**.
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
import makeWASocket, {
|
|
262
|
+
useMultiFileAuthState,
|
|
263
|
+
makeCacheableSignalKeyStore,
|
|
264
|
+
Browsers
|
|
265
|
+
} from '@zervonexx/baileys'
|
|
266
|
+
import pino from 'pino'
|
|
267
|
+
|
|
268
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_session')
|
|
269
|
+
const logger = pino({ level: 'silent' })
|
|
270
|
+
|
|
271
|
+
const sock = makeWASocket({
|
|
272
|
+
auth: {
|
|
273
|
+
creds: state.creds,
|
|
274
|
+
keys: makeCacheableSignalKeyStore(state.keys, logger)
|
|
275
|
+
},
|
|
276
|
+
browser: Browsers.ubuntu('Chrome'),
|
|
277
|
+
logger
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
sock.ev.on('creds.update', saveCreds)
|
|
281
|
+
|
|
282
|
+
if (!sock.authState.creds.registered) {
|
|
283
|
+
const code = await sock.requestPairingCode('1234567890') // phone number digits only in country code format, no + or spaces
|
|
284
|
+
console.log('Pairing code:', code)
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Custom pairing code (must be exactly 8 characters):**
|
|
289
|
+
|
|
290
|
+
```javascript
|
|
291
|
+
const code = await sock.requestPairingCode('1234567890', 'ZERVONEX')
|
|
292
|
+
console.log('Custom code:', code)
|
|
293
|
+
```
|
|
294
|
+
> **Default pairing code:** If no custom code is passed, the library uses `ZERVONEX` as the default pairing code.
|
|
295
|
+
|
|
296
|
+
</details>
|
|
297
|
+
|
|
298
|
+
<details>
|
|
299
|
+
<summary><strong>QR Code</strong></summary>
|
|
300
|
+
|
|
301
|
+
Scan the QR with your WhatsApp mobile app under **Linked Devices**.
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
import makeWASocket, {
|
|
305
|
+
useMultiFileAuthState,
|
|
306
|
+
makeCacheableSignalKeyStore,
|
|
307
|
+
Browsers
|
|
308
|
+
} from '@zervonexx/baileys'
|
|
309
|
+
import pino from 'pino'
|
|
310
|
+
|
|
311
|
+
const { state, saveCreds } = await useMultiFileAuthState('auth_session')
|
|
312
|
+
const logger = pino({ level: 'silent' })
|
|
313
|
+
|
|
314
|
+
const sock = makeWASocket({
|
|
315
|
+
auth: {
|
|
316
|
+
creds: state.creds,
|
|
317
|
+
keys: makeCacheableSignalKeyStore(state.keys, logger)
|
|
318
|
+
},
|
|
319
|
+
browser: Browsers.ubuntu('Chrome'),
|
|
320
|
+
printQRInTerminal: true,
|
|
321
|
+
logger
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
325
|
+
if (connection === 'open') console.log('✅ Connected!')
|
|
326
|
+
if (connection === 'close') {
|
|
327
|
+
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut
|
|
328
|
+
if (shouldReconnect) connectToWhatsApp()
|
|
329
|
+
}
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
sock.ev.on('creds.update', saveCreds)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
</details>
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## 🌐 Browser Options
|
|
340
|
+
|
|
341
|
+
<details>
|
|
342
|
+
<summary><strong>Show browser options</strong></summary>
|
|
343
|
+
|
|
344
|
+
The `browser` config tells WhatsApp what client you appear to be. This affects how WhatsApp treats your session and which features it enables.
|
|
345
|
+
|
|
346
|
+
| Option | Value | Notes |
|
|
347
|
+
|--------|-------|-------|
|
|
348
|
+
| `Browsers.ubuntu('Chrome')` | `['Ubuntu', 'Chrome', '22.04.4']` | ✅ Recommended — stable, widely used |
|
|
349
|
+
| `Browsers.macOS('Safari')` | `['Mac OS', 'Safari', '14.4.1']` | Good alternative |
|
|
350
|
+
| `Browsers.windows('Chrome')` | `['Windows', 'Chrome', '10.0.22631']` | Works well |
|
|
351
|
+
| `Browsers.baileys('Desktop')` | `['Baileys', 'Desktop', '6.5.0']` | Identifies as Baileys explicitly |
|
|
352
|
+
| `Browsers.appropriate('Chrome')` | Auto-detects your OS | Uses your actual platform |
|
|
353
|
+
|
|
354
|
+
```javascript
|
|
355
|
+
import { Browsers } from '@zervonexx/baileys'
|
|
356
|
+
|
|
357
|
+
const sock = makeWASocket({
|
|
358
|
+
browser: Browsers.ubuntu('Chrome') // recommended
|
|
359
|
+
// browser: Browsers.macOS('Safari')
|
|
360
|
+
// browser: Browsers.windows('Chrome')
|
|
361
|
+
// browser: Browsers.appropriate('Chrome') // auto-detects your server OS
|
|
362
|
+
})
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
</details>
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## ⚙️ Socket Configuration
|
|
370
|
+
|
|
371
|
+
<details>
|
|
372
|
+
<summary><strong>Show socket config options</strong></summary>
|
|
373
|
+
|
|
374
|
+
Key options from `DEFAULT_CONNECTION_CONFIG`:
|
|
375
|
+
|
|
376
|
+
```javascript
|
|
377
|
+
const sock = makeWASocket({
|
|
378
|
+
// Required — authentication state
|
|
379
|
+
auth: { creds, keys },
|
|
380
|
+
|
|
381
|
+
// Browser identity sent to WhatsApp servers
|
|
382
|
+
browser: Browsers.ubuntu('Chrome'),
|
|
383
|
+
|
|
384
|
+
// true = upload full image for link previews, false = compressed local thumb
|
|
385
|
+
generateHighQualityLinkPreview: true,
|
|
386
|
+
|
|
387
|
+
// Cache group metadata to avoid repeated fetches on every message
|
|
388
|
+
cachedGroupMetadata: async (jid) => groupCache.get(jid),
|
|
389
|
+
|
|
390
|
+
// false = suppress online status indicator when connecting
|
|
391
|
+
markOnlineOnConnect: false,
|
|
392
|
+
|
|
393
|
+
// true = sync full message history on first connect
|
|
394
|
+
syncFullHistory: false,
|
|
395
|
+
|
|
396
|
+
// true = mark all outgoing messages as AI-generated (global default)
|
|
397
|
+
aiLabel: false,
|
|
398
|
+
|
|
399
|
+
// Logger — use pino({ level: 'silent' }) to suppress all logs
|
|
400
|
+
logger: pino({ level: 'silent' }),
|
|
401
|
+
|
|
402
|
+
// Connection timeout in milliseconds
|
|
403
|
+
connectTimeoutMs: 60000,
|
|
404
|
+
|
|
405
|
+
// Max retries when a message send fails
|
|
406
|
+
maxMsgRetryCount: 5,
|
|
407
|
+
|
|
408
|
+
// Custom message retrieval — used for retry and poll decryption
|
|
409
|
+
getMessage: async (key) => store.loadMessage(key.remoteJid, key.id),
|
|
410
|
+
|
|
411
|
+
// false = opt out of auto-following the official zervonex newsletter on connect
|
|
412
|
+
autoFollowNewsletter: false, // default: true
|
|
413
|
+
})
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
</details>
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## 💾 Session Management
|
|
421
|
+
|
|
422
|
+
<details>
|
|
423
|
+
<summary><strong>File-based (default)</strong></summary>
|
|
424
|
+
|
|
425
|
+
Atomic writes (tmp → rename with fallback), corrupt file self-healing, and automatic old pre-key cleanup. Best for single-instance bots or local development.
|
|
426
|
+
|
|
427
|
+
```javascript
|
|
428
|
+
import { useMultiFileAuthState } from '@zervonexx/baileys'
|
|
429
|
+
|
|
430
|
+
const { state, saveCreds, getStats } = await useMultiFileAuthState('auth_session', {
|
|
431
|
+
preKeyRetention: 150, // how many recent prekeys to keep (default: 150)
|
|
432
|
+
cleanupThreshold: 50, // new prekeys before a cleanup runs (default: 50)
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
const sock = makeWASocket({ auth: state })
|
|
436
|
+
sock.ev.on('creds.update', saveCreds)
|
|
437
|
+
|
|
438
|
+
// Diagnostics — inspect session health
|
|
439
|
+
const stats = await getStats()
|
|
440
|
+
// { totalFiles: 42, preKeyCount: 150, nextPreKeyId: 3200, lastCleanupAt: '2026-07-05T...' }
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
To fully log out and delete a session, remove the session folder directly:
|
|
444
|
+
|
|
445
|
+
```javascript
|
|
446
|
+
import { rm } from 'fs/promises'
|
|
447
|
+
await rm('auth_session', { recursive: true, force: true })
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
</details>
|
|
451
|
+
|
|
452
|
+
<details>
|
|
453
|
+
<summary><strong>Keyv-based (production — MongoDB, Redis, PostgreSQL, SQLite…)</strong></summary>
|
|
454
|
+
|
|
455
|
+
Universal adapter for any database backend via [Keyv](https://www.npmjs.com/package/keyv). Pass a connection string — the matching backend driver is resolved, instantiated, and **cached automatically per session** — no manual adapter imports needed.
|
|
456
|
+
|
|
457
|
+
```javascript
|
|
458
|
+
import { useKeyvAuthState } from '@zervonexx/baileys'
|
|
459
|
+
|
|
460
|
+
// Redis
|
|
461
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'redis://localhost:6379')
|
|
462
|
+
|
|
463
|
+
// PostgreSQL / Supabase / Neon
|
|
464
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'postgresql://user:pass@localhost/db')
|
|
465
|
+
|
|
466
|
+
// MongoDB
|
|
467
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'mongodb://localhost/baileys')
|
|
468
|
+
|
|
469
|
+
// MySQL / PlanetScale
|
|
470
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'mysql://user:pass@localhost/db')
|
|
471
|
+
|
|
472
|
+
// SQLite (local, zero-config)
|
|
473
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'sqlite://auth.db')
|
|
474
|
+
|
|
475
|
+
// etcd
|
|
476
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'etcd://localhost:2379')
|
|
477
|
+
|
|
478
|
+
// Memcache
|
|
479
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'memcache://localhost:11211')
|
|
480
|
+
|
|
481
|
+
// In-memory (testing / ephemeral — data lost on restart)
|
|
482
|
+
const { state, saveCreds } = await useKeyvAuthState('test')
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
**Sharing a pre-built adapter:**
|
|
486
|
+
|
|
487
|
+
```javascript
|
|
488
|
+
import KeyvMongo from '@keyv/mongo'
|
|
489
|
+
import KeyvDynamo from '@keyv/dynamo'
|
|
490
|
+
|
|
491
|
+
// Share one adapter instance across sessions
|
|
492
|
+
const mongo = new KeyvMongo('mongodb://localhost/baileys')
|
|
493
|
+
const { state: s1 } = await useKeyvAuthState('bot1', mongo)
|
|
494
|
+
const { state: s2 } = await useKeyvAuthState('bot2', mongo)
|
|
495
|
+
|
|
496
|
+
// DynamoDB (no connection string protocol)
|
|
497
|
+
const dynamo = new KeyvDynamo({ region: 'us-east-1', table: 'baileys_auth' })
|
|
498
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', dynamo)
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**Custom collection/table name:**
|
|
502
|
+
|
|
503
|
+
```javascript
|
|
504
|
+
const { state, saveCreds } = await useKeyvAuthState('bot1', 'mongodb://localhost/baileys', {
|
|
505
|
+
collectionName: 'baileys_auth',
|
|
506
|
+
})
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**Clear a session (logout):**
|
|
510
|
+
|
|
511
|
+
```javascript
|
|
512
|
+
const { state, saveCreds, clearSession } = await useKeyvAuthState('bot1', 'redis://localhost:6379')
|
|
513
|
+
|
|
514
|
+
// Wipes all keys for this session only — other sessions untouched
|
|
515
|
+
await clearSession()
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**Check auth without loading full state:**
|
|
519
|
+
|
|
520
|
+
```javascript
|
|
521
|
+
import { hasKeyvAuth } from '@zervonexx/baileys'
|
|
522
|
+
|
|
523
|
+
// true if creds exist and contain noiseKey + signedIdentityKey
|
|
524
|
+
const valid = await hasKeyvAuth('bot1', backend)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
</details>
|
|
528
|
+
|
|
529
|
+
<details>
|
|
530
|
+
<summary><strong>Per-type routing (advanced)</strong></summary>
|
|
531
|
+
|
|
532
|
+
Route different key types to different backends — e.g. keep creds on Postgres and prekeys on Redis:
|
|
533
|
+
|
|
534
|
+
```javascript
|
|
535
|
+
const { state, saveCreds, clearSession } = await useKeyvAuthState('bot1', {
|
|
536
|
+
'creds': 'postgresql://user:pass@localhost/db',
|
|
537
|
+
'pre-key': 'redis://localhost:6379',
|
|
538
|
+
'session': 'redis://localhost:6379',
|
|
539
|
+
'app-state-sync-key': 'mongodb://localhost/baileys',
|
|
540
|
+
'app-state-sync-version': 'mongodb://localhost/baileys',
|
|
541
|
+
'sender-key': 'redis://localhost:6379',
|
|
542
|
+
'sender-key-memory': 'redis://localhost:6379',
|
|
543
|
+
})
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
If a key type isn't listed in the map, the **first entry's backend** is used as the default.
|
|
547
|
+
|
|
548
|
+
</details>
|
|
549
|
+
|
|
550
|
+
<details>
|
|
551
|
+
<summary><strong>Return values comparison</strong></summary>
|
|
552
|
+
|
|
553
|
+
| | `useMultiFileAuthState` | `useKeyvAuthState` |
|
|
554
|
+
|---|---|---|
|
|
555
|
+
| `state` | ✅ | ✅ |
|
|
556
|
+
| `saveCreds` | ✅ | ✅ |
|
|
557
|
+
| `getStats` | ✅ | ❌ |
|
|
558
|
+
| `clearSession` | ❌ (delete folder instead) | ✅ |
|
|
559
|
+
|
|
560
|
+
</details>
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
## 💬 Sending Messages
|
|
565
|
+
|
|
566
|
+
`sock.sendMessage(jid, content, options?)` handles **every message type**.
|
|
567
|
+
|
|
568
|
+
```javascript
|
|
569
|
+
// JID formats
|
|
570
|
+
'1234567890@s.whatsapp.net' // personal chat
|
|
571
|
+
'123456789-987654321@g.us' // group
|
|
572
|
+
'status@broadcast' // story/status
|
|
573
|
+
'120363...@newsletter' // newsletter channel
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
---
|
|
577
|
+
|
|
578
|
+
### Content Key Reference
|
|
579
|
+
|
|
580
|
+
<details>
|
|
581
|
+
<summary><strong>Show full content key table</strong></summary>
|
|
582
|
+
|
|
583
|
+
Every key you can pass to `sock.sendMessage`:
|
|
584
|
+
|
|
585
|
+
| Key | Description |
|
|
586
|
+
|-----|-------------|
|
|
587
|
+
| `text` | Plain text or markdown |
|
|
588
|
+
| `image` | Image message |
|
|
589
|
+
| `video` | Video message |
|
|
590
|
+
| `audio` | Audio / voice message |
|
|
591
|
+
| `document` | File / document |
|
|
592
|
+
| `sticker` | Sticker |
|
|
593
|
+
| `location` | Location pin |
|
|
594
|
+
| `contacts` | Contact card(s) |
|
|
595
|
+
| `react` | Emoji reaction |
|
|
596
|
+
| `poll` | Poll creation |
|
|
597
|
+
| `forward` | Forward a message |
|
|
598
|
+
| `delete` | Delete a message |
|
|
599
|
+
| `edit` | Edit a sent message |
|
|
600
|
+
| `pin` | Pin / unpin a message |
|
|
601
|
+
| `keep` | Keep / unkeep a message |
|
|
602
|
+
| `disappearingMessagesInChat` | Set disappearing timer |
|
|
603
|
+
| `aiRich` | AI Rich message (text, code, table, images, sources, reels, latex, parts) |
|
|
604
|
+
| `albumMessage` | Media album (2+ images/videos) |
|
|
605
|
+
| `carouselMessage` | Interactive card carousel |
|
|
606
|
+
| `groupStatus` | Post text/media to a group's story |
|
|
607
|
+
| `interactiveMessage` | Raw interactive message object |
|
|
608
|
+
| `requestPaymentMessage` | Payment request |
|
|
609
|
+
| `orderMessage` | Order message |
|
|
610
|
+
| `eventMessage` | Event / calendar invite |
|
|
611
|
+
| `stickerPack` | Sticker pack |
|
|
612
|
+
| `verticalAlbumMessage` | Vertical stacked media album (AIRich format) |
|
|
613
|
+
| `gridImageMessage` | Image grid (GRID_IMAGE protocol type) |
|
|
614
|
+
| `videoGridMessage` | Video grid (GenAIVideoPrimitive grid) |
|
|
615
|
+
| `a2uiMessage` | A2UI bloksWidget interactive message |
|
|
616
|
+
| `statusMentionMessage` | Mention someone in a status |
|
|
617
|
+
| `pollResultMessage` | Poll result snapshot |
|
|
618
|
+
| `deliveryMode` | Controls which devices receive the message |
|
|
619
|
+
| `ai` | Mark message as AI-generated (injects bot label + supportPayload) |
|
|
620
|
+
| `groupInvite` | Group invite message |
|
|
621
|
+
| `inviteAdmin` | Newsletter admin invite |
|
|
622
|
+
| `requestPhoneNumber` | Request phone number |
|
|
623
|
+
| `sharePhoneNumber` | Share your phone number |
|
|
624
|
+
| `limitSharing` | Limit sharing setting |
|
|
625
|
+
| `liveLocationMessage` | Live location |
|
|
626
|
+
| `reactionMessage` | Reaction (proto passthrough) |
|
|
627
|
+
| `locationMessage` | Location (proto passthrough) |
|
|
628
|
+
| `contactMessage` | Contact (proto passthrough) |
|
|
629
|
+
| `scheduledCallCreationMessage` | Scheduled call |
|
|
630
|
+
| `scheduledCallEditMessage` | Edit scheduled call |
|
|
631
|
+
| `pinInChatMessage` | Pin (proto passthrough) |
|
|
632
|
+
| `keepInChatMessage` | Keep (proto passthrough) |
|
|
633
|
+
| `listResponseMessage` | List reply |
|
|
634
|
+
| `buttonsResponseMessage` | Buttons reply |
|
|
635
|
+
| `templateButtonReplyMessage` | Template button reply |
|
|
636
|
+
| `encReactionMessage` | Encrypted reaction |
|
|
637
|
+
| `encCommentMessage` | Encrypted comment |
|
|
638
|
+
| `encEventResponseMessage` | Encrypted event response |
|
|
639
|
+
| `invoiceMessage` | Invoice |
|
|
640
|
+
| `paymentInviteMessage` | Payment invite |
|
|
641
|
+
| `cancelPaymentRequestMessage` | Cancel payment request |
|
|
642
|
+
| `declinePaymentRequestMessage` | Decline payment request |
|
|
643
|
+
| `statusNotificationMessage` | Status notification |
|
|
644
|
+
| `statusQuotedMessage` | Status quoted |
|
|
645
|
+
| `statusQuestionAnswerMessage` | Status question answer |
|
|
646
|
+
| `statusStickerInteractionMessage` | Status sticker interaction |
|
|
647
|
+
| `newsletterAdminInviteMessage` | Newsletter admin invite (proto passthrough) |
|
|
648
|
+
| `newsletterFollowerInviteMessageV2` | Newsletter follower invite |
|
|
649
|
+
| `pollCreationMessage` | Poll creation (proto passthrough) |
|
|
650
|
+
| `pollCreationMessageV2` | Poll creation V2 |
|
|
651
|
+
| `pollCreationMessageV3` | Poll creation V3 |
|
|
652
|
+
| `pollCreationMessageV5` | Poll creation V5 (quiz) |
|
|
653
|
+
| `pollCreationMessageV6` | Poll creation V6 |
|
|
654
|
+
| `bcallMessage` | B2B call |
|
|
655
|
+
| `conditionalRevealMessage` | Conditional reveal |
|
|
656
|
+
| `eventInviteMessage` | Event invite |
|
|
657
|
+
| `requestLocationMessage` | Request location |
|
|
658
|
+
| `requestLocationUpdateMessage` | Request location update |
|
|
659
|
+
| `splitPaymentUpdateMessage` | Split payment update |
|
|
660
|
+
| `secretEncryptedMessage` | Secret encrypted |
|
|
661
|
+
| `placeholderMessage` | Placeholder |
|
|
662
|
+
| `questionResponseMessage` | Question response |
|
|
663
|
+
| `vpcRequestMessage` | VPC request |
|
|
664
|
+
|
|
665
|
+
</details>
|
|
666
|
+
|
|
667
|
+
---
|
|
668
|
+
|
|
669
|
+
### Text Messages
|
|
670
|
+
|
|
671
|
+
<details>
|
|
672
|
+
<summary><strong>Show text message examples</strong></summary>
|
|
673
|
+
|
|
674
|
+
```javascript
|
|
675
|
+
// Plain text
|
|
676
|
+
await sock.sendMessage(jid, { text: 'Hello World!' })
|
|
677
|
+
|
|
678
|
+
// With link preview (auto-detects URLs in text)
|
|
679
|
+
await sock.sendMessage(jid, { text: 'Check this out: https://github.com' })
|
|
680
|
+
|
|
681
|
+
// Disable link preview
|
|
682
|
+
await sock.sendMessage(jid, { text: 'https://example.com', linkPreview: false })
|
|
683
|
+
|
|
684
|
+
// Quote / reply to a message
|
|
685
|
+
await sock.sendMessage(jid, { text: 'This is a reply' }, { quoted: message })
|
|
686
|
+
|
|
687
|
+
// Mention users in a message
|
|
688
|
+
await sock.sendMessage(jid, {
|
|
689
|
+
text: '@1234567890 hey!',
|
|
690
|
+
mentions: ['1234567890@s.whatsapp.net']
|
|
691
|
+
})
|
|
692
|
+
|
|
693
|
+
// Mark as AI-generated — per-message (content flag)
|
|
694
|
+
await sock.sendMessage(jid, { text: 'AI response here', ai: true })
|
|
695
|
+
|
|
696
|
+
// Mark as AI-generated — per-message (options flag)
|
|
697
|
+
await sock.sendMessage(jid, { text: 'AI response here' }, { ai: true })
|
|
698
|
+
|
|
699
|
+
// Mark as AI-generated — alias
|
|
700
|
+
await sock.sendMessage(jid, { text: 'AI response here' }, { aiLabel: true })
|
|
701
|
+
|
|
702
|
+
// Mark as AI-generated — global (every message from this socket)
|
|
703
|
+
const sock = makeWASocket({ aiLabel: true })
|
|
704
|
+
|
|
705
|
+
// Styled text — colored background or font
|
|
706
|
+
await sock.sendMessage(jid, {
|
|
707
|
+
text: 'Styled text',
|
|
708
|
+
// font: 0=SANS_SERIF 1=SERIF 2=NORICAN_REGULAR 3=BRYNDAN_WRITE 4=BEBASNEUE_REGULAR 5=OSWALD_HEAVY
|
|
709
|
+
// backgroundArgb / textArgb: ARGB color int e.g. 0xFF25D366
|
|
710
|
+
})
|
|
711
|
+
|
|
712
|
+
// Question message
|
|
713
|
+
await sock.sendMessage(jid, {
|
|
714
|
+
question: { text: 'What is your favorite color?', contextInfo: {} }
|
|
715
|
+
})
|
|
716
|
+
|
|
717
|
+
// Question reply
|
|
718
|
+
await sock.sendMessage(jid, {
|
|
719
|
+
questionReply: {
|
|
720
|
+
text: 'Blue!',
|
|
721
|
+
serverQuestionId: 12345,
|
|
722
|
+
quotedQuestion: msg.key,
|
|
723
|
+
}
|
|
724
|
+
})
|
|
725
|
+
|
|
726
|
+
// Question response
|
|
727
|
+
await sock.sendMessage(jid, {
|
|
728
|
+
questionResponse: { key: msg.key, text: 'My answer' }
|
|
729
|
+
})
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
</details>
|
|
733
|
+
|
|
734
|
+
---
|
|
735
|
+
|
|
736
|
+
### Delivery Mode
|
|
737
|
+
|
|
738
|
+
<details>
|
|
739
|
+
<summary><strong>Show delivery mode options</strong></summary>
|
|
740
|
+
|
|
741
|
+
Control which devices receive your message using the `deliveryMode` option. By default every device gets the message (`toAll`).
|
|
742
|
+
|
|
743
|
+
| Mode | Your Main | Your Companions | Recipient Main | Recipient Companions |
|
|
744
|
+
|------|-----------|-----------------|----------------|----------------------|
|
|
745
|
+
| `toAll` | ✅ | ✅ | ✅ | ✅ |
|
|
746
|
+
| `toMainOnly` | ✅ | ❌ | ✅ | ❌ |
|
|
747
|
+
| `toRecipientMain` | ✅ | ✅ | ✅ | ❌ |
|
|
748
|
+
| `toSelf` | ✅ | ✅ | ❌ | ❌ |
|
|
749
|
+
| `toRecipient` | ❌ | ❌ | ✅ | ✅ |
|
|
750
|
+
| `toSelfMain` | ✅ | ❌ | ❌ | ❌ |
|
|
751
|
+
| `toRecipientMainOnly` | ❌ | ❌ | ✅ | ❌ |
|
|
752
|
+
|
|
753
|
+
```javascript
|
|
754
|
+
// Everyone gets it (default)
|
|
755
|
+
await sock.sendMessage(jid, { text: 'Hello!' }, { deliveryMode: 'toAll' })
|
|
756
|
+
|
|
757
|
+
// Main phones only — no companion devices on either side
|
|
758
|
+
await sock.sendMessage(jid, { text: 'Hello!' }, { deliveryMode: 'toMainOnly' })
|
|
759
|
+
|
|
760
|
+
// Recipient's main phone only — your companions still get it
|
|
761
|
+
await sock.sendMessage(jid, { text: 'Hello!' }, { deliveryMode: 'toRecipientMain' })
|
|
762
|
+
|
|
763
|
+
// Your devices only — recipient gets nothing
|
|
764
|
+
await sock.sendMessage(jid, { text: 'Hello!' }, { deliveryMode: 'toSelf' })
|
|
765
|
+
|
|
766
|
+
// Recipient all devices — you see nothing
|
|
767
|
+
await sock.sendMessage(jid, { text: 'Hello!' }, { deliveryMode: 'toRecipient' })
|
|
768
|
+
|
|
769
|
+
// Your main phone only — nothing else
|
|
770
|
+
await sock.sendMessage(jid, { text: 'Hello!' }, { deliveryMode: 'toSelfMain' })
|
|
771
|
+
|
|
772
|
+
// Recipient main phone only — you see nothing
|
|
773
|
+
await sock.sendMessage(jid, { text: 'Hello!' }, { deliveryMode: 'toRecipientMainOnly' })
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
> `deliveryMode` is optional — omitting it defaults to `toAll`.
|
|
777
|
+
|
|
778
|
+
</details>
|
|
779
|
+
|
|
780
|
+
---
|
|
781
|
+
|
|
782
|
+
### Media Messages
|
|
783
|
+
|
|
784
|
+
<details>
|
|
785
|
+
<summary><strong>Image</strong></summary>
|
|
786
|
+
|
|
787
|
+
> You can pass `{ url: '...' }`, a `Buffer`, a file path string, or `{ stream: Stream }` for any media type.
|
|
788
|
+
|
|
789
|
+
```javascript
|
|
790
|
+
// From URL
|
|
791
|
+
await sock.sendMessage(jid, {
|
|
792
|
+
image: { url: 'https://example.com/image.jpg' },
|
|
793
|
+
caption: 'Caption here'
|
|
794
|
+
})
|
|
795
|
+
|
|
796
|
+
// From Buffer
|
|
797
|
+
await sock.sendMessage(jid, { image: buffer, caption: 'From buffer' })
|
|
798
|
+
|
|
799
|
+
// From file path
|
|
800
|
+
await sock.sendMessage(jid, { image: fs.readFileSync('./image.jpg') })
|
|
801
|
+
|
|
802
|
+
// View once — disappears after viewing
|
|
803
|
+
await sock.sendMessage(jid, { image: { url: './secret.jpg' }, viewOnce: true })
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
</details>
|
|
807
|
+
|
|
808
|
+
<details>
|
|
809
|
+
<summary><strong>Video</strong></summary>
|
|
810
|
+
|
|
811
|
+
```javascript
|
|
812
|
+
await sock.sendMessage(jid, {
|
|
813
|
+
video: { url: './video.mp4' },
|
|
814
|
+
caption: 'Watch this!',
|
|
815
|
+
gifPlayback: false, // true = render as looping GIF
|
|
816
|
+
ptv: false // true = video note (round circle)
|
|
817
|
+
})
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
</details>
|
|
821
|
+
|
|
822
|
+
<details>
|
|
823
|
+
<summary><strong>Audio</strong></summary>
|
|
824
|
+
|
|
825
|
+
```javascript
|
|
826
|
+
await sock.sendMessage(jid, {
|
|
827
|
+
audio: { url: './audio.mp3' },
|
|
828
|
+
mimetype: 'audio/mp4',
|
|
829
|
+
ptt: true // true = voice message, false = audio file
|
|
830
|
+
})
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
> Convert to voice-compatible format: `ffmpeg -i input.mp4 -avoid_negative_ts make_zero -ac 1 output.ogg`
|
|
834
|
+
|
|
835
|
+
</details>
|
|
836
|
+
|
|
837
|
+
<details>
|
|
838
|
+
<summary><strong>Document</strong></summary>
|
|
839
|
+
|
|
840
|
+
```javascript
|
|
841
|
+
await sock.sendMessage(jid, {
|
|
842
|
+
document: { url: './file.pdf' },
|
|
843
|
+
fileName: 'document.pdf',
|
|
844
|
+
mimetype: 'application/pdf',
|
|
845
|
+
caption: 'Here is the file'
|
|
846
|
+
})
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
</details>
|
|
850
|
+
|
|
851
|
+
<details>
|
|
852
|
+
<summary><strong>Sticker</strong></summary>
|
|
853
|
+
|
|
854
|
+
```javascript
|
|
855
|
+
// Basic sticker
|
|
856
|
+
await sock.sendMessage(jid, { sticker: { url: './sticker.webp' } })
|
|
857
|
+
|
|
858
|
+
// Premium sticker
|
|
859
|
+
await sock.sendMessage(jid, { sticker: buffer, premium: 1 })
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
</details>
|
|
863
|
+
|
|
864
|
+
<details>
|
|
865
|
+
<summary><strong>Location</strong></summary>
|
|
866
|
+
|
|
867
|
+
```javascript
|
|
868
|
+
// Static location pin
|
|
869
|
+
await sock.sendMessage(jid, {
|
|
870
|
+
location: {
|
|
871
|
+
degreesLatitude: 24.121231,
|
|
872
|
+
degreesLongitude: 55.1121221,
|
|
873
|
+
name: 'Location Name',
|
|
874
|
+
address: 'Full Address Here'
|
|
875
|
+
}
|
|
876
|
+
})
|
|
877
|
+
|
|
878
|
+
// Live location — streams real-time coordinates
|
|
879
|
+
await sock.sendMessage(jid, {
|
|
880
|
+
liveLocation: {
|
|
881
|
+
degreesLatitude: 6.5243793,
|
|
882
|
+
degreesLongitude: 3.3792057,
|
|
883
|
+
accuracyInMeters: 10,
|
|
884
|
+
speedInMps: 0,
|
|
885
|
+
degreesClockwiseFromMagneticNorth: 0,
|
|
886
|
+
caption: 'I am here',
|
|
887
|
+
sequenceNumber: 1,
|
|
888
|
+
timeOffset: 0,
|
|
889
|
+
}
|
|
890
|
+
})
|
|
891
|
+
|
|
892
|
+
// Request location from a user
|
|
893
|
+
await sock.sendMessage(jid, {
|
|
894
|
+
requestLocationMessage: { contextInfo: {} }
|
|
895
|
+
})
|
|
896
|
+
|
|
897
|
+
// Stop a live location stream
|
|
898
|
+
await sock.sendMessage(jid, {
|
|
899
|
+
requestLocationUpdateMessage: {
|
|
900
|
+
key: msg.key,
|
|
901
|
+
updateType: 1, // 1 = STOP
|
|
902
|
+
senderTimestampMs: Date.now(),
|
|
903
|
+
}
|
|
904
|
+
})
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
</details>
|
|
908
|
+
|
|
909
|
+
<details>
|
|
910
|
+
<summary><strong>Reaction</strong></summary>
|
|
911
|
+
|
|
912
|
+
```javascript
|
|
913
|
+
// Add a reaction
|
|
914
|
+
await sock.sendMessage(jid, {
|
|
915
|
+
react: {
|
|
916
|
+
text: '💖', // empty string '' removes the reaction
|
|
917
|
+
key: message.key
|
|
918
|
+
}
|
|
919
|
+
})
|
|
920
|
+
```
|
|
921
|
+
|
|
922
|
+
</details>
|
|
923
|
+
|
|
924
|
+
---
|
|
925
|
+
|
|
926
|
+
### Contact Messages
|
|
927
|
+
|
|
928
|
+
<details>
|
|
929
|
+
<summary><strong>Show contact message examples</strong></summary>
|
|
930
|
+
|
|
931
|
+
```javascript
|
|
932
|
+
// Standard contact card
|
|
933
|
+
const vcard = 'BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nORG:zervonex;\nTEL;type=CELL;waid=1234567890:+1 234 567 890\nEND:VCARD'
|
|
934
|
+
|
|
935
|
+
await sock.sendMessage(jid, {
|
|
936
|
+
contacts: {
|
|
937
|
+
displayName: 'John Doe',
|
|
938
|
+
contacts: [{ vcard }]
|
|
939
|
+
}
|
|
940
|
+
})
|
|
941
|
+
|
|
942
|
+
// Direct proto field — single contact
|
|
943
|
+
await sock.sendMessage(jid, {
|
|
944
|
+
contactMessage: {
|
|
945
|
+
displayName: 'John Doe',
|
|
946
|
+
vcard: 'BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL:+2341234567890\nEND:VCARD',
|
|
947
|
+
}
|
|
948
|
+
})
|
|
949
|
+
|
|
950
|
+
// Multiple contacts in one message
|
|
951
|
+
await sock.sendMessage(jid, {
|
|
952
|
+
contactsArrayMessage: {
|
|
953
|
+
displayName: 'Contacts',
|
|
954
|
+
contacts: [
|
|
955
|
+
{ displayName: 'John Doe', vcard: 'BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL:+234...\nEND:VCARD' },
|
|
956
|
+
{ displayName: 'Jane Doe', vcard: 'BEGIN:VCARD\nVERSION:3.0\nFN:Jane Doe\nTEL:+234...\nEND:VCARD' },
|
|
957
|
+
]
|
|
958
|
+
}
|
|
959
|
+
})
|
|
960
|
+
|
|
961
|
+
// Share your own phone number with the recipient
|
|
962
|
+
await sock.sendMessage(jid, { sharePhoneNumber: true })
|
|
963
|
+
|
|
964
|
+
// Request the recipient's phone number
|
|
965
|
+
await sock.sendMessage(jid, {
|
|
966
|
+
requestPhoneNumberMessage: { contextInfo: {} }
|
|
967
|
+
})
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
</details>
|
|
971
|
+
|
|
972
|
+
---
|
|
973
|
+
|
|
974
|
+
### Buttons & Interactive Messages
|
|
975
|
+
|
|
976
|
+
<details>
|
|
977
|
+
<summary><strong>Native Flow Buttons (text, image, video, document)</strong></summary>
|
|
978
|
+
|
|
979
|
+
```javascript
|
|
980
|
+
// Text with native buttons
|
|
981
|
+
await sock.sendMessage(jid, {
|
|
982
|
+
text: 'Choose an option',
|
|
983
|
+
footer: '© zervonex',
|
|
984
|
+
buttons: [
|
|
985
|
+
{
|
|
986
|
+
name: 'quick_reply',
|
|
987
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Option 1', id: 'opt1' })
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
name: 'cta_url',
|
|
991
|
+
buttonParamsJson: JSON.stringify({
|
|
992
|
+
display_text: 'Visit Website',
|
|
993
|
+
url: 'https://zervonex.com',
|
|
994
|
+
merchant_url: 'https://zervonex.com'
|
|
995
|
+
})
|
|
996
|
+
}
|
|
997
|
+
]
|
|
998
|
+
})
|
|
999
|
+
|
|
1000
|
+
// Image / Video / Document with buttons
|
|
1001
|
+
await sock.sendMessage(jid, {
|
|
1002
|
+
image: { url: 'https://example.com/image.jpg' },
|
|
1003
|
+
caption: 'Description',
|
|
1004
|
+
footer: '© zervonex',
|
|
1005
|
+
buttons: [
|
|
1006
|
+
{
|
|
1007
|
+
name: 'quick_reply',
|
|
1008
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Reply', id: 'btn1' })
|
|
1009
|
+
}
|
|
1010
|
+
]
|
|
1011
|
+
})
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
</details>
|
|
1015
|
+
|
|
1016
|
+
<details>
|
|
1017
|
+
<summary><strong>All Button Types</strong></summary>
|
|
1018
|
+
|
|
1019
|
+
| Type | `name` value | Required params |
|
|
1020
|
+
|------|-------------|-----------------|
|
|
1021
|
+
| Quick Reply | `quick_reply` | `display_text`, `id` |
|
|
1022
|
+
| URL | `cta_url` | `display_text`, `url`, `merchant_url` |
|
|
1023
|
+
| Call | `cta_call` | `display_text`, `phone_number` |
|
|
1024
|
+
| Copy | `cta_copy` | `display_text`, `copy_code` |
|
|
1025
|
+
| Open Webview | `cta_open_webview` | `display_text`, `url` |
|
|
1026
|
+
| Reminder | `cta_reminder` | `display_text` |
|
|
1027
|
+
| Cancel Reminder | `cta_cancel_reminder` | `display_text` |
|
|
1028
|
+
| Address | `address` | `display_text` |
|
|
1029
|
+
| Send Location | `send_location` | `display_text` |
|
|
1030
|
+
| Flow | `flow` | `display_text`, `flow_id`, `flow_token` |
|
|
1031
|
+
| Catalog | `catalog` | `display_text` |
|
|
1032
|
+
| Review & Pay | `review_and_pay` | `display_text` |
|
|
1033
|
+
| Review Order | `review_order` | `display_text` |
|
|
1034
|
+
| Order Details | `order_details` | `display_text` |
|
|
1035
|
+
| Payment Status | `payment_status` | `display_text` |
|
|
1036
|
+
| Transaction Details | `transaction_details` | `display_text` |
|
|
1037
|
+
| List/Select | `single_select` | `title`, `sections[].rows[]` |
|
|
1038
|
+
|
|
1039
|
+
</details>
|
|
1040
|
+
|
|
1041
|
+
<details>
|
|
1042
|
+
<summary><strong>List / Single Select</strong></summary>
|
|
1043
|
+
|
|
1044
|
+
```javascript
|
|
1045
|
+
// Via sendMessage — text with sections
|
|
1046
|
+
await sock.sendMessage(jid, {
|
|
1047
|
+
text: 'Pick one',
|
|
1048
|
+
sections: [{ title: 'Options', rows: [{ title: 'Row 1', rowId: 'r1', description: 'Desc' }] }],
|
|
1049
|
+
buttonText: 'Choose',
|
|
1050
|
+
footer: 'Footer',
|
|
1051
|
+
})
|
|
1052
|
+
|
|
1053
|
+
// Via buttons array
|
|
1054
|
+
{
|
|
1055
|
+
name: 'single_select',
|
|
1056
|
+
buttonParamsJson: JSON.stringify({
|
|
1057
|
+
title: 'Select Option',
|
|
1058
|
+
sections: [{
|
|
1059
|
+
title: 'Section 1',
|
|
1060
|
+
highlight_label: 'Popular',
|
|
1061
|
+
rows: [
|
|
1062
|
+
{ title: 'Option 1', description: 'Desc 1', id: 'opt1' },
|
|
1063
|
+
{ title: 'Option 2', description: 'Desc 2', id: 'opt2' }
|
|
1064
|
+
]
|
|
1065
|
+
}]
|
|
1066
|
+
})
|
|
1067
|
+
}
|
|
1068
|
+
```
|
|
1069
|
+
|
|
1070
|
+
</details>
|
|
1071
|
+
|
|
1072
|
+
<details>
|
|
1073
|
+
<summary><strong>interactiveButtons Shorthand</strong></summary>
|
|
1074
|
+
|
|
1075
|
+
```javascript
|
|
1076
|
+
// Without media header
|
|
1077
|
+
await sock.sendMessage(jid, {
|
|
1078
|
+
text: 'Description of Message',
|
|
1079
|
+
title: 'Title of Message',
|
|
1080
|
+
subtitle: 'Subtitle Message',
|
|
1081
|
+
footer: 'Footer Message',
|
|
1082
|
+
interactiveButtons: [
|
|
1083
|
+
{
|
|
1084
|
+
name: 'quick_reply',
|
|
1085
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Quick Reply', id: 'button_1' })
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
name: 'cta_url',
|
|
1089
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Visit Website', url: 'https://zervonex.com' })
|
|
1090
|
+
}
|
|
1091
|
+
]
|
|
1092
|
+
}, { quoted: message })
|
|
1093
|
+
|
|
1094
|
+
// With image header
|
|
1095
|
+
await sock.sendMessage(jid, {
|
|
1096
|
+
image: { url: 'https://example.jpg' },
|
|
1097
|
+
caption: 'Description of Message',
|
|
1098
|
+
title: 'Title of Message',
|
|
1099
|
+
subtitle: 'Subtitle Message',
|
|
1100
|
+
footer: 'Footer Message',
|
|
1101
|
+
media: true,
|
|
1102
|
+
interactiveButtons: [
|
|
1103
|
+
{
|
|
1104
|
+
name: 'quick_reply',
|
|
1105
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Quick Reply', id: 'button_1' })
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: 'cta_url',
|
|
1109
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Visit Website', url: 'https://zervonex.com' })
|
|
1110
|
+
}
|
|
1111
|
+
]
|
|
1112
|
+
}, { quoted: message })
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
</details>
|
|
1116
|
+
|
|
1117
|
+
<details>
|
|
1118
|
+
<summary><strong>Button Reply, List Reply</strong></summary>
|
|
1119
|
+
|
|
1120
|
+
```javascript
|
|
1121
|
+
// Quick reply to a legacy button
|
|
1122
|
+
await sock.sendMessage(jid, {
|
|
1123
|
+
buttonReply: { displayText: 'Button 1', id: 'btn1', index: 0 },
|
|
1124
|
+
type: 'template'
|
|
1125
|
+
})
|
|
1126
|
+
|
|
1127
|
+
// Reply to a list selection
|
|
1128
|
+
await sock.sendMessage(jid, {
|
|
1129
|
+
listReply: { title: 'Title', singleSelectReply: { selectedRowId: 'r1' } }
|
|
1130
|
+
})
|
|
1131
|
+
```
|
|
1132
|
+
|
|
1133
|
+
</details>
|
|
1134
|
+
|
|
1135
|
+
<details>
|
|
1136
|
+
<summary><strong>Native Flow with Audio Footer</strong></summary>
|
|
1137
|
+
|
|
1138
|
+
```javascript
|
|
1139
|
+
// Message with an audio footer and quick reply button
|
|
1140
|
+
await sock.sendMessage(jid, {
|
|
1141
|
+
text: 'Listen to this',
|
|
1142
|
+
audioFooter: { url: 'https://example.com/audio.ogg' },
|
|
1143
|
+
buttons: [{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'OK', id: 'ok' }) }]
|
|
1144
|
+
})
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
</details>
|
|
1148
|
+
|
|
1149
|
+
<details>
|
|
1150
|
+
<summary><strong>WhatsApp Flow</strong></summary>
|
|
1151
|
+
|
|
1152
|
+
```javascript
|
|
1153
|
+
// Via sendWhatsAppFlow
|
|
1154
|
+
await sock.sendWhatsAppFlow(jid, {
|
|
1155
|
+
flowId: 'FLOW_ID',
|
|
1156
|
+
cta: 'Open form',
|
|
1157
|
+
mode: 'draft',
|
|
1158
|
+
text: 'Fill this form',
|
|
1159
|
+
})
|
|
1160
|
+
|
|
1161
|
+
// Via Button builder
|
|
1162
|
+
new sock.Button(sock)
|
|
1163
|
+
.setBody('Fill form')
|
|
1164
|
+
.flow('Open form', 'FLOW_ID', { token: 'tok' })
|
|
1165
|
+
.send(jid)
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
</details>
|
|
1169
|
+
|
|
1170
|
+
<details>
|
|
1171
|
+
<summary><strong>sendInteractiveMessage Shorthand</strong></summary>
|
|
1172
|
+
|
|
1173
|
+
```javascript
|
|
1174
|
+
// All-in-one interactive message helper
|
|
1175
|
+
await sock.sendInteractiveMessage(jid, {
|
|
1176
|
+
body: { text: 'Main message' },
|
|
1177
|
+
footer: { text: 'Footer' },
|
|
1178
|
+
header: { title: 'Title', hasMediaAttachment: false },
|
|
1179
|
+
buttons: [{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Yes', id: 'yes' }) }]
|
|
1180
|
+
}, quoted)
|
|
1181
|
+
```
|
|
1182
|
+
|
|
1183
|
+
</details>
|
|
1184
|
+
|
|
1185
|
+
<details>
|
|
1186
|
+
<summary><strong>Full Raw Interactive Message</strong></summary>
|
|
1187
|
+
|
|
1188
|
+
```javascript
|
|
1189
|
+
await sock.sendMessage(jid, {
|
|
1190
|
+
interactiveMessage: {
|
|
1191
|
+
title: 'Interactive',
|
|
1192
|
+
footer: '© zervonex',
|
|
1193
|
+
image: { url: 'https://example.com/image.jpg' },
|
|
1194
|
+
nativeFlowMessage: {
|
|
1195
|
+
messageParamsJson: JSON.stringify({ /* optional advanced config */ }),
|
|
1196
|
+
buttons: [
|
|
1197
|
+
{
|
|
1198
|
+
name: 'single_select',
|
|
1199
|
+
buttonParamsJson: JSON.stringify({
|
|
1200
|
+
title: 'Select',
|
|
1201
|
+
sections: [{ title: 'Options', rows: [{ title: 'Option 1', id: 'opt1' }] }]
|
|
1202
|
+
})
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
name: 'cta_copy',
|
|
1206
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Copy Code', copy_code: 'NEXUS2025' })
|
|
1207
|
+
}
|
|
1208
|
+
]
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
})
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
</details>
|
|
1215
|
+
|
|
1216
|
+
<details>
|
|
1217
|
+
<summary><strong>Classic Buttons (Legacy)</strong></summary>
|
|
1218
|
+
|
|
1219
|
+
For compatibility with older WhatsApp versions:
|
|
1220
|
+
|
|
1221
|
+
```javascript
|
|
1222
|
+
// Text with classic buttons
|
|
1223
|
+
await sock.sendMessage(jid, {
|
|
1224
|
+
text: 'Message with classic buttons',
|
|
1225
|
+
footer: 'Footer text',
|
|
1226
|
+
buttons: [
|
|
1227
|
+
{ buttonId: 'btn1', buttonText: { displayText: 'Button 1' }, type: 1 },
|
|
1228
|
+
{ buttonId: 'btn2', buttonText: { displayText: 'Button 2' }, type: 1 }
|
|
1229
|
+
],
|
|
1230
|
+
headerType: 1
|
|
1231
|
+
})
|
|
1232
|
+
|
|
1233
|
+
// Image header with classic buttons
|
|
1234
|
+
await sock.sendMessage(jid, {
|
|
1235
|
+
image: { url: 'https://example.com/image.jpg' },
|
|
1236
|
+
caption: 'Body text',
|
|
1237
|
+
footer: 'Footer',
|
|
1238
|
+
buttons: [
|
|
1239
|
+
{ buttonId: 'btn1', buttonText: { displayText: 'Button 1' }, type: 1 }
|
|
1240
|
+
],
|
|
1241
|
+
headerType: 3 // 3 = IMAGE
|
|
1242
|
+
})
|
|
1243
|
+
```
|
|
1244
|
+
|
|
1245
|
+
| `headerType` | Type |
|
|
1246
|
+
|---|---|
|
|
1247
|
+
| `1` | EMPTY (no header) |
|
|
1248
|
+
| `2` | TEXT |
|
|
1249
|
+
| `3` | DOCUMENT |
|
|
1250
|
+
| `4` | IMAGE |
|
|
1251
|
+
| `5` | VIDEO |
|
|
1252
|
+
| `6` | LOCATION |
|
|
1253
|
+
|
|
1254
|
+
</details>
|
|
1255
|
+
|
|
1256
|
+
---
|
|
1257
|
+
|
|
1258
|
+
### Extended Message Types
|
|
1259
|
+
|
|
1260
|
+
<details>
|
|
1261
|
+
<summary><strong>Album</strong></summary>
|
|
1262
|
+
|
|
1263
|
+
```javascript
|
|
1264
|
+
// Via sendMessage
|
|
1265
|
+
await sock.sendMessage(jid, {
|
|
1266
|
+
albumMessage: [
|
|
1267
|
+
{ image: { url: 'https://example.com/1.jpg' }, caption: 'Photo 1' },
|
|
1268
|
+
{ image: { url: 'https://example.com/2.jpg' }, caption: 'Photo 2' },
|
|
1269
|
+
{ video: { url: 'https://example.com/3.mp4' }, caption: 'Video 1' }
|
|
1270
|
+
]
|
|
1271
|
+
}, { albumDelay: 1500 })
|
|
1272
|
+
|
|
1273
|
+
// Via shorthand
|
|
1274
|
+
await sock.sendAlbumMessage(jid, [
|
|
1275
|
+
{ image: { url: 'https://example.com/1.jpg' }, caption: 'Photo 1' },
|
|
1276
|
+
{ video: { url: 'https://example.com/2.mp4' }, caption: 'Video 1' }
|
|
1277
|
+
], quoted)
|
|
1278
|
+
|
|
1279
|
+
// Via builder
|
|
1280
|
+
await sock.album()
|
|
1281
|
+
.image('https://example.com/1.jpg', 'Photo 1')
|
|
1282
|
+
.image('https://example.com/2.jpg', 'Photo 2')
|
|
1283
|
+
.video('https://example.com/3.mp4', 'Video 1')
|
|
1284
|
+
.send(jid)
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
</details>
|
|
1288
|
+
|
|
1289
|
+
<details>
|
|
1290
|
+
<summary><strong>Carousel</strong></summary>
|
|
1291
|
+
|
|
1292
|
+
```javascript
|
|
1293
|
+
// Via sendMessage
|
|
1294
|
+
await sock.sendMessage(jid, {
|
|
1295
|
+
carouselMessage: {
|
|
1296
|
+
caption: 'Our Products',
|
|
1297
|
+
footer: 'Powered by zervonex',
|
|
1298
|
+
cards: [
|
|
1299
|
+
{
|
|
1300
|
+
header: { title: 'Card 1', hasMediaAttachment: false },
|
|
1301
|
+
body: { text: 'Description of card 1' },
|
|
1302
|
+
footer: { text: 'Footer' },
|
|
1303
|
+
nativeFlowMessage: {
|
|
1304
|
+
buttons: [
|
|
1305
|
+
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Select', id: 'card1' }) },
|
|
1306
|
+
{ name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: 'Learn More', url: 'https://zervonex.com' }) }
|
|
1307
|
+
]
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
]
|
|
1311
|
+
}
|
|
1312
|
+
})
|
|
1313
|
+
|
|
1314
|
+
// Via builder
|
|
1315
|
+
await sock.carousel()
|
|
1316
|
+
.setCaption('Our Products')
|
|
1317
|
+
.setFooter('Powered by zervonex')
|
|
1318
|
+
.card(sock.button().setBody('Card 1 description').reply('Select', 'card1').url('Learn More', 'https://zervonex.com'))
|
|
1319
|
+
.card(sock.button().setBody('Card 2 description').reply('Select', 'card2'))
|
|
1320
|
+
.send(jid)
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
</details>
|
|
1324
|
+
|
|
1325
|
+
<details>
|
|
1326
|
+
<summary><strong>Pin, Keep, Disappearing, Forward, Edit, Delete</strong></summary>
|
|
1327
|
+
|
|
1328
|
+
```javascript
|
|
1329
|
+
// Pin a message (time in seconds: 86400=24h, 604800=7d, 2592000=30d)
|
|
1330
|
+
await sock.sendMessage(jid, {
|
|
1331
|
+
pin: { type: 1, time: 86400, key: message.key }
|
|
1332
|
+
})
|
|
1333
|
+
|
|
1334
|
+
// Unpin
|
|
1335
|
+
await sock.sendMessage(jid, {
|
|
1336
|
+
pin: { type: 0, time: 0, key: message.key }
|
|
1337
|
+
})
|
|
1338
|
+
|
|
1339
|
+
// Keep a message
|
|
1340
|
+
await sock.sendMessage(jid, { keep: message.key, type: 1, time: 86400 })
|
|
1341
|
+
|
|
1342
|
+
// Unkeep a message
|
|
1343
|
+
await sock.sendMessage(jid, { keep: message.key, type: 2 })
|
|
1344
|
+
|
|
1345
|
+
// Enable disappearing messages (86400 = 24h, 604800 = 7d, 7776000 = 90d)
|
|
1346
|
+
await sock.sendMessage(jid, { disappearingMessagesInChat: 86400 })
|
|
1347
|
+
|
|
1348
|
+
// Disable disappearing messages
|
|
1349
|
+
await sock.sendMessage(jid, { disappearingMessagesInChat: false })
|
|
1350
|
+
|
|
1351
|
+
// Forward a message
|
|
1352
|
+
await sock.sendMessage(jid, { forward: message, force: true })
|
|
1353
|
+
|
|
1354
|
+
// Edit a sent message
|
|
1355
|
+
await sock.sendMessage(jid, { text: 'Updated text', edit: originalMessage.key })
|
|
1356
|
+
|
|
1357
|
+
// Delete a message for everyone
|
|
1358
|
+
const sent = await sock.sendMessage(jid, { text: 'hello' })
|
|
1359
|
+
await sock.sendMessage(jid, { delete: sent.key })
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
</details>
|
|
1363
|
+
|
|
1364
|
+
<details>
|
|
1365
|
+
<summary><strong>Order</strong></summary>
|
|
1366
|
+
|
|
1367
|
+
```javascript
|
|
1368
|
+
// Via sendMessage
|
|
1369
|
+
await sock.sendMessage(jid, {
|
|
1370
|
+
orderMessage: {
|
|
1371
|
+
orderId: 'ORDER_001',
|
|
1372
|
+
itemCount: 3,
|
|
1373
|
+
totalAmount1000: 45000000,
|
|
1374
|
+
totalCurrencyCode: 'NGN',
|
|
1375
|
+
orderTitle: 'My Order',
|
|
1376
|
+
message: 'Thank you for your order',
|
|
1377
|
+
sellerJid: sock.user.id,
|
|
1378
|
+
thumbnail: { url: 'https://example.com/product.jpg' }
|
|
1379
|
+
}
|
|
1380
|
+
})
|
|
1381
|
+
|
|
1382
|
+
// Via builder
|
|
1383
|
+
await sock.order()
|
|
1384
|
+
.from({ orderId: 'ORDER_001', itemCount: 3, totalAmount1000: 45000000, totalCurrencyCode: 'NGN', orderTitle: 'My Order' })
|
|
1385
|
+
.send(jid)
|
|
1386
|
+
```
|
|
1387
|
+
|
|
1388
|
+
</details>
|
|
1389
|
+
|
|
1390
|
+
<details>
|
|
1391
|
+
<summary><strong>Product Message</strong></summary>
|
|
1392
|
+
|
|
1393
|
+
```javascript
|
|
1394
|
+
await sock.sendMessage(jid, {
|
|
1395
|
+
productMessage: {
|
|
1396
|
+
title: 'Product Title',
|
|
1397
|
+
description: 'Product Description',
|
|
1398
|
+
thumbnail: 'https://example.com/img.png',
|
|
1399
|
+
productId: '123456789',
|
|
1400
|
+
retailerId: 'STORE',
|
|
1401
|
+
url: 'https://example.com',
|
|
1402
|
+
body: 'Product Body',
|
|
1403
|
+
footer: 'Product Footer',
|
|
1404
|
+
buttons: [
|
|
1405
|
+
{
|
|
1406
|
+
name: 'cta_url',
|
|
1407
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Buy Now', url: 'https://example.com' })
|
|
1408
|
+
}
|
|
1409
|
+
]
|
|
1410
|
+
}
|
|
1411
|
+
}, { quoted: message })
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
</details>
|
|
1415
|
+
|
|
1416
|
+
<details>
|
|
1417
|
+
<summary><strong>Poll Result</strong></summary>
|
|
1418
|
+
|
|
1419
|
+
```javascript
|
|
1420
|
+
// Poll result snapshot — newsletter style
|
|
1421
|
+
await sock.sendMessage(jid, {
|
|
1422
|
+
pollResult: {
|
|
1423
|
+
name: 'Poll Title',
|
|
1424
|
+
votes: [['Option A', 42], ['Option B', 17]]
|
|
1425
|
+
}
|
|
1426
|
+
}, { quoted: message })
|
|
1427
|
+
```
|
|
1428
|
+
|
|
1429
|
+
</details>
|
|
1430
|
+
|
|
1431
|
+
<details>
|
|
1432
|
+
<summary><strong>Group Story</strong></summary>
|
|
1433
|
+
|
|
1434
|
+
Post a story/status visible only to a specific group.
|
|
1435
|
+
|
|
1436
|
+
```javascript
|
|
1437
|
+
// Via sendMessage
|
|
1438
|
+
await sock.sendMessage(jid, { groupStatus: { text: 'Hello group!' } })
|
|
1439
|
+
await sock.sendMessage(jid, { groupStatus: { image: { url: 'https://example.com/image.jpg' }, caption: 'Caption' } })
|
|
1440
|
+
await sock.sendMessage(jid, { groupStatus: { video: { url: 'https://example.com/video.mp4' }, caption: 'Caption' } })
|
|
1441
|
+
await sock.sendMessage(jid, { groupStatus: { audio: { url: 'https://example.com/audio.mp3' }, ptt: false } })
|
|
1442
|
+
|
|
1443
|
+
// Via shorthand
|
|
1444
|
+
await sock.sendGroupStatusMessage(groupJid, { text: 'Hello group!' })
|
|
1445
|
+
await sock.sendGroupStatusMessage(groupJid, { image: { url: 'https://example.com/image.jpg' }, caption: 'Caption' })
|
|
1446
|
+
await sock.sendGroupStatusMessage(groupJid, { image: buffer })
|
|
1447
|
+
await sock.sendGroupStatusMessage(groupJid, { image: fs.readFileSync('./image.jpg') })
|
|
1448
|
+
```
|
|
1449
|
+
|
|
1450
|
+
</details>
|
|
1451
|
+
|
|
1452
|
+
---
|
|
1453
|
+
|
|
1454
|
+
### Poll Messages
|
|
1455
|
+
|
|
1456
|
+
<details>
|
|
1457
|
+
<summary><strong>Show poll message examples</strong></summary>
|
|
1458
|
+
|
|
1459
|
+
```javascript
|
|
1460
|
+
// Standard poll
|
|
1461
|
+
await sock.sendMessage(jid, {
|
|
1462
|
+
poll: {
|
|
1463
|
+
name: 'Favorite Color?',
|
|
1464
|
+
values: ['Red', 'Blue', 'Green'],
|
|
1465
|
+
selectableOptionsCount: 1,
|
|
1466
|
+
toAnnouncementGroup: false
|
|
1467
|
+
}
|
|
1468
|
+
})
|
|
1469
|
+
|
|
1470
|
+
// Quiz poll — single correct answer
|
|
1471
|
+
await sock.sendMessage(jid, {
|
|
1472
|
+
poll: {
|
|
1473
|
+
name: 'What is 2+2?',
|
|
1474
|
+
values: ['3', '4', '5'],
|
|
1475
|
+
selectableOptionsCount: 1,
|
|
1476
|
+
pollType: 1, // 1 = quiz mode
|
|
1477
|
+
correctAnswer: '4'
|
|
1478
|
+
}
|
|
1479
|
+
})
|
|
1480
|
+
|
|
1481
|
+
// Timed poll with hidden voter names
|
|
1482
|
+
await sock.sendMessage(jid, {
|
|
1483
|
+
poll: {
|
|
1484
|
+
name: 'Quick vote!',
|
|
1485
|
+
values: ['Yes', 'No'],
|
|
1486
|
+
endTime: Math.floor(Date.now() / 1000) + 3600, // expires in 1 hour
|
|
1487
|
+
hideParticipantName: true,
|
|
1488
|
+
allowAddOption: false
|
|
1489
|
+
}
|
|
1490
|
+
})
|
|
1491
|
+
|
|
1492
|
+
// Add a new option to an existing poll
|
|
1493
|
+
await sock.sendMessage(jid, {
|
|
1494
|
+
pollAddOption: {
|
|
1495
|
+
pollCreationMessageKey: pollMsg.key,
|
|
1496
|
+
option: 'New Option',
|
|
1497
|
+
}
|
|
1498
|
+
})
|
|
1499
|
+
|
|
1500
|
+
// Add option via proto passthrough
|
|
1501
|
+
await sock.sendMessage(jid, {
|
|
1502
|
+
pollAddOptionMessage: {
|
|
1503
|
+
pollCreationMessageKey: existingPollMsg.key,
|
|
1504
|
+
addOption: { optionName: 'New Option' }
|
|
1505
|
+
}
|
|
1506
|
+
})
|
|
1507
|
+
|
|
1508
|
+
// Manual poll vote update (usually handled internally)
|
|
1509
|
+
await sock.sendMessage(jid, {
|
|
1510
|
+
pollUpdateMessage: {
|
|
1511
|
+
pollCreationMessageKey: pollMsg.key,
|
|
1512
|
+
vote: { encPayload: Buffer, encIv: Buffer },
|
|
1513
|
+
senderTimestampMs: Date.now(),
|
|
1514
|
+
}
|
|
1515
|
+
})
|
|
1516
|
+
|
|
1517
|
+
// Poll builder shorthand
|
|
1518
|
+
await sock.poll()
|
|
1519
|
+
.name('Favorite Color?')
|
|
1520
|
+
.options(['Red', 'Blue', 'Green'])
|
|
1521
|
+
.send(jid)
|
|
1522
|
+
```
|
|
1523
|
+
|
|
1524
|
+
</details>
|
|
1525
|
+
|
|
1526
|
+
---
|
|
1527
|
+
|
|
1528
|
+
### Payment Messages
|
|
1529
|
+
|
|
1530
|
+
<details>
|
|
1531
|
+
<summary><strong>Show payment message examples</strong></summary>
|
|
1532
|
+
|
|
1533
|
+
```javascript
|
|
1534
|
+
// Request payment from a user
|
|
1535
|
+
await sock.sendMessage(jid, {
|
|
1536
|
+
requestPayment: {
|
|
1537
|
+
amount: 5000,
|
|
1538
|
+
currency: 'NGN',
|
|
1539
|
+
note: 'Pay for order',
|
|
1540
|
+
from: '234xxx@s.whatsapp.net',
|
|
1541
|
+
expiry: Math.floor(Date.now() / 1000) + 86400, // expires in 24h
|
|
1542
|
+
}
|
|
1543
|
+
})
|
|
1544
|
+
|
|
1545
|
+
// Via builder
|
|
1546
|
+
await sock.payment()
|
|
1547
|
+
.setCurrency('NGN')
|
|
1548
|
+
.setAmount(10000000)
|
|
1549
|
+
.setFrom('1234567890@s.whatsapp.net')
|
|
1550
|
+
.setNote('Payment for order #123')
|
|
1551
|
+
.setExpiry(Date.now() + 86400000)
|
|
1552
|
+
.send(jid)
|
|
1553
|
+
|
|
1554
|
+
// Decline a payment request
|
|
1555
|
+
await sock.sendMessage(jid, {
|
|
1556
|
+
declinePaymentRequest: { key: paymentMsg.key }
|
|
1557
|
+
})
|
|
1558
|
+
|
|
1559
|
+
// Cancel a payment request
|
|
1560
|
+
await sock.sendMessage(jid, {
|
|
1561
|
+
cancelPaymentRequest: { key: paymentMsg.key }
|
|
1562
|
+
})
|
|
1563
|
+
|
|
1564
|
+
// Payment invite (UPI, PIX, etc.)
|
|
1565
|
+
await sock.sendMessage(jid, {
|
|
1566
|
+
paymentInviteMessage: {
|
|
1567
|
+
serviceType: 3, // 1=FBPAY 2=NOVI 3=UPI 4=PIX
|
|
1568
|
+
expiryTimestamp: Math.floor(Date.now() / 1000) + 86400,
|
|
1569
|
+
incentiveEligible: false,
|
|
1570
|
+
inviteType: 0, // 0=DEFAULT 1=MAPPER
|
|
1571
|
+
}
|
|
1572
|
+
})
|
|
1573
|
+
|
|
1574
|
+
// Payment reminder — recurring billing
|
|
1575
|
+
await sock.sendMessage(jid, {
|
|
1576
|
+
paymentReminderMessage: {
|
|
1577
|
+
reminderId: 'rem_001',
|
|
1578
|
+
description: 'Monthly subscription',
|
|
1579
|
+
frequency: 3, // 1=WEEKLY 2=BI_WEEKLY 3=MONTHLY 4=QUARTERLY
|
|
1580
|
+
status: 1, // 1=ACTIVE
|
|
1581
|
+
payeeJid: '234xxx@s.whatsapp.net',
|
|
1582
|
+
payerJid: '234yyy@s.whatsapp.net',
|
|
1583
|
+
amount: { value: 9900, offset: 2, currencyCode: 'NGN' }, // = ₦99.00
|
|
1584
|
+
}
|
|
1585
|
+
})
|
|
1586
|
+
|
|
1587
|
+
// Payment receipt / confirmation
|
|
1588
|
+
await sock.sendMessage(jid, {
|
|
1589
|
+
paymentDetailsMessage: {
|
|
1590
|
+
serviceType: 1,
|
|
1591
|
+
amount: { value: 5000, offset: 2, currencyCode: 'NGN' },
|
|
1592
|
+
payeeName: 'John Doe',
|
|
1593
|
+
payerName: 'Jane Doe',
|
|
1594
|
+
transactionTimestampMs: Date.now(),
|
|
1595
|
+
transactionId: 'TXN123456',
|
|
1596
|
+
status: 1, // 1=SUCCESS
|
|
1597
|
+
}
|
|
1598
|
+
})
|
|
1599
|
+
|
|
1600
|
+
// Split payment update
|
|
1601
|
+
await sock.sendMessage(jid, {
|
|
1602
|
+
splitPaymentUpdateMessage: {
|
|
1603
|
+
splitId: 'split_001',
|
|
1604
|
+
participantJid: '234xxx@s.whatsapp.net',
|
|
1605
|
+
}
|
|
1606
|
+
})
|
|
1607
|
+
```
|
|
1608
|
+
|
|
1609
|
+
</details>
|
|
1610
|
+
|
|
1611
|
+
---
|
|
1612
|
+
|
|
1613
|
+
### Event & Scheduled Calls
|
|
1614
|
+
|
|
1615
|
+
<details>
|
|
1616
|
+
<summary><strong>Show event and scheduled call examples</strong></summary>
|
|
1617
|
+
|
|
1618
|
+
```javascript
|
|
1619
|
+
// Event / calendar invite
|
|
1620
|
+
await sock.sendMessage(jid, {
|
|
1621
|
+
eventMessage: {
|
|
1622
|
+
name: 'NexusTech Conference',
|
|
1623
|
+
description: 'Annual developer conference',
|
|
1624
|
+
location: { degreesLatitude: 6.5244, degreesLongitude: 3.3792, name: 'Lagos, Nigeria' },
|
|
1625
|
+
joinLink: 'https://meet.example.com/nexusconf',
|
|
1626
|
+
startTime: Math.floor(Date.now() / 1000) + 86400,
|
|
1627
|
+
endTime: Math.floor(Date.now() / 1000) + 172800,
|
|
1628
|
+
extraGuestsAllowed: true,
|
|
1629
|
+
hasReminder: true,
|
|
1630
|
+
reminderOffsetSec: 3600 // remind 1 hour before
|
|
1631
|
+
}
|
|
1632
|
+
})
|
|
1633
|
+
|
|
1634
|
+
// Event invite message
|
|
1635
|
+
await sock.sendMessage(jid, {
|
|
1636
|
+
eventInvite: {
|
|
1637
|
+
eventId: 'evt_001',
|
|
1638
|
+
eventTitle: 'Party Night',
|
|
1639
|
+
startTime: new Date('2026-12-01T20:00:00'),
|
|
1640
|
+
endTime: new Date('2026-12-02T02:00:00'),
|
|
1641
|
+
caption: 'You are invited!',
|
|
1642
|
+
jpegThumbnail: buffer,
|
|
1643
|
+
}
|
|
1644
|
+
})
|
|
1645
|
+
|
|
1646
|
+
// Via builder
|
|
1647
|
+
await sock.event()
|
|
1648
|
+
.setName('NexusTech Conference 2026')
|
|
1649
|
+
.setDescription('Annual developer meetup')
|
|
1650
|
+
.setLocation({ degreesLatitude: 6.5244, degreesLongitude: 3.3792, name: 'Lagos, Nigeria' })
|
|
1651
|
+
.setJoinLink('https://meet.example.com/nexusconf')
|
|
1652
|
+
.setStartTime(Math.floor(Date.now() / 1000) + 86400)
|
|
1653
|
+
.setEndTime(Math.floor(Date.now() / 1000) + 172800)
|
|
1654
|
+
.setReminder(3600)
|
|
1655
|
+
.send(jid)
|
|
1656
|
+
|
|
1657
|
+
// Scheduled call — create
|
|
1658
|
+
await sock.sendMessage(jid, {
|
|
1659
|
+
scheduledCall: {
|
|
1660
|
+
scheduledTimestampMs: new Date('2026-12-01T10:00:00').getTime(),
|
|
1661
|
+
callType: 1, // 0=UNKNOWN 1=AUDIO 2=VIDEO
|
|
1662
|
+
title: 'Team Standup',
|
|
1663
|
+
}
|
|
1664
|
+
})
|
|
1665
|
+
|
|
1666
|
+
// Scheduled call — cancel or edit
|
|
1667
|
+
await sock.sendMessage(jid, {
|
|
1668
|
+
scheduledCallEdit: {
|
|
1669
|
+
key: scheduledCallMsg.key,
|
|
1670
|
+
editType: 1, // 0=UNKNOWN 1=CANCEL
|
|
1671
|
+
}
|
|
1672
|
+
})
|
|
1673
|
+
```
|
|
1674
|
+
|
|
1675
|
+
</details>
|
|
1676
|
+
|
|
1677
|
+
---
|
|
1678
|
+
|
|
1679
|
+
### Call Messages
|
|
1680
|
+
|
|
1681
|
+
<details>
|
|
1682
|
+
<summary><strong>Show call message examples</strong></summary>
|
|
1683
|
+
|
|
1684
|
+
```javascript
|
|
1685
|
+
// Initiate a call at protocol level
|
|
1686
|
+
await sock.sendMessage(jid, {
|
|
1687
|
+
call: {
|
|
1688
|
+
callKey: Buffer.from(crypto.randomBytes(32)),
|
|
1689
|
+
contextInfo: {},
|
|
1690
|
+
}
|
|
1691
|
+
})
|
|
1692
|
+
|
|
1693
|
+
// Call log — record a missed, received, or failed call
|
|
1694
|
+
await sock.sendMessage(jid, {
|
|
1695
|
+
callLogMesssage: { // note: 3 s's — typo in proto definition
|
|
1696
|
+
isVideo: false,
|
|
1697
|
+
callOutcome: 2, // 1=CONNECTED 2=MISSED 3=REJECTED 4=FAILED
|
|
1698
|
+
durationSecs: 0,
|
|
1699
|
+
callType: 0, // 0=REGULAR 1=ENCRYPTED
|
|
1700
|
+
}
|
|
1701
|
+
})
|
|
1702
|
+
```
|
|
1703
|
+
|
|
1704
|
+
</details>
|
|
1705
|
+
|
|
1706
|
+
---
|
|
1707
|
+
|
|
1708
|
+
### AI Rich Messages
|
|
1709
|
+
|
|
1710
|
+
<details>
|
|
1711
|
+
<summary><strong>Overview & sendMessage API</strong></summary>
|
|
1712
|
+
|
|
1713
|
+
All types can be sent two ways:
|
|
1714
|
+
- **`sock.sendMessage`** with an `aiRich` content key
|
|
1715
|
+
- **`sock.airich()` builder** (fluent chain)
|
|
1716
|
+
|
|
1717
|
+
```javascript
|
|
1718
|
+
// via sendMessage — everything in one object
|
|
1719
|
+
await sock.sendMessage(jid, {
|
|
1720
|
+
aiRich: {
|
|
1721
|
+
parts: [
|
|
1722
|
+
{ type: 'text', content: '## String Reversal' },
|
|
1723
|
+
{ type: 'code', language: 'javascript', content: `const reverse = s => s.split('').reverse().join('')` },
|
|
1724
|
+
{ type: 'text', content: 'Performance:' },
|
|
1725
|
+
{ type: 'table', table: ['Benchmarks', ['Method', 'Ops/sec'], ['split.reverse.join', '1.2M'], ['manual loop', '2.1M']] },
|
|
1726
|
+
{ type: 'sources', sources: [{ url: 'https://jsperf.app', displayName: 'JSPerf', subtitle: 'jsperf.app' }] }
|
|
1727
|
+
],
|
|
1728
|
+
footer: '_zervonex_'
|
|
1729
|
+
}
|
|
1730
|
+
}, { quoted: message })
|
|
1731
|
+
```
|
|
1732
|
+
|
|
1733
|
+
**`aiRich` Options Reference:**
|
|
1734
|
+
|
|
1735
|
+
| Key | Type | Description |
|
|
1736
|
+
|-----|------|-------------|
|
|
1737
|
+
| `text` | `string` | Single markdown text block |
|
|
1738
|
+
| `texts` | `string[]` | Multiple text blocks in order |
|
|
1739
|
+
| `code` | `string \| { language, code }` | Single code block |
|
|
1740
|
+
| `codes` | `Array` | Multiple code blocks |
|
|
1741
|
+
| `language` | `string` | Default language for `code`/`codes` |
|
|
1742
|
+
| `table` | `Array` | `[title, headers[], ...rows[]]` |
|
|
1743
|
+
| `headers` + `rows` | `Array` | Alternative table format |
|
|
1744
|
+
| `images` | `Array` | Grid images with `url`, `sourceUrl` |
|
|
1745
|
+
| `sources` | `Array` | Search source cards |
|
|
1746
|
+
| `reels` | `Array` | Horizontal reel cards |
|
|
1747
|
+
| `latex` | `Array` | LaTeX expression objects |
|
|
1748
|
+
| `latexText` | `string` | Text shown above latex |
|
|
1749
|
+
| `parts` | `Array` | Composite ordered parts array |
|
|
1750
|
+
| `header` | `string` | Text prepended before content |
|
|
1751
|
+
| `footer` | `string` | Text appended after content |
|
|
1752
|
+
| `botJid` | `string` | Custom bot JID |
|
|
1753
|
+
| `responseId` | `string` | Custom response UUID |
|
|
1754
|
+
| `forwarded` | `boolean` | Set `false` to disable forwarded context |
|
|
1755
|
+
| `rawSections` | `Array` | Raw unified response sections (advanced) |
|
|
1756
|
+
| `rawSubmessages` | `Array` | Matching submessages for `rawSections` |
|
|
1757
|
+
|
|
1758
|
+
</details>
|
|
1759
|
+
|
|
1760
|
+
<details>
|
|
1761
|
+
<summary><strong>Builder — text, code, table, dividers, spacers</strong></summary>
|
|
1762
|
+
|
|
1763
|
+
```javascript
|
|
1764
|
+
// Text, code and table
|
|
1765
|
+
await sock.airich()
|
|
1766
|
+
.setTitle('zervonex Bot')
|
|
1767
|
+
.setFooter('Powered by @zervonexx/baileys')
|
|
1768
|
+
.addText('*Welcome!*')
|
|
1769
|
+
.addCode('javascript', 'console.log("Hello from zervonex")')
|
|
1770
|
+
.addTable([
|
|
1771
|
+
['Plan', 'Price', 'Sessions'],
|
|
1772
|
+
['Basic', 'Free', '1'],
|
|
1773
|
+
['Pro', '$9/mo', '10'],
|
|
1774
|
+
['Enterprise', 'Custom', 'Unlimited']
|
|
1775
|
+
])
|
|
1776
|
+
.send(jid)
|
|
1777
|
+
|
|
1778
|
+
// Dividers and spacers
|
|
1779
|
+
await sock.airich()
|
|
1780
|
+
.addText('*Section A*')
|
|
1781
|
+
.addDivider() // horizontal line
|
|
1782
|
+
.addText('*Section B*')
|
|
1783
|
+
.addDivider('DOT') // dotted divider
|
|
1784
|
+
.addText('*Section C*')
|
|
1785
|
+
.addSpacer(3) // 3-line blank gap
|
|
1786
|
+
.addText('*Section D*')
|
|
1787
|
+
.send(jid)
|
|
1788
|
+
|
|
1789
|
+
// Task queue
|
|
1790
|
+
await sock.airich()
|
|
1791
|
+
.setTitle('Job Queue')
|
|
1792
|
+
.addTask({ taskId: 'task-1', title: 'Fetch data', subtitle: 'Calling API', status: 'DONE' })
|
|
1793
|
+
.addTask({ taskId: 'task-2', title: 'Process result', status: 'RUNNING' })
|
|
1794
|
+
.addTask({ taskId: 'task-3', title: 'Send response', status: 'PENDING' })
|
|
1795
|
+
.send(jid)
|
|
1796
|
+
|
|
1797
|
+
// Thinking / progress status
|
|
1798
|
+
await sock.airich()
|
|
1799
|
+
.addThinkingStatus('Searching the web...', 'WEB_SEARCH')
|
|
1800
|
+
.addThinkingStatus('Thinking deeply...', 'THINKING')
|
|
1801
|
+
.addProgressStatus('Almost done — 80%', true)
|
|
1802
|
+
.addProgressStatus('Done!', false)
|
|
1803
|
+
.send(jid)
|
|
1804
|
+
```
|
|
1805
|
+
|
|
1806
|
+
</details>
|
|
1807
|
+
|
|
1808
|
+
<details>
|
|
1809
|
+
<summary><strong>LaTeX</strong></summary>
|
|
1810
|
+
|
|
1811
|
+
```javascript
|
|
1812
|
+
// Via sendMessage
|
|
1813
|
+
await sock.sendMessage(jid, {
|
|
1814
|
+
aiRich: {
|
|
1815
|
+
latexText: 'The quadratic formula:',
|
|
1816
|
+
latex: [
|
|
1817
|
+
{ latexExpression: 'x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}', url: 'https://example.com/formula.png', width: 400, height: 80 }
|
|
1818
|
+
]
|
|
1819
|
+
}
|
|
1820
|
+
}, { quoted: message })
|
|
1821
|
+
|
|
1822
|
+
// Via builder
|
|
1823
|
+
await sock.airich()
|
|
1824
|
+
.addText("Einstein's famous equation:")
|
|
1825
|
+
.addLatex({ expression: 'E = mc^2', imageUrl: 'https://example.com/emc2.png', width: 300, height: 60 })
|
|
1826
|
+
.send(jid)
|
|
1827
|
+
|
|
1828
|
+
// Via shorthand
|
|
1829
|
+
await sock.sendLatex(jid, [
|
|
1830
|
+
{ latexExpression: 'E = mc^2', url: 'https://example.com/emc2.png', width: 300, height: 60 }
|
|
1831
|
+
], quoted, { text: 'Mass-energy equivalence:' })
|
|
1832
|
+
```
|
|
1833
|
+
|
|
1834
|
+
> Note: LaTeX requires a pre-rendered image URL — WhatsApp does not render LaTeX client-side.
|
|
1835
|
+
|
|
1836
|
+
</details>
|
|
1837
|
+
|
|
1838
|
+
<details>
|
|
1839
|
+
<summary><strong>Post & Product Cards, Map, Rich Map, Dynamic</strong></summary>
|
|
1840
|
+
|
|
1841
|
+
```javascript
|
|
1842
|
+
// Post and product cards
|
|
1843
|
+
await sock.airich()
|
|
1844
|
+
.addPost({
|
|
1845
|
+
title: 'zervonex v3.0.2 🚀',
|
|
1846
|
+
username: 'nexustechpro2',
|
|
1847
|
+
subtitle: 'GitHub',
|
|
1848
|
+
thumbnail_url: 'https://example.com/thumb.jpg',
|
|
1849
|
+
post_url: 'https://github.com/nexustechpro2',
|
|
1850
|
+
post_caption: 'New release — faster, smarter, better.',
|
|
1851
|
+
source_app: 'instagram',
|
|
1852
|
+
likes_count: 2048,
|
|
1853
|
+
comments_count: 128,
|
|
1854
|
+
is_verified: true
|
|
1855
|
+
})
|
|
1856
|
+
.addProduct({
|
|
1857
|
+
title: 'zervonex Premium',
|
|
1858
|
+
brand: 'zervonex',
|
|
1859
|
+
price: '$9.99/mo',
|
|
1860
|
+
sale_price: '$4.99/mo',
|
|
1861
|
+
product_url: 'https://github.com/nexustechpro2',
|
|
1862
|
+
image_url: 'https://example.com/product.jpg'
|
|
1863
|
+
})
|
|
1864
|
+
.send(jid)
|
|
1865
|
+
|
|
1866
|
+
// Map with markers
|
|
1867
|
+
await sock.airich()
|
|
1868
|
+
.addText('Our location:')
|
|
1869
|
+
.addMap([{
|
|
1870
|
+
latitude: 6.5244,
|
|
1871
|
+
longitude: 3.3792,
|
|
1872
|
+
name: 'Lagos, Nigeria',
|
|
1873
|
+
address: 'Lagos Island, Lagos State'
|
|
1874
|
+
}])
|
|
1875
|
+
.send(jid)
|
|
1876
|
+
|
|
1877
|
+
// Rich map with annotations
|
|
1878
|
+
await sock.airich()
|
|
1879
|
+
.addRichMap({
|
|
1880
|
+
centerLatitude: 6.5244,
|
|
1881
|
+
centerLongitude: 3.3792,
|
|
1882
|
+
annotations: [{ latitude: 6.5244, longitude: 3.3792, title: 'Here' }]
|
|
1883
|
+
})
|
|
1884
|
+
.send(jid)
|
|
1885
|
+
|
|
1886
|
+
// Or via shorthand
|
|
1887
|
+
await sock.sendRichMap(jid, {
|
|
1888
|
+
centerLatitude: 6.5244,
|
|
1889
|
+
centerLongitude: 3.3792,
|
|
1890
|
+
annotations: [{ latitude: 6.5244, longitude: 3.3792, title: 'Here' }]
|
|
1891
|
+
})
|
|
1892
|
+
|
|
1893
|
+
// Dynamic GIF
|
|
1894
|
+
await sock.airich().addDynamic({ url: 'https://example.com/anim.gif', type: 'GIF' }).send(jid)
|
|
1895
|
+
await sock.sendDynamic(jid, { url: 'https://example.com/anim.gif', type: 'GIF' })
|
|
1896
|
+
```
|
|
1897
|
+
|
|
1898
|
+
</details>
|
|
1899
|
+
|
|
1900
|
+
<details>
|
|
1901
|
+
<summary><strong>Suggest Prompts, Rich Label, Bot Plan</strong></summary>
|
|
1902
|
+
|
|
1903
|
+
```javascript
|
|
1904
|
+
// Suggest prompts — pill row that sends a message when tapped
|
|
1905
|
+
await sock.airich().addSuggestPrompts(['Tell me more', 'Show examples']).send(jid)
|
|
1906
|
+
await sock.sendBotPromptSuggestions(jid, { text: 'What next?', suggestions: ['A', 'B'] })
|
|
1907
|
+
|
|
1908
|
+
// Rich label — status banner
|
|
1909
|
+
await sock.sendRichLabel(jid, 'Success!', { variant: 'POSITIVE' })
|
|
1910
|
+
|
|
1911
|
+
// Bot plan / task breakdown
|
|
1912
|
+
await sock.sendBotPlan(jid, {
|
|
1913
|
+
title: 'Plan',
|
|
1914
|
+
steps: [{ title: 'Step 1', status: 'executing' }, { title: 'Step 2', status: 'pending' }]
|
|
1915
|
+
})
|
|
1916
|
+
|
|
1917
|
+
// Ask Meta AI directly
|
|
1918
|
+
await sock.sendMetaAI(jid, 'What is Node.js?')
|
|
1919
|
+
```
|
|
1920
|
+
|
|
1921
|
+
</details>
|
|
1922
|
+
|
|
1923
|
+
<details>
|
|
1924
|
+
<summary><strong>Music Message</strong></summary>
|
|
1925
|
+
|
|
1926
|
+
```javascript
|
|
1927
|
+
await sock.sendMessage(jid, {
|
|
1928
|
+
musicMessage: {
|
|
1929
|
+
embeddedMusic: {
|
|
1930
|
+
id: 'track_id',
|
|
1931
|
+
title: 'Song Title',
|
|
1932
|
+
artist: 'Artist Name',
|
|
1933
|
+
thumbnailUrl: 'https://example.com/thumb.jpg',
|
|
1934
|
+
streamUrl: 'https://example.com/stream.mp3',
|
|
1935
|
+
},
|
|
1936
|
+
songUri: 'spotify:track:xxx',
|
|
1937
|
+
artworkUri: 'https://example.com/artwork.jpg',
|
|
1938
|
+
style: 1,
|
|
1939
|
+
lyrics: {
|
|
1940
|
+
syncedLyrics: [
|
|
1941
|
+
{ timeMs: 0, line: 'First line' },
|
|
1942
|
+
{ timeMs: 3000, line: 'Second line' }
|
|
1943
|
+
]
|
|
1944
|
+
},
|
|
1945
|
+
}
|
|
1946
|
+
})
|
|
1947
|
+
```
|
|
1948
|
+
|
|
1949
|
+
</details>
|
|
1950
|
+
|
|
1951
|
+
<details>
|
|
1952
|
+
<summary><strong>Image Grid via AIRich</strong></summary>
|
|
1953
|
+
|
|
1954
|
+
```javascript
|
|
1955
|
+
// Image grid via airich builder
|
|
1956
|
+
await sock.airich().addGrid(['https://img1.jpg', 'https://img2.jpg', 'https://img3.jpg']).send(jid)
|
|
1957
|
+
```
|
|
1958
|
+
|
|
1959
|
+
</details>
|
|
1960
|
+
|
|
1961
|
+
<details>
|
|
1962
|
+
<summary><strong>Image Generation Placeholder</strong></summary>
|
|
1963
|
+
|
|
1964
|
+
```javascript
|
|
1965
|
+
// Generation placeholder — shown while image is being created
|
|
1966
|
+
await sock.airich()
|
|
1967
|
+
.addText('Generating your image...')
|
|
1968
|
+
.addImagine({ mediaType: 'image', status: 'GENERATING', estimatedMs: 5000 })
|
|
1969
|
+
.send(jid)
|
|
1970
|
+
|
|
1971
|
+
// Standalone generation message with itemId for later editing
|
|
1972
|
+
const { msg, responseId, itemId } = await sock.sendRichGeneration(jid, {
|
|
1973
|
+
text: 'Generating...',
|
|
1974
|
+
mediaType: 'video',
|
|
1975
|
+
status: 'GENERATING',
|
|
1976
|
+
estimatedMs: 8000
|
|
1977
|
+
})
|
|
1978
|
+
|
|
1979
|
+
// Later — edit that same message with the finished result
|
|
1980
|
+
await sock.airich()
|
|
1981
|
+
.setResponseId(responseId)
|
|
1982
|
+
.addText('Here is your video!')
|
|
1983
|
+
.addImagine({ mediaType: 'video', url: 'https://example.com/result.mp4', status: 'READY' })
|
|
1984
|
+
.sendEdit(jid, msg.key.id)
|
|
1985
|
+
```
|
|
1986
|
+
|
|
1987
|
+
</details>
|
|
1988
|
+
|
|
1989
|
+
<details>
|
|
1990
|
+
<summary><strong>Load From / Edit / Capture / Relay</strong></summary>
|
|
1991
|
+
|
|
1992
|
+
```javascript
|
|
1993
|
+
// Load an existing AIRich message back into the builder for editing
|
|
1994
|
+
const r = sock.airich()
|
|
1995
|
+
r.loadFrom(receivedMessage.message)
|
|
1996
|
+
r.addText('Additional content added!')
|
|
1997
|
+
await r.send(jid)
|
|
1998
|
+
|
|
1999
|
+
// Edit a sent AIRich message
|
|
2000
|
+
const sent = await sock.airich().addText('Original text').send(jid)
|
|
2001
|
+
await sock.airich()
|
|
2002
|
+
.addText('Updated text')
|
|
2003
|
+
.sendEdit(jid, sent.key.id)
|
|
2004
|
+
|
|
2005
|
+
// Capture a received AIRich message for forwarding
|
|
2006
|
+
const captured = sock.captureAiRich(msg.message)
|
|
2007
|
+
|
|
2008
|
+
// Relay it to another JID
|
|
2009
|
+
if (captured) await sock.relayAiRich(targetJid, captured)
|
|
2010
|
+
```
|
|
2011
|
+
|
|
2012
|
+
</details>
|
|
2013
|
+
|
|
2014
|
+
<details>
|
|
2015
|
+
<summary><strong>HTML Primitives</strong></summary>
|
|
2016
|
+
|
|
2017
|
+
#### `addHtml(html, trustedSources?, opts?)`
|
|
2018
|
+
|
|
2019
|
+
> [!WARNING] Uses an experimental primitive internally — treat as unstable.
|
|
2020
|
+
|
|
2021
|
+
```javascript
|
|
2022
|
+
await sock.airich()
|
|
2023
|
+
.addText('Here is a live preview:')
|
|
2024
|
+
.addHtml('<h2>Hello</h2><p>This is <b>bold</b> and <em>italic</em>.</p>')
|
|
2025
|
+
.send(jid)
|
|
2026
|
+
```
|
|
2027
|
+
|
|
2028
|
+
| Param | Type | Description |
|
|
2029
|
+
|---|---|---|
|
|
2030
|
+
| `html` | `string` | Raw HTML string to render |
|
|
2031
|
+
| `trustedSources` | `string[]` | Allowed source origins for the HTML content |
|
|
2032
|
+
| `opts` | `object` | `{ id, replace, insertAt }` |
|
|
2033
|
+
|
|
2034
|
+
#### `addRichHtml(tabs, title?, opts?)`
|
|
2035
|
+
|
|
2036
|
+
Renders a tabbed HTML panel.
|
|
2037
|
+
|
|
2038
|
+
```javascript
|
|
2039
|
+
// Single string
|
|
2040
|
+
await sock.airich()
|
|
2041
|
+
.addRichHtml('<p>Simple preview</p>')
|
|
2042
|
+
.send(jid)
|
|
2043
|
+
|
|
2044
|
+
// Single tab object
|
|
2045
|
+
await sock.airich()
|
|
2046
|
+
.addRichHtml({ title: 'Result', html: '<h1>Done</h1>' }, 'Preview')
|
|
2047
|
+
.send(jid)
|
|
2048
|
+
|
|
2049
|
+
// Multi-tab panel
|
|
2050
|
+
await sock.airich()
|
|
2051
|
+
.addRichHtml([
|
|
2052
|
+
{ id: 'tab_preview', title: 'Preview', html: '<h1>Hello World</h1>' },
|
|
2053
|
+
{ id: 'tab_code', title: 'Source', html: '<pre><h1>Hello World</h1></pre>' },
|
|
2054
|
+
{ id: 'tab_live', title: 'Live', html: '<p>Live</p>', url: 'https://example.com', trustedSources: ['https://example.com'] },
|
|
2055
|
+
], 'My Panel')
|
|
2056
|
+
.send(jid)
|
|
2057
|
+
```
|
|
2058
|
+
|
|
2059
|
+
</details>
|
|
2060
|
+
|
|
2061
|
+
<details>
|
|
2062
|
+
<summary><strong>Named Node IDs</strong></summary>
|
|
2063
|
+
|
|
2064
|
+
```javascript
|
|
2065
|
+
const r = sock.airich()
|
|
2066
|
+
r.addText('Loading...', { id: 'status' })
|
|
2067
|
+
r.addCode('js', '// placeholder', { id: 'code' })
|
|
2068
|
+
|
|
2069
|
+
// Later, replace specific nodes by id
|
|
2070
|
+
r.addText('Done!', { replace: 'status' })
|
|
2071
|
+
r.addCode('js', 'console.log("real code")', { replace: 'code' })
|
|
2072
|
+
|
|
2073
|
+
await r.send(jid)
|
|
2074
|
+
```
|
|
2075
|
+
|
|
2076
|
+
</details>
|
|
2077
|
+
|
|
2078
|
+
<details>
|
|
2079
|
+
<summary><strong>Full Combo Example</strong></summary>
|
|
2080
|
+
|
|
2081
|
+
```javascript
|
|
2082
|
+
await sock.airich()
|
|
2083
|
+
.setTitle('zervonex Bot')
|
|
2084
|
+
.setFooter('Powered by @zervonexx/baileys latest')
|
|
2085
|
+
.addText('*Welcome to zervonex!*')
|
|
2086
|
+
.addDivider()
|
|
2087
|
+
.addCode('python', 'print("Hello from zervonex")')
|
|
2088
|
+
.addTable([
|
|
2089
|
+
['Plan', 'Price', 'Sessions'],
|
|
2090
|
+
['Basic', 'Free', '1'],
|
|
2091
|
+
['Pro', '$9/mo', '10'],
|
|
2092
|
+
['Enterprise', 'Custom', 'Unlimited']
|
|
2093
|
+
])
|
|
2094
|
+
.addTask({ taskId: 't1', title: 'Bot online', status: 'DONE' })
|
|
2095
|
+
.addMetadata('zervonex • v3.0.2 • 2026')
|
|
2096
|
+
.addSuggest(['View commands', 'Get support', 'Upgrade plan'])
|
|
2097
|
+
.addFooterAction({ cta_text: '📖 View Dashboard', cta_type: 'OPEN_URL', cta_url: 'https://github.com/nexustechpro2' })
|
|
2098
|
+
.addFOAText('_Reply with any message to continue_')
|
|
2099
|
+
.send(jid)
|
|
2100
|
+
```
|
|
2101
|
+
|
|
2102
|
+
</details>
|
|
2103
|
+
|
|
2104
|
+
---
|
|
2105
|
+
|
|
2106
|
+
### Status & Stories
|
|
2107
|
+
|
|
2108
|
+
<details>
|
|
2109
|
+
<summary><strong>Personal Status (status@broadcast)</strong></summary>
|
|
2110
|
+
|
|
2111
|
+
```javascript
|
|
2112
|
+
// Text status
|
|
2113
|
+
await sock.sendMessage('status@broadcast', { text: 'My status update!' })
|
|
2114
|
+
|
|
2115
|
+
// Image status
|
|
2116
|
+
await sock.sendMessage('status@broadcast', { image: { url: 'https://example.com/image.jpg' }, caption: 'Caption' })
|
|
2117
|
+
|
|
2118
|
+
// Video status
|
|
2119
|
+
await sock.sendMessage('status@broadcast', { video: { url: 'https://example.com/video.mp4' }, caption: 'Caption' })
|
|
2120
|
+
|
|
2121
|
+
// Audio status
|
|
2122
|
+
await sock.sendMessage('status@broadcast', { audio: { url: 'https://example.com/audio.mp3' }, ptt: false })
|
|
2123
|
+
|
|
2124
|
+
// Send to specific contacts only
|
|
2125
|
+
await sock.sendMessage('status@broadcast', {
|
|
2126
|
+
text: 'Private status',
|
|
2127
|
+
statusJidList: [
|
|
2128
|
+
'1234567890@s.whatsapp.net',
|
|
2129
|
+
'0987654321@s.whatsapp.net'
|
|
2130
|
+
]
|
|
2131
|
+
})
|
|
2132
|
+
|
|
2133
|
+
// sendStatus shorthand
|
|
2134
|
+
await sock.sendStatus({ text: 'Good morning!' }, { statusJidList: ['jid@s.whatsapp.net'] })
|
|
2135
|
+
await sock.sendStatus({ image: { url: 'https://...' }, caption: 'Caption' }, { statusJidList: [...] })
|
|
2136
|
+
await sock.sendStatus({ video: { url: 'https://...' }, caption: 'Caption' }, { statusJidList: [...] })
|
|
2137
|
+
```
|
|
2138
|
+
|
|
2139
|
+
</details>
|
|
2140
|
+
|
|
2141
|
+
<details>
|
|
2142
|
+
<summary><strong>Audience Targeting, Add Yours, Status Reply</strong></summary>
|
|
2143
|
+
|
|
2144
|
+
```javascript
|
|
2145
|
+
// Close friends / audience targeting
|
|
2146
|
+
await sock.sendMessage('status@broadcast', {
|
|
2147
|
+
text: 'Close friends only',
|
|
2148
|
+
statusAudience: { audienceType: 1, listName: 'Close friends' }, // 1=CLOSE_FRIENDS
|
|
2149
|
+
}, { broadcast: true, statusJidList: [...] })
|
|
2150
|
+
|
|
2151
|
+
// Add Yours response
|
|
2152
|
+
await sock.sendMessage('status@broadcast', {
|
|
2153
|
+
image: { url: 'https://...' },
|
|
2154
|
+
addYours: parentStatus.key,
|
|
2155
|
+
}, { broadcast: true, statusJidList: [...] })
|
|
2156
|
+
|
|
2157
|
+
// Status question answer
|
|
2158
|
+
await sock.sendMessage(jid, {
|
|
2159
|
+
statusQuestionAnswer: { key: questionStatus.key, text: 'My answer' }
|
|
2160
|
+
})
|
|
2161
|
+
|
|
2162
|
+
// Status quoted — reply to a status
|
|
2163
|
+
await sock.sendMessage(jid, {
|
|
2164
|
+
statusQuoted: {
|
|
2165
|
+
originalStatusId: { id: 'statusMsgId', remoteJid: 'status@broadcast', fromMe: false },
|
|
2166
|
+
type: 1, // 1=QUESTION_ANSWER
|
|
2167
|
+
text: 'Reply text',
|
|
2168
|
+
}
|
|
2169
|
+
})
|
|
2170
|
+
|
|
2171
|
+
// Status sticker interaction
|
|
2172
|
+
await sock.sendMessage(jid, {
|
|
2173
|
+
statusStickerInteraction: {
|
|
2174
|
+
key: statusMsg.key,
|
|
2175
|
+
stickerKey: stickerMsg.key,
|
|
2176
|
+
type: 1, // 1=REACTION
|
|
2177
|
+
}
|
|
2178
|
+
})
|
|
2179
|
+
```
|
|
2180
|
+
|
|
2181
|
+
</details>
|
|
2182
|
+
|
|
2183
|
+
<details>
|
|
2184
|
+
<summary><strong>React to a Status</strong></summary>
|
|
2185
|
+
|
|
2186
|
+
```javascript
|
|
2187
|
+
// Via sendMessage
|
|
2188
|
+
await sock.sendMessage('status@broadcast', {
|
|
2189
|
+
react: {
|
|
2190
|
+
text: '❤️',
|
|
2191
|
+
key: message.key // key of the status message
|
|
2192
|
+
}
|
|
2193
|
+
}, {
|
|
2194
|
+
statusJidList: [message.key.participant] // person who posted the status
|
|
2195
|
+
})
|
|
2196
|
+
|
|
2197
|
+
// Via sendReaction shorthand
|
|
2198
|
+
await sock.sendReaction('status@broadcast', message.key, '❤️', {
|
|
2199
|
+
statusJidList: [message.key.participant]
|
|
2200
|
+
})
|
|
2201
|
+
```
|
|
2202
|
+
|
|
2203
|
+
</details>
|
|
2204
|
+
|
|
2205
|
+
<details>
|
|
2206
|
+
<summary><strong>Status Mention (tag someone in your story)</strong></summary>
|
|
2207
|
+
|
|
2208
|
+
```javascript
|
|
2209
|
+
// Text
|
|
2210
|
+
await sock.sendStatusMentions({ text: 'Hey @someone check this out!' }, ['1234567890@s.whatsapp.net'])
|
|
2211
|
+
|
|
2212
|
+
// Image
|
|
2213
|
+
await sock.sendStatusMentions({ image: { url: 'https://example.com/image.jpg' }, caption: 'Caption' }, ['1234567890@s.whatsapp.net'])
|
|
2214
|
+
|
|
2215
|
+
// Video
|
|
2216
|
+
await sock.sendStatusMentions({ video: { url: 'https://example.com/video.mp4' } }, ['1234567890@s.whatsapp.net'])
|
|
2217
|
+
|
|
2218
|
+
// Audio
|
|
2219
|
+
await sock.sendStatusMentions({ audio: { url: 'https://example.com/audio.mp3' }, ptt: true }, ['1234567890@s.whatsapp.net'])
|
|
2220
|
+
|
|
2221
|
+
// Tag an entire group — all members get notified
|
|
2222
|
+
await sock.sendStatusMentions({ text: 'Hey group!' }, ['123456789@g.us'])
|
|
2223
|
+
```
|
|
2224
|
+
|
|
2225
|
+
</details>
|
|
2226
|
+
|
|
2227
|
+
---
|
|
2228
|
+
|
|
2229
|
+
### Newsletter Messages
|
|
2230
|
+
|
|
2231
|
+
<details>
|
|
2232
|
+
<summary><strong>Show newsletter message examples</strong></summary>
|
|
2233
|
+
|
|
2234
|
+
```javascript
|
|
2235
|
+
// Newsletter follower invite
|
|
2236
|
+
await sock.sendMessage(jid, {
|
|
2237
|
+
newsletterFollowerInvite: {
|
|
2238
|
+
newsletterJid: 'xxx@newsletter',
|
|
2239
|
+
newsletterName: 'My Channel',
|
|
2240
|
+
caption: 'Follow us!',
|
|
2241
|
+
jpegThumbnail: buffer,
|
|
2242
|
+
}
|
|
2243
|
+
})
|
|
2244
|
+
|
|
2245
|
+
// Share newsletter on your status
|
|
2246
|
+
await sock.sendMessage('status@broadcast', {
|
|
2247
|
+
text: 'Check this out',
|
|
2248
|
+
newsletterStatus: {
|
|
2249
|
+
newsletterJid: 'xxx@newsletter',
|
|
2250
|
+
messageId: 123,
|
|
2251
|
+
actionUrl: 'https://...',
|
|
2252
|
+
}
|
|
2253
|
+
}, { broadcast: true, statusJidList: [...] })
|
|
2254
|
+
```
|
|
2255
|
+
|
|
2256
|
+
</details>
|
|
2257
|
+
|
|
2258
|
+
---
|
|
2259
|
+
|
|
2260
|
+
### Comments
|
|
2261
|
+
|
|
2262
|
+
<details>
|
|
2263
|
+
<summary><strong>Show comment examples</strong></summary>
|
|
2264
|
+
|
|
2265
|
+
Comment on a newsletter post or status message.
|
|
2266
|
+
|
|
2267
|
+
```javascript
|
|
2268
|
+
// Text comment
|
|
2269
|
+
await sock.sendMessage(jid, {
|
|
2270
|
+
comment: {
|
|
2271
|
+
targetMessageKey: msg.key,
|
|
2272
|
+
content: { text: 'Great post!' },
|
|
2273
|
+
}
|
|
2274
|
+
})
|
|
2275
|
+
|
|
2276
|
+
// Comment with raw proto message
|
|
2277
|
+
await sock.sendMessage(jid, {
|
|
2278
|
+
comment: {
|
|
2279
|
+
targetMessageKey: msg.key,
|
|
2280
|
+
message: { extendedTextMessage: { text: 'Great post!' } },
|
|
2281
|
+
}
|
|
2282
|
+
})
|
|
2283
|
+
```
|
|
2284
|
+
|
|
2285
|
+
</details>
|
|
2286
|
+
|
|
2287
|
+
---
|
|
2288
|
+
|
|
2289
|
+
### Sticker Pack
|
|
2290
|
+
|
|
2291
|
+
<details>
|
|
2292
|
+
<summary><strong>Show sticker pack examples</strong></summary>
|
|
2293
|
+
|
|
2294
|
+
Send a full sticker pack. Supports buffers, file paths, and URLs. Packs over 60 stickers are automatically batched with a 2-second delay between batches.
|
|
2295
|
+
|
|
2296
|
+
```javascript
|
|
2297
|
+
// Via sendMessage
|
|
2298
|
+
await sock.sendMessage(jid, {
|
|
2299
|
+
stickerPack: {
|
|
2300
|
+
name: 'My Stickers',
|
|
2301
|
+
publisher: 'zervonex',
|
|
2302
|
+
stickers: [
|
|
2303
|
+
{ data: buffer, emojis: ['😊'] },
|
|
2304
|
+
{ data: './sticker.png', emojis: ['😂'] },
|
|
2305
|
+
{ data: './sticker.webp', emojis: ['🎉'] },
|
|
2306
|
+
{ data: './sticker.gif', emojis: ['✨'], isAnimated: true },
|
|
2307
|
+
{ data: './sticker.webm', emojis: ['🎬'], isAnimated: true },
|
|
2308
|
+
{ data: 'https://example.com/sticker.jpg', emojis: ['❤️'] },
|
|
2309
|
+
{ data: buffer, type: StickerTypes.ROUNDED, emojis: ['🔥'] },
|
|
2310
|
+
],
|
|
2311
|
+
cover: coverBuffer // optional — defaults to first sticker
|
|
2312
|
+
}
|
|
2313
|
+
}, { quoted: message })
|
|
2314
|
+
|
|
2315
|
+
// Via dedicated shorthand
|
|
2316
|
+
await sock.stickerPackMessage(jid, {
|
|
2317
|
+
name: 'My Stickers',
|
|
2318
|
+
publisher: 'zervonex',
|
|
2319
|
+
stickers: [
|
|
2320
|
+
{ data: buffer, emojis: ['😊'] },
|
|
2321
|
+
{ data: './sticker.png', emojis: ['😂'] }
|
|
2322
|
+
],
|
|
2323
|
+
cover: coverBuffer
|
|
2324
|
+
}, { quoted: message })
|
|
2325
|
+
```
|
|
2326
|
+
|
|
2327
|
+
**Premium Stickers:**
|
|
2328
|
+
|
|
2329
|
+
```javascript
|
|
2330
|
+
// Single sticker as premium
|
|
2331
|
+
await sock.sendMessage(jid, { sticker: buffer, premium: 1 })
|
|
2332
|
+
|
|
2333
|
+
// Per-sticker in a pack
|
|
2334
|
+
await sock.sendMessage(jid, { stickerPack: { stickers: [{ data: buffer, emojis: ['🔥'], premium: 1 }] } })
|
|
2335
|
+
|
|
2336
|
+
// Whole pack as premium
|
|
2337
|
+
await sock.sendMessage(jid, { stickerPack: { premium: 1, stickers: [...] } })
|
|
2338
|
+
```
|
|
2339
|
+
|
|
2340
|
+
**Per-sticker options:**
|
|
2341
|
+
|
|
2342
|
+
| Field | Type | Default | Description |
|
|
2343
|
+
|-------|------|---------|-------------|
|
|
2344
|
+
| `data` | Buffer \| string | required | Buffer, file path, URL, or SVG string |
|
|
2345
|
+
| `emojis` | string[] | `[]` | Associated emojis shown in sticker picker |
|
|
2346
|
+
| `type` | StickerTypes | `ROUNDED` | Crop/shape style |
|
|
2347
|
+
| `isAnimated` | boolean | `false` | Mark as animated (GIF/WebM inputs) |
|
|
2348
|
+
| `isLottie` | boolean | `false` | Mark as Lottie animated (TGS inputs) |
|
|
2349
|
+
| `accessibilityLabel` | string | `''` | Accessibility label |
|
|
2350
|
+
|
|
2351
|
+
**Sticker types (`StickerTypes`):**
|
|
2352
|
+
|
|
2353
|
+
| Value | Description |
|
|
2354
|
+
|-------|-------------|
|
|
2355
|
+
| `StickerTypes.DEFAULT` | Original aspect ratio, no crop |
|
|
2356
|
+
| `StickerTypes.CROPPED` | Cropped to 512×512 |
|
|
2357
|
+
| `StickerTypes.FULL` | Stretched to fill 512×512 |
|
|
2358
|
+
| `StickerTypes.CIRCLE` | Circular mask |
|
|
2359
|
+
| `StickerTypes.ROUNDED` | Rounded corners |
|
|
2360
|
+
|
|
2361
|
+
**Supported input formats:**
|
|
2362
|
+
|
|
2363
|
+
| Format | Support | Notes |
|
|
2364
|
+
|--------|---------|-------|
|
|
2365
|
+
| WebP | ✅ Full | Static and animated, passed through sharp |
|
|
2366
|
+
| PNG | ✅ Full | Auto-converted to WebP |
|
|
2367
|
+
| JPG/JPEG | ✅ Full | Auto-converted to WebP |
|
|
2368
|
+
| BMP | ✅ Full | Auto-converted to WebP |
|
|
2369
|
+
| SVG | ✅ Full | Rendered and converted to WebP |
|
|
2370
|
+
| GIF | ✅ Animated | Converted to animated WebP via sharp |
|
|
2371
|
+
| WebM (VP9) | ✅ Animated | Converted via ffmpeg → animated WebP |
|
|
2372
|
+
| MP4 | ✅ Animated | Converted via ffmpeg → animated WebP |
|
|
2373
|
+
| TGS | ✅ Animated | Telegram gzip-compressed Lottie — converted via rlottie WASM |
|
|
2374
|
+
|
|
2375
|
+
</details>
|
|
2376
|
+
|
|
2377
|
+
---
|
|
2378
|
+
|
|
2379
|
+
### Associated Flows
|
|
2380
|
+
|
|
2381
|
+
<details>
|
|
2382
|
+
<summary><strong>Show associated flow examples</strong></summary>
|
|
2383
|
+
|
|
2384
|
+
Multi-message flows that send a parent message followed by linked child messages.
|
|
2385
|
+
All media fields accept a `Buffer`, file path, URL string, or `{ url }` object.
|
|
2386
|
+
|
|
2387
|
+
```javascript
|
|
2388
|
+
// Motion Photo — still image + short video clip
|
|
2389
|
+
await sock.sendMessage(jid, {
|
|
2390
|
+
motionPhoto: {
|
|
2391
|
+
items: [
|
|
2392
|
+
{ image: { url: 'https://example.com/still.jpg' } },
|
|
2393
|
+
{ video: { url: 'https://example.com/motion.mp4' } }
|
|
2394
|
+
]
|
|
2395
|
+
}
|
|
2396
|
+
})
|
|
2397
|
+
|
|
2398
|
+
// Also supported — clean direct shape
|
|
2399
|
+
await sock.sendMessage(jid, {
|
|
2400
|
+
motionPhoto: {
|
|
2401
|
+
image: { url: 'https://photo.jpg' },
|
|
2402
|
+
video: { url: 'https://motion.mp4' },
|
|
2403
|
+
}
|
|
2404
|
+
})
|
|
2405
|
+
|
|
2406
|
+
// HD Video — SD version + HD version
|
|
2407
|
+
await sock.sendMessage(jid, {
|
|
2408
|
+
hdVideoDualUpload: {
|
|
2409
|
+
items: [
|
|
2410
|
+
{ video: { url: 'https://example.com/sd.mp4' } },
|
|
2411
|
+
{ video: { url: 'https://example.com/hd.mp4' } }
|
|
2412
|
+
]
|
|
2413
|
+
}
|
|
2414
|
+
})
|
|
2415
|
+
|
|
2416
|
+
// HD Image — preview + HD version
|
|
2417
|
+
await sock.sendMessage(jid, {
|
|
2418
|
+
hdImageDualUpload: {
|
|
2419
|
+
image: buffer, // normal quality
|
|
2420
|
+
hdImage: buffer, // HD version
|
|
2421
|
+
}
|
|
2422
|
+
})
|
|
2423
|
+
|
|
2424
|
+
// Also supported — items[] shape
|
|
2425
|
+
await sock.sendMessage(jid, {
|
|
2426
|
+
hdImageDualUpload: {
|
|
2427
|
+
items: [
|
|
2428
|
+
{ image: { url: 'https://example.com/preview.jpg' } },
|
|
2429
|
+
{ image: { url: 'https://example.com/hd.jpg' } }
|
|
2430
|
+
]
|
|
2431
|
+
}
|
|
2432
|
+
})
|
|
2433
|
+
|
|
2434
|
+
// HEVC Video — original + HEVC encoded
|
|
2435
|
+
await sock.sendMessage(jid, {
|
|
2436
|
+
hevcVideoDualUpload: {
|
|
2437
|
+
items: [
|
|
2438
|
+
{ video: { url: 'https://example.com/original.mp4' } },
|
|
2439
|
+
{ video: { url: 'https://example.com/hevc.mp4' } }
|
|
2440
|
+
]
|
|
2441
|
+
}
|
|
2442
|
+
})
|
|
2443
|
+
|
|
2444
|
+
// AV1 Video — original + AV1 encoded
|
|
2445
|
+
await sock.sendMessage(jid, {
|
|
2446
|
+
av1VideoDualUpload: {
|
|
2447
|
+
items: [
|
|
2448
|
+
{ video: { url: 'https://example.com/original.mp4' } },
|
|
2449
|
+
{ video: { url: 'https://example.com/av1.mp4' } }
|
|
2450
|
+
]
|
|
2451
|
+
}
|
|
2452
|
+
})
|
|
2453
|
+
|
|
2454
|
+
// Streamed HD Video — SD stream + HD stream
|
|
2455
|
+
await sock.sendMessage(jid, {
|
|
2456
|
+
streamedHdVideoDualUpload: {
|
|
2457
|
+
items: [
|
|
2458
|
+
{ video: { url: 'https://example.com/sd-stream.mp4' } },
|
|
2459
|
+
{ video: { url: 'https://example.com/hd-stream.mp4' } }
|
|
2460
|
+
]
|
|
2461
|
+
}
|
|
2462
|
+
})
|
|
2463
|
+
|
|
2464
|
+
// Original Video — processed version + original
|
|
2465
|
+
await sock.sendMessage(jid, {
|
|
2466
|
+
originalVideoDualUpload: {
|
|
2467
|
+
items: [
|
|
2468
|
+
{ video: { url: 'https://example.com/processed.mp4' } },
|
|
2469
|
+
{ video: { url: 'https://example.com/original.mp4' } }
|
|
2470
|
+
]
|
|
2471
|
+
}
|
|
2472
|
+
})
|
|
2473
|
+
|
|
2474
|
+
// Original Image — processed version + original
|
|
2475
|
+
await sock.sendMessage(jid, {
|
|
2476
|
+
originalImageDualUpload: {
|
|
2477
|
+
items: [
|
|
2478
|
+
{ image: { url: 'https://example.com/processed.jpg' } },
|
|
2479
|
+
{ image: { url: 'https://example.com/original.jpg' } }
|
|
2480
|
+
]
|
|
2481
|
+
}
|
|
2482
|
+
})
|
|
2483
|
+
|
|
2484
|
+
// Media Album — group of images and videos
|
|
2485
|
+
await sock.sendMessage(jid, {
|
|
2486
|
+
mediaAlbum: {
|
|
2487
|
+
items: [
|
|
2488
|
+
{ image: { url: 'https://example.com/1.jpg' }, caption: 'First' },
|
|
2489
|
+
{ image: { url: 'https://example.com/2.jpg' } },
|
|
2490
|
+
{ video: { url: 'https://example.com/3.mp4' }, caption: 'Last' }
|
|
2491
|
+
]
|
|
2492
|
+
}
|
|
2493
|
+
})
|
|
2494
|
+
|
|
2495
|
+
// Image Poll — poll where each option has an image
|
|
2496
|
+
await sock.sendMessage(jid, {
|
|
2497
|
+
poll: {
|
|
2498
|
+
name: 'Which looks better?',
|
|
2499
|
+
values: [
|
|
2500
|
+
{ name: 'Option A', image: { url: 'https://example.com/a.jpg' } },
|
|
2501
|
+
{ name: 'Option B', image: { url: 'https://example.com/b.jpg' } }
|
|
2502
|
+
],
|
|
2503
|
+
selectableCount: 1
|
|
2504
|
+
}
|
|
2505
|
+
})
|
|
2506
|
+
|
|
2507
|
+
// Event Cover Image — event message + cover photo
|
|
2508
|
+
await sock.sendMessage(jid, {
|
|
2509
|
+
eventCoverImage: {
|
|
2510
|
+
items: [
|
|
2511
|
+
{ event: { name: 'My Event', startDate: new Date(Date.now() + 86400_000), description: '...' } },
|
|
2512
|
+
{ image: { url: 'https://example.com/cover.jpg' } }
|
|
2513
|
+
]
|
|
2514
|
+
}
|
|
2515
|
+
})
|
|
2516
|
+
|
|
2517
|
+
// Sticker Annotation — image with sticker overlaid
|
|
2518
|
+
await sock.sendMessage(jid, {
|
|
2519
|
+
stickerAnnotation: {
|
|
2520
|
+
items: [
|
|
2521
|
+
{ image: { url: 'https://example.com/photo.jpg' } },
|
|
2522
|
+
{ sticker: { url: 'https://example.com/sticker.webp' } }
|
|
2523
|
+
]
|
|
2524
|
+
}
|
|
2525
|
+
})
|
|
2526
|
+
|
|
2527
|
+
// Status Poll — poll attached to a status
|
|
2528
|
+
await sock.sendMessage('status@broadcast', {
|
|
2529
|
+
statusPoll: {
|
|
2530
|
+
items: [
|
|
2531
|
+
{ poll: { name: 'Vote!', values: ['Yes', 'No'], selectableCount: 1 } },
|
|
2532
|
+
{ image: { url: 'https://example.com/status-bg.jpg' } }
|
|
2533
|
+
]
|
|
2534
|
+
}
|
|
2535
|
+
})
|
|
2536
|
+
|
|
2537
|
+
// Status Add Yours — add yours sticker response
|
|
2538
|
+
await sock.sendMessage('status@broadcast', {
|
|
2539
|
+
statusAddYours: {
|
|
2540
|
+
items: [
|
|
2541
|
+
{ image: { url: 'https://example.com/status.jpg' } },
|
|
2542
|
+
{ text: 'Add yours!' }
|
|
2543
|
+
]
|
|
2544
|
+
}
|
|
2545
|
+
})
|
|
2546
|
+
|
|
2547
|
+
// Attach child message to parent — manual association
|
|
2548
|
+
await sock.sendMessage(jid, {
|
|
2549
|
+
text: 'Child message',
|
|
2550
|
+
messageAssociation: {
|
|
2551
|
+
parentMessageKey: parentMsg.key,
|
|
2552
|
+
associationType: 1, // 1=MEDIA_ALBUM
|
|
2553
|
+
messageIndex: 0,
|
|
2554
|
+
}
|
|
2555
|
+
})
|
|
2556
|
+
```
|
|
2557
|
+
|
|
2558
|
+
**Association Types:**
|
|
2559
|
+
|
|
2560
|
+
| Key | AssociationType | Description |
|
|
2561
|
+
|-----|----------------|-------------|
|
|
2562
|
+
| `motionPhoto` | 12 | Still image + short video clip |
|
|
2563
|
+
| `hdVideoDualUpload` | 5 | SD video + HD version |
|
|
2564
|
+
| `hdImageDualUpload` | 10 | Compressed image + HD version |
|
|
2565
|
+
| `hevcVideoDualUpload` | 19 | Original video + HEVC encoded |
|
|
2566
|
+
| `av1VideoDualUpload` | 21 | Original video + AV1 encoded |
|
|
2567
|
+
| `streamedHdVideoDualUpload` | 22 | SD stream + HD stream |
|
|
2568
|
+
| `originalVideoDualUpload` | 23 | Processed video + original |
|
|
2569
|
+
| `originalImageDualUpload` | 24 | Processed image + original |
|
|
2570
|
+
| `mediaAlbum` | 1 | Group of images and videos |
|
|
2571
|
+
| `poll` (with images) | 7 | Poll where each option has an image |
|
|
2572
|
+
| `eventCoverImage` | 3 | Event message + cover photo |
|
|
2573
|
+
| `stickerAnnotation` | 11 | Image with sticker overlaid |
|
|
2574
|
+
| `pollAddOptionMessage` | 20 | New option added to an existing poll |
|
|
2575
|
+
| `statusPoll` | 4 | Poll attached to a status |
|
|
2576
|
+
| `statusAddYours` | 8 | Add yours sticker response |
|
|
2577
|
+
| `statusQuestion` | 16 | Question sticker on a status |
|
|
2578
|
+
| `statusReaction` | 18 | Reaction to a status |
|
|
2579
|
+
| `statusExternalReshare` | 6 | Reshared external content |
|
|
2580
|
+
| `statusLinkAction` | 13 | Link action card on a status |
|
|
2581
|
+
| `statusNotification` | 9 | Notification linked to a status |
|
|
2582
|
+
| `statusAddYoursAiImagine` | 15 | AI-generated imagine response |
|
|
2583
|
+
| `statusAddYoursDiwali` | 17 | Diwali themed add yours |
|
|
2584
|
+
| `viewAllReplies` | 14 | Thread expansion |
|
|
2585
|
+
| `botPlugin` | 2 | Bot plugin association |
|
|
2586
|
+
|
|
2587
|
+
</details>
|
|
2588
|
+
|
|
2589
|
+
---
|
|
2590
|
+
|
|
2591
|
+
### Fake Quoted Messages
|
|
2592
|
+
|
|
2593
|
+
<details>
|
|
2594
|
+
<summary><strong>Show fake quote examples</strong></summary>
|
|
2595
|
+
|
|
2596
|
+
Fake a reply without an actual original message — useful for AI responses, status reposts, and custom UIs.
|
|
2597
|
+
|
|
2598
|
+
```javascript
|
|
2599
|
+
// Text quote
|
|
2600
|
+
await sock.sendMessage(jid, { text: 'Actual message' }, {
|
|
2601
|
+
quoted: {
|
|
2602
|
+
key: { remoteJid: jid, fromMe: false, id: 'FAKE_' + Date.now(), participant: '1234567890@s.whatsapp.net' },
|
|
2603
|
+
message: { conversation: 'Fake quoted text' }
|
|
2604
|
+
}
|
|
2605
|
+
})
|
|
2606
|
+
|
|
2607
|
+
// Image quote
|
|
2608
|
+
await sock.sendMessage(jid, { text: 'Replying to image' }, {
|
|
2609
|
+
quoted: {
|
|
2610
|
+
key: { remoteJid: jid, fromMe: false, id: 'FAKE_' + Date.now(), participant: '1234567890@s.whatsapp.net' },
|
|
2611
|
+
message: { imageMessage: { caption: 'Fake image caption' } }
|
|
2612
|
+
}
|
|
2613
|
+
})
|
|
2614
|
+
|
|
2615
|
+
// Sticker quote
|
|
2616
|
+
await sock.sendMessage(jid, { text: 'Replying to sticker' }, {
|
|
2617
|
+
quoted: {
|
|
2618
|
+
key: { remoteJid: jid, fromMe: false, id: 'FAKE_' + Date.now(), participant: '1234567890@s.whatsapp.net' },
|
|
2619
|
+
message: { stickerMessage: {} }
|
|
2620
|
+
}
|
|
2621
|
+
})
|
|
2622
|
+
|
|
2623
|
+
// AI / Bot quote
|
|
2624
|
+
await sock.sendMessage(jid, { text: 'My response' }, {
|
|
2625
|
+
quoted: {
|
|
2626
|
+
key: { remoteJid: jid, fromMe: true, id: 'FAKE_' + Date.now() },
|
|
2627
|
+
message: { extendedTextMessage: { text: 'AI generated this', title: 'NexusAI' } }
|
|
2628
|
+
}
|
|
2629
|
+
})
|
|
2630
|
+
|
|
2631
|
+
// Status quote
|
|
2632
|
+
await sock.sendMessage(jid, { text: 'Replying to your status!' }, {
|
|
2633
|
+
quoted: {
|
|
2634
|
+
key: { remoteJid: 'status@broadcast', fromMe: false, id: 'FAKE_' + Date.now(), participant: '1234567890@s.whatsapp.net' },
|
|
2635
|
+
message: { conversation: 'Original status text' }
|
|
2636
|
+
}
|
|
2637
|
+
})
|
|
2638
|
+
```
|
|
2639
|
+
|
|
2640
|
+
**Key Fields:**
|
|
2641
|
+
|
|
2642
|
+
| Field | Description |
|
|
2643
|
+
|-------|-------------|
|
|
2644
|
+
| `remoteJid` | Where the quoted message appears to be from (`jid`, `status@broadcast`, group, etc.) |
|
|
2645
|
+
| `fromMe` | `true` = appears sent by you/bot, `false` = appears sent by someone else |
|
|
2646
|
+
| `id` | Any unique string — `'FAKE_' + Date.now()` avoids collisions |
|
|
2647
|
+
| `participant` | Required in groups/status — the person who appears to have sent it |
|
|
2648
|
+
|
|
2649
|
+
</details>
|
|
2650
|
+
|
|
2651
|
+
---
|
|
2652
|
+
|
|
2653
|
+
### Shorthand Wrappers
|
|
2654
|
+
|
|
2655
|
+
<details>
|
|
2656
|
+
<summary><strong>Show all shorthand methods</strong></summary>
|
|
2657
|
+
|
|
2658
|
+
```javascript
|
|
2659
|
+
// Basic message types
|
|
2660
|
+
await sock.sendText(jid, 'Hello!', options)
|
|
2661
|
+
await sock.sendImage(jid, { url: './image.jpg' }, 'Caption', options)
|
|
2662
|
+
await sock.sendVideo(jid, buffer, 'Caption', options)
|
|
2663
|
+
await sock.sendDocument(jid, { url: './file.pdf' }, 'Caption', options)
|
|
2664
|
+
await sock.sendAudio(jid, { url: './audio.mp3' }, options)
|
|
2665
|
+
await sock.sendLocation(jid, { degreesLatitude: 24.12, degreesLongitude: 55.11, name: 'Place' }, options)
|
|
2666
|
+
await sock.sendPoll(jid, 'Question?', ['A', 'B', 'C'], false, options)
|
|
2667
|
+
await sock.sendReaction(jid, message.key, '💖', options)
|
|
2668
|
+
await sock.sendSticker(jid, { url: './sticker.webp' }, options)
|
|
2669
|
+
await sock.sendContact(jid, { vcard }, options)
|
|
2670
|
+
await sock.sendForward(jid, message, { force: true })
|
|
2671
|
+
|
|
2672
|
+
// AI Rich messages
|
|
2673
|
+
await sock.sendCodeBlock(jid, code, quoted, { language, title, footer })
|
|
2674
|
+
await sock.sendCodeBlockV2(jid, code, quoted, { language, title, text, footer })
|
|
2675
|
+
await sock.sendTable(jid, title, headers, rows, quoted, { headerText, footer })
|
|
2676
|
+
await sock.sendTableV2(jid, tableArray, quoted, { headerText, text, footer })
|
|
2677
|
+
await sock.sendList(jid, title, items, quoted, { footer })
|
|
2678
|
+
await sock.sendLink(jid, text, links, quoted, { headerText, footer, botJid })
|
|
2679
|
+
await sock.sendLinkV2(jid, text, links, quoted, { headerText, footer, searchEngine })
|
|
2680
|
+
await sock.sendLatex(jid, expressions, quoted, { text, headerText, footer })
|
|
2681
|
+
await sock.sendRichMessage(jid, data, quoted)
|
|
2682
|
+
await sock.sendAlbumMessage(jid, items, quoted)
|
|
2683
|
+
await sock.sendGroupStatusMessage(jid, content)
|
|
2684
|
+
await sock.sendRichGeneration(jid, { text, mediaType, status, estimatedMs })
|
|
2685
|
+
await sock.sendUnifiedResponse(jid, sections, submessages, options)
|
|
2686
|
+
await sock.sendVerticalAlbumMessage(jid, { items: [...] })
|
|
2687
|
+
await sock.sendGridImageMessage(jid, { imageUrls: [...] })
|
|
2688
|
+
await sock.sendVideoGridMessage(jid, { videos: [...] })
|
|
2689
|
+
await sock.sendA2UI(jid, components, opts)
|
|
2690
|
+
await sock.sendA2UIMessage(jid, { bloksWidget, nativeFlowMessage })
|
|
2691
|
+
await sock.sendA2UICommandMenu(jid, { title, rows, buttons, footer, image })
|
|
2692
|
+
```
|
|
2693
|
+
|
|
2694
|
+
</details>
|
|
2695
|
+
|
|
2696
|
+
---
|
|
2697
|
+
|
|
2698
|
+
## ✏️ Message Modifications
|
|
2699
|
+
|
|
2700
|
+
<details>
|
|
2701
|
+
<summary><strong>Show message modification examples</strong></summary>
|
|
2702
|
+
|
|
2703
|
+
```javascript
|
|
2704
|
+
// Edit a sent message
|
|
2705
|
+
await sock.sendMessage(jid, { text: 'Updated text', edit: originalMessage.key })
|
|
2706
|
+
|
|
2707
|
+
// Delete for everyone
|
|
2708
|
+
const sent = await sock.sendMessage(jid, { text: 'hello' })
|
|
2709
|
+
await sock.sendMessage(jid, { delete: sent.key })
|
|
2710
|
+
|
|
2711
|
+
// Pin (time in seconds: 86400=24h, 604800=7d, 2592000=30d)
|
|
2712
|
+
await sock.sendMessage(jid, { pin: { type: 1, time: 86400, key: message.key } })
|
|
2713
|
+
|
|
2714
|
+
// Unpin
|
|
2715
|
+
await sock.sendMessage(jid, { pin: { type: 0, time: 0, key: message.key } })
|
|
2716
|
+
```
|
|
2717
|
+
|
|
2718
|
+
</details>
|
|
2719
|
+
|
|
2720
|
+
---
|
|
2721
|
+
|
|
2722
|
+
## 📥 Media Download
|
|
2723
|
+
|
|
2724
|
+
<details>
|
|
2725
|
+
<summary><strong>Show media download examples</strong></summary>
|
|
2726
|
+
|
|
2727
|
+
```javascript
|
|
2728
|
+
import { downloadMediaMessage, getContentType } from '@zervonexx/baileys'
|
|
2729
|
+
|
|
2730
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
2731
|
+
const msg = messages[0]
|
|
2732
|
+
if (!msg.message) return
|
|
2733
|
+
|
|
2734
|
+
const type = getContentType(msg.message)
|
|
2735
|
+
|
|
2736
|
+
if (type === 'imageMessage') {
|
|
2737
|
+
const buffer = await downloadMediaMessage(
|
|
2738
|
+
msg,
|
|
2739
|
+
'buffer',
|
|
2740
|
+
{},
|
|
2741
|
+
{ logger, reuploadRequest: sock.updateMediaMessage }
|
|
2742
|
+
)
|
|
2743
|
+
fs.writeFileSync('./downloaded.jpg', buffer)
|
|
2744
|
+
}
|
|
2745
|
+
})
|
|
2746
|
+
|
|
2747
|
+
// Re-upload expired media
|
|
2748
|
+
await sock.updateMediaMessage(msg)
|
|
2749
|
+
```
|
|
2750
|
+
|
|
2751
|
+
</details>
|
|
2752
|
+
|
|
2753
|
+
---
|
|
2754
|
+
|
|
2755
|
+
## 👥 Group Management
|
|
2756
|
+
|
|
2757
|
+
<details>
|
|
2758
|
+
<summary><strong>Standard Groups</strong></summary>
|
|
2759
|
+
|
|
2760
|
+
```javascript
|
|
2761
|
+
// Create group
|
|
2762
|
+
const group = await sock.groupCreate('Group Name', ['1234567890@s.whatsapp.net'])
|
|
2763
|
+
|
|
2764
|
+
// Add / Remove / Promote / Demote participants
|
|
2765
|
+
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'add')
|
|
2766
|
+
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'remove')
|
|
2767
|
+
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'promote')
|
|
2768
|
+
await sock.groupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'demote')
|
|
2769
|
+
|
|
2770
|
+
// Update group info
|
|
2771
|
+
await sock.groupUpdateSubject(groupJid, 'New Group Name')
|
|
2772
|
+
await sock.groupUpdateDescription(groupJid, 'New description')
|
|
2773
|
+
|
|
2774
|
+
// Settings
|
|
2775
|
+
await sock.groupSettingUpdate(groupJid, 'announcement') // only admins can send
|
|
2776
|
+
await sock.groupSettingUpdate(groupJid, 'not_announcement') // everyone can send
|
|
2777
|
+
await sock.groupSettingUpdate(groupJid, 'locked') // only admins edit info
|
|
2778
|
+
await sock.groupSettingUpdate(groupJid, 'unlocked') // everyone edits info
|
|
2779
|
+
|
|
2780
|
+
// Metadata and invite management
|
|
2781
|
+
const metadata = await sock.groupMetadata(groupJid)
|
|
2782
|
+
const code = await sock.groupInviteCode(groupJid)
|
|
2783
|
+
console.log(`https://chat.whatsapp.com/${code}`)
|
|
2784
|
+
|
|
2785
|
+
await sock.groupRevokeInvite(groupJid)
|
|
2786
|
+
await sock.groupRevokeInviteV4(groupJid, '1234567890@s.whatsapp.net')
|
|
2787
|
+
await sock.groupAcceptInvite('INVITE_CODE')
|
|
2788
|
+
await sock.groupLeave(groupJid)
|
|
2789
|
+
```
|
|
2790
|
+
|
|
2791
|
+
</details>
|
|
2792
|
+
|
|
2793
|
+
<details>
|
|
2794
|
+
<summary><strong>AI Groups</strong></summary>
|
|
2795
|
+
|
|
2796
|
+
WhatsApp AI Groups are a special group type with Meta AI built-in as a participant.
|
|
2797
|
+
|
|
2798
|
+
```javascript
|
|
2799
|
+
// Create an AI group
|
|
2800
|
+
const group = await sock.aiGroupCreate('AI Study Group', ['1234567890@s.whatsapp.net'])
|
|
2801
|
+
|
|
2802
|
+
// Get AI group metadata
|
|
2803
|
+
const metadata = await sock.aiGroupMetadata(groupJid)
|
|
2804
|
+
|
|
2805
|
+
// Add the Meta AI bot to an existing AI group
|
|
2806
|
+
await sock.aiGroupAddBot(groupJid)
|
|
2807
|
+
|
|
2808
|
+
// Participant management
|
|
2809
|
+
await sock.aiGroupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'add')
|
|
2810
|
+
await sock.aiGroupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'remove')
|
|
2811
|
+
await sock.aiGroupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'promote')
|
|
2812
|
+
await sock.aiGroupParticipantsUpdate(groupJid, ['1234567890@s.whatsapp.net'], 'demote')
|
|
2813
|
+
|
|
2814
|
+
// Update subject
|
|
2815
|
+
await sock.aiGroupUpdateSubject(groupJid, 'New AI Group Name')
|
|
2816
|
+
|
|
2817
|
+
// Invite management
|
|
2818
|
+
const code = await sock.aiGroupInviteCode(groupJid)
|
|
2819
|
+
await sock.aiGroupRevokeInvite(groupJid)
|
|
2820
|
+
await sock.aiGroupAcceptInvite('INVITE_CODE')
|
|
2821
|
+
await sock.aiGroupLeave(groupJid)
|
|
2822
|
+
|
|
2823
|
+
// Settings
|
|
2824
|
+
await sock.aiGroupSettingUpdate(groupJid, 'announcement')
|
|
2825
|
+
|
|
2826
|
+
// Ephemeral messages
|
|
2827
|
+
await sock.aiGroupToggleEphemeral(groupJid, 86400) // 24h
|
|
2828
|
+
await sock.aiGroupToggleEphemeral(groupJid, 0) // disable
|
|
2829
|
+
```
|
|
2830
|
+
|
|
2831
|
+
</details>
|
|
2832
|
+
|
|
2833
|
+
---
|
|
2834
|
+
|
|
2835
|
+
## 📱 User Operations
|
|
2836
|
+
|
|
2837
|
+
<details>
|
|
2838
|
+
<summary><strong>Basic User Operations</strong></summary>
|
|
2839
|
+
|
|
2840
|
+
```javascript
|
|
2841
|
+
// Check if a number exists on WhatsApp
|
|
2842
|
+
const [result] = await sock.onWhatsApp('1234567890')
|
|
2843
|
+
if (result?.exists) console.log(result.jid)
|
|
2844
|
+
|
|
2845
|
+
// Profile picture
|
|
2846
|
+
const url = await sock.profilePictureUrl(jid, 'image') // 'image' = HD
|
|
2847
|
+
await sock.updateProfilePicture(jid, { url: './profile.jpg' })
|
|
2848
|
+
await sock.removeProfilePicture(jid)
|
|
2849
|
+
|
|
2850
|
+
// Status and name
|
|
2851
|
+
const status = await sock.fetchStatus(jid)
|
|
2852
|
+
await sock.updateProfileStatus('Available 24/7')
|
|
2853
|
+
await sock.updateProfileName('My Bot')
|
|
2854
|
+
|
|
2855
|
+
// Business profile
|
|
2856
|
+
const biz = await sock.getBusinessProfile(jid)
|
|
2857
|
+
|
|
2858
|
+
// Presence — composing, recording, online, etc.
|
|
2859
|
+
await sock.presenceSubscribe(jid)
|
|
2860
|
+
await sock.sendPresenceUpdate('composing', jid) // available | unavailable | composing | recording | paused
|
|
2861
|
+
|
|
2862
|
+
// Mark messages as read
|
|
2863
|
+
await sock.readMessages([message.key])
|
|
2864
|
+
|
|
2865
|
+
// Block / Unblock a contact
|
|
2866
|
+
await sock.updateBlockStatus(jid, 'block')
|
|
2867
|
+
await sock.updateBlockStatus(jid, 'unblock')
|
|
2868
|
+
|
|
2869
|
+
// Fetch blocklist
|
|
2870
|
+
const blocked = await sock.fetchBlocklist()
|
|
2871
|
+
```
|
|
2872
|
+
|
|
2873
|
+
</details>
|
|
2874
|
+
|
|
2875
|
+
<details>
|
|
2876
|
+
<summary><strong>Usernames</strong></summary>
|
|
2877
|
+
|
|
2878
|
+
```javascript
|
|
2879
|
+
// Check if a username is available
|
|
2880
|
+
const result = await sock.checkUsername('zervonex')
|
|
2881
|
+
// { available: true, username: 'zervonex', session_id: '...' }
|
|
2882
|
+
// { available: false, suggestions: ['zervonex1', 'zervonex_'], ... }
|
|
2883
|
+
|
|
2884
|
+
// Check multiple usernames at once
|
|
2885
|
+
const results = await sock.checkUsernameMulti(['zervonex', 'zervonex2'])
|
|
2886
|
+
|
|
2887
|
+
// Set your username
|
|
2888
|
+
await sock.setUsername('zervonex')
|
|
2889
|
+
await sock.setUsername('zervonex', { pin: '1234' })
|
|
2890
|
+
|
|
2891
|
+
// Check availability then set in one call
|
|
2892
|
+
await sock.checkAndSetUsername('zervonex')
|
|
2893
|
+
|
|
2894
|
+
// Get your current username
|
|
2895
|
+
const username = await sock.getMyUsername()
|
|
2896
|
+
|
|
2897
|
+
// Delete your username
|
|
2898
|
+
await sock.deleteUsername()
|
|
2899
|
+
|
|
2900
|
+
// Set a PIN on your username
|
|
2901
|
+
await sock.setUsernamePin('1234')
|
|
2902
|
+
|
|
2903
|
+
// Find a user by their @username
|
|
2904
|
+
const user = await sock.findUserByUsername('zervonex')
|
|
2905
|
+
const userPinProtected = await sock.findUserByUsername('zervonex', '1234')
|
|
2906
|
+
|
|
2907
|
+
// Fetch usernames of multiple contacts
|
|
2908
|
+
const list = await sock.fetchContactUsernames('1234567890@s.whatsapp.net', '0987654321@s.whatsapp.net')
|
|
2909
|
+
|
|
2910
|
+
// Get username suggestions from WhatsApp
|
|
2911
|
+
const suggestions = await sock.getUsernameRecommendations()
|
|
2912
|
+
```
|
|
2913
|
+
|
|
2914
|
+
</details>
|
|
2915
|
+
|
|
2916
|
+
<details>
|
|
2917
|
+
<summary><strong>Extended Privacy (MEX-based)</strong></summary>
|
|
2918
|
+
|
|
2919
|
+
```javascript
|
|
2920
|
+
// Update your About/bio text with optional emoji
|
|
2921
|
+
await sock.updateTextStatus('Available for chats', '👋')
|
|
2922
|
+
|
|
2923
|
+
// Get About text of multiple contacts
|
|
2924
|
+
const statuses = await sock.getTextStatusList(['1234567890@s.whatsapp.net'])
|
|
2925
|
+
|
|
2926
|
+
// Fetch profile picture info for a user
|
|
2927
|
+
const info = await sock.fetchUserPictureInfo('1234567890@s.whatsapp.net')
|
|
2928
|
+
|
|
2929
|
+
// Set profile picture via MEX
|
|
2930
|
+
await sock.setProfilePictureMex(imageBase64)
|
|
2931
|
+
|
|
2932
|
+
// Trusted devices
|
|
2933
|
+
const devices = await sock.getTrustedDevices()
|
|
2934
|
+
await sock.addTrustedDevice('device_id', 'My Laptop')
|
|
2935
|
+
await sock.untrustTrustedDevice('device_id')
|
|
2936
|
+
await sock.deleteTrustedDevice('device_id')
|
|
2937
|
+
|
|
2938
|
+
// Multi-account linking
|
|
2939
|
+
await sock.addMultiAccountLink('1234567890')
|
|
2940
|
+
await sock.revokeMultiAccount('1234567890@s.whatsapp.net')
|
|
2941
|
+
|
|
2942
|
+
// Check if contacts/businesses are valid WA users
|
|
2943
|
+
const contacts = await sock.contactIntegrityQuery(['1234567890@s.whatsapp.net'])
|
|
2944
|
+
const businesses = await sock.bizIntegrityQuery(['1234567890@s.whatsapp.net'])
|
|
2945
|
+
|
|
2946
|
+
// Link / unlink Facebook or Instagram profile
|
|
2947
|
+
await sock.linkedProfilesSet([{ type: 'FB', username: 'myprofile' }])
|
|
2948
|
+
await sock.linkedProfilesRemove(['FB'])
|
|
2949
|
+
await sock.linkedProfilesUpdate([{ type: 'FB', showOnProfile: true }])
|
|
2950
|
+
|
|
2951
|
+
// Migrate blocklist to LID system
|
|
2952
|
+
await sock.migrateBlocklistLid(['1234567890@s.whatsapp.net'])
|
|
2953
|
+
|
|
2954
|
+
// Notify group members of your push name
|
|
2955
|
+
await sock.notifyPushName(groupJid, [{ jid: '1234567890@s.whatsapp.net', pushName: 'John' }])
|
|
2956
|
+
```
|
|
2957
|
+
|
|
2958
|
+
</details>
|
|
2959
|
+
|
|
2960
|
+
---
|
|
2961
|
+
|
|
2962
|
+
## 🔍 Check Number Status
|
|
2963
|
+
|
|
2964
|
+
<details>
|
|
2965
|
+
<summary><strong>Show number status checker examples</strong></summary>
|
|
2966
|
+
|
|
2967
|
+
```javascript
|
|
2968
|
+
// Via socket instance
|
|
2969
|
+
const result = await sock.checkStatusWA('1234567890')
|
|
2970
|
+
|
|
2971
|
+
// Or direct import — no socket needed
|
|
2972
|
+
import { checkStatusWA } from '@zervonexx/baileys'
|
|
2973
|
+
const result = await checkStatusWA('1234567890')
|
|
2974
|
+
|
|
2975
|
+
// Active number response
|
|
2976
|
+
// { number: '+1234567890', status: 'active', isBanned: false, isNeedOfficialWa: false, banInfo: null }
|
|
2977
|
+
|
|
2978
|
+
// Banned number response
|
|
2979
|
+
{
|
|
2980
|
+
number: '+1234567890',
|
|
2981
|
+
status: 'banned',
|
|
2982
|
+
isBanned: true,
|
|
2983
|
+
banInfo: {
|
|
2984
|
+
banType: 'temporary', // 'temporary' | 'permanent'
|
|
2985
|
+
violationType: '2',
|
|
2986
|
+
violationReason: 'Type 2',
|
|
2987
|
+
canAppeal: true, // false if permanent ban
|
|
2988
|
+
appealToken: 'xxxxx',
|
|
2989
|
+
banTime: 1716840000,
|
|
2990
|
+
banDate: '2024-05-28T00:00:00.000Z',
|
|
2991
|
+
appealStatus: 'PENDING',
|
|
2992
|
+
appealCreatedAt: '2024-05-27T00:00:00.000Z'
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
// Usage example
|
|
2997
|
+
import { checkStatusWA } from '@zervonexx/baileys'
|
|
2998
|
+
const check = await checkStatusWA('1234567890')
|
|
2999
|
+
if (check.isBanned) {
|
|
3000
|
+
console.log(`Banned: ${check.banInfo.banType}`)
|
|
3001
|
+
if (check.banInfo.canAppeal) console.log(`Appeal token: ${check.banInfo.appealToken}`)
|
|
3002
|
+
} else {
|
|
3003
|
+
console.log(`Status: ${check.status}`)
|
|
3004
|
+
}
|
|
3005
|
+
```
|
|
3006
|
+
|
|
3007
|
+
</details>
|
|
3008
|
+
|
|
3009
|
+
---
|
|
3010
|
+
|
|
3011
|
+
## 🔒 Privacy Controls
|
|
3012
|
+
|
|
3013
|
+
<details>
|
|
3014
|
+
<summary><strong>Show privacy control examples</strong></summary>
|
|
3015
|
+
|
|
3016
|
+
```javascript
|
|
3017
|
+
const settings = await sock.fetchPrivacySettings()
|
|
3018
|
+
|
|
3019
|
+
// Last seen: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
3020
|
+
await sock.updateLastSeenPrivacy('contacts')
|
|
3021
|
+
|
|
3022
|
+
// Online: 'all' | 'match_last_seen'
|
|
3023
|
+
await sock.updateOnlinePrivacy('all')
|
|
3024
|
+
|
|
3025
|
+
// Profile picture: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
3026
|
+
await sock.updateProfilePicturePrivacy('contacts')
|
|
3027
|
+
|
|
3028
|
+
// Status: 'all' | 'contacts' | 'contact_blacklist' | 'none'
|
|
3029
|
+
await sock.updateStatusPrivacy('contacts')
|
|
3030
|
+
|
|
3031
|
+
// Read receipts: 'all' | 'none'
|
|
3032
|
+
await sock.updateReadReceiptsPrivacy('all')
|
|
3033
|
+
|
|
3034
|
+
// Groups add: 'all' | 'contacts' | 'contact_blacklist'
|
|
3035
|
+
await sock.updateGroupsAddPrivacy('contacts')
|
|
3036
|
+
```
|
|
3037
|
+
|
|
3038
|
+
</details>
|
|
3039
|
+
|
|
3040
|
+
<details>
|
|
3041
|
+
<summary><strong>Reporting</strong></summary>
|
|
3042
|
+
|
|
3043
|
+
```javascript
|
|
3044
|
+
// Report spam — works on any JID (contact or group)
|
|
3045
|
+
// Rich report with full message metadata — requires at least one received message
|
|
3046
|
+
await sock.reportSpam(jid)
|
|
3047
|
+
|
|
3048
|
+
// Report spam with options
|
|
3049
|
+
await sock.reportSpam(jid, {
|
|
3050
|
+
spamFlow: 'ACCOUNT_INFO_REPORT', // report flow type
|
|
3051
|
+
maxMessages: 5, // max messages to include in report
|
|
3052
|
+
messages: [...] // optional — manual message list, skips auto-lookup
|
|
3053
|
+
})
|
|
3054
|
+
|
|
3055
|
+
// Report a contact — also blocks the contact automatically
|
|
3056
|
+
await sock.reportContact(jid)
|
|
3057
|
+
await sock.reportContact(jid, [message.key, message2.key])
|
|
3058
|
+
|
|
3059
|
+
// Report a group — also leaves the group automatically
|
|
3060
|
+
await sock.reportGroup(groupJid)
|
|
3061
|
+
await sock.reportGroup(groupJid, [message.key, message2.key])
|
|
3062
|
+
```
|
|
3063
|
+
|
|
3064
|
+
| Method | Works On | Auto-Blocks | Auto-Leaves | Detailed Report |
|
|
3065
|
+
|--------|----------|-------------|-------------|-----------------|
|
|
3066
|
+
| `reportSpam` | Contacts & Groups | ❌ | ❌ | ✅ |
|
|
3067
|
+
| `reportContact` | Contacts only | ✅ | ❌ | ❌ |
|
|
3068
|
+
| `reportGroup` | Groups only | ❌ | ✅ | ❌ |
|
|
3069
|
+
|
|
3070
|
+
</details>
|
|
3071
|
+
|
|
3072
|
+
<details>
|
|
3073
|
+
<summary><strong>Reporting Info Store</strong></summary>
|
|
3074
|
+
|
|
3075
|
+
```javascript
|
|
3076
|
+
// Get stored reporting info for a JID (used internally by reportSpam)
|
|
3077
|
+
const info = sock.getStoredReportingInfo(jid)
|
|
3078
|
+
const limited = sock.getStoredReportingInfo(jid, 3) // max 3 entries
|
|
3079
|
+
|
|
3080
|
+
// Clear stored reporting info for a JID
|
|
3081
|
+
sock.clearStoredReportingInfo(jid)
|
|
3082
|
+
|
|
3083
|
+
// Access available spam flow types
|
|
3084
|
+
console.log(sock.SPAM_FLOWS)
|
|
3085
|
+
```
|
|
3086
|
+
|
|
3087
|
+
</details>
|
|
3088
|
+
|
|
3089
|
+
---
|
|
3090
|
+
|
|
3091
|
+
## 💬 Chat Operations
|
|
3092
|
+
|
|
3093
|
+
<details>
|
|
3094
|
+
<summary><strong>Show chat operation examples</strong></summary>
|
|
3095
|
+
|
|
3096
|
+
```javascript
|
|
3097
|
+
const lastMsg = await getLastMessageInChat(jid) // implement with your store
|
|
3098
|
+
|
|
3099
|
+
// Archive / Unarchive
|
|
3100
|
+
await sock.chatModify({ archive: true, lastMessages: [lastMsg] }, jid)
|
|
3101
|
+
|
|
3102
|
+
// Mute for 8 hours (in ms)
|
|
3103
|
+
await sock.chatModify({ mute: 8 * 60 * 60 * 1000 }, jid)
|
|
3104
|
+
|
|
3105
|
+
// Unmute
|
|
3106
|
+
await sock.chatModify({ mute: null }, jid)
|
|
3107
|
+
|
|
3108
|
+
// Pin / Unpin
|
|
3109
|
+
await sock.chatModify({ pin: true }, jid)
|
|
3110
|
+
await sock.chatModify({ pin: false }, jid)
|
|
3111
|
+
|
|
3112
|
+
// Delete chat
|
|
3113
|
+
await sock.chatModify({ delete: true, lastMessages: [{ key: lastMsg.key, messageTimestamp: lastMsg.messageTimestamp }] }, jid)
|
|
3114
|
+
|
|
3115
|
+
// Mark read / unread
|
|
3116
|
+
await sock.chatModify({ markRead: true }, jid)
|
|
3117
|
+
await sock.chatModify({ markRead: false }, jid)
|
|
3118
|
+
```
|
|
3119
|
+
|
|
3120
|
+
</details>
|
|
3121
|
+
|
|
3122
|
+
---
|
|
3123
|
+
|
|
3124
|
+
## 📢 Newsletter / Channels
|
|
3125
|
+
|
|
3126
|
+
<details>
|
|
3127
|
+
<summary><strong>Create & Manage</strong></summary>
|
|
3128
|
+
|
|
3129
|
+
```javascript
|
|
3130
|
+
// Create a channel
|
|
3131
|
+
const channel = await sock.newsletterCreate('Channel Name', 'Channel description')
|
|
3132
|
+
console.log(channel.id) // newsletter jid
|
|
3133
|
+
|
|
3134
|
+
// Fetch channel metadata by invite code or jid
|
|
3135
|
+
const meta = await sock.newsletterMetadata('invite', 'INVITE_CODE')
|
|
3136
|
+
const meta2 = await sock.newsletterMetadata('jid', newsletterJid)
|
|
3137
|
+
|
|
3138
|
+
// Update channel info
|
|
3139
|
+
await sock.newsletterUpdate(newsletterJid, { name: 'New Name' })
|
|
3140
|
+
await sock.newsletterUpdate(newsletterJid, { description: 'New description' })
|
|
3141
|
+
await sock.newsletterUpdate(newsletterJid, { picture: buffer })
|
|
3142
|
+
|
|
3143
|
+
// Shorthand update helpers
|
|
3144
|
+
await sock.newsletterUpdateName(newsletterJid, 'New Name')
|
|
3145
|
+
await sock.newsletterUpdateDescription(newsletterJid, 'New description')
|
|
3146
|
+
await sock.newsletterUpdatePicture(newsletterJid, buffer)
|
|
3147
|
+
await sock.newsletterRemovePicture(newsletterJid)
|
|
3148
|
+
|
|
3149
|
+
// Update reaction settings — 'ALL' | 'BASIC' | 'NONE' | 'BLOCKLIST'
|
|
3150
|
+
await sock.newsletterUpdateReactions(newsletterJid, 'ALL')
|
|
3151
|
+
|
|
3152
|
+
// Delete channel
|
|
3153
|
+
await sock.newsletterDelete(newsletterJid)
|
|
3154
|
+
|
|
3155
|
+
// Change channel owner
|
|
3156
|
+
await sock.newsletterChangeOwner(newsletterJid, newOwnerJid)
|
|
3157
|
+
|
|
3158
|
+
// Demote an admin
|
|
3159
|
+
await sock.newsletterDemote(newsletterJid, userJid)
|
|
3160
|
+
```
|
|
3161
|
+
|
|
3162
|
+
</details>
|
|
3163
|
+
|
|
3164
|
+
<details>
|
|
3165
|
+
<summary><strong>Follow / Unfollow, Mute</strong></summary>
|
|
3166
|
+
|
|
3167
|
+
```javascript
|
|
3168
|
+
await sock.newsletterFollow(newsletterJid)
|
|
3169
|
+
await sock.newsletterUnfollow(newsletterJid)
|
|
3170
|
+
|
|
3171
|
+
// Get all subscribed channels
|
|
3172
|
+
const subscribed = await sock.newsletterSubscribed()
|
|
3173
|
+
|
|
3174
|
+
// Subscribe to live updates for a channel
|
|
3175
|
+
const sub = await sock.subscribeNewsletterUpdates(newsletterJid)
|
|
3176
|
+
console.log(sub.duration)
|
|
3177
|
+
|
|
3178
|
+
// Mute / Unmute
|
|
3179
|
+
await sock.newsletterMute(newsletterJid)
|
|
3180
|
+
await sock.newsletterUnmute(newsletterJid)
|
|
3181
|
+
|
|
3182
|
+
// Fine-grained mute control
|
|
3183
|
+
await sock.newsletterUpdateUserSetting(newsletterJid, 'FOLLOWER_NOTIFICATIONS', true)
|
|
3184
|
+
await sock.newsletterUpdateUserSetting(newsletterJid, 'ADMIN_NOTIFICATIONS', false)
|
|
3185
|
+
```
|
|
3186
|
+
|
|
3187
|
+
</details>
|
|
3188
|
+
|
|
3189
|
+
<details>
|
|
3190
|
+
<summary><strong>Admin Management</strong></summary>
|
|
3191
|
+
|
|
3192
|
+
```javascript
|
|
3193
|
+
// Get admin count and info
|
|
3194
|
+
const count = await sock.newsletterAdminCount(newsletterJid)
|
|
3195
|
+
const adminInfo = await sock.newsletterAdminInfo(newsletterJid)
|
|
3196
|
+
console.log(adminInfo.adminCount, adminInfo.adminProfile, adminInfo.adminProfilesEnabled)
|
|
3197
|
+
|
|
3198
|
+
// Get admin capabilities
|
|
3199
|
+
const capabilities = await sock.newsletterAdminCapabilities(newsletterJid)
|
|
3200
|
+
|
|
3201
|
+
// Check if you can post status
|
|
3202
|
+
const { canPost, canPostMusic, capabilities: caps } = await sock.newsletterCanPostStatus(newsletterJid)
|
|
3203
|
+
|
|
3204
|
+
// Admin invites
|
|
3205
|
+
await sock.newsletterCreateAdminInvite(newsletterJid, userJid)
|
|
3206
|
+
await sock.newsletterRevokeAdminInvite(newsletterJid, userJid)
|
|
3207
|
+
await sock.newsletterAcceptAdminInvite(newsletterJid)
|
|
3208
|
+
|
|
3209
|
+
// List pending admin invites
|
|
3210
|
+
const pending = await sock.newsletterPendingAdminInvites(newsletterJid)
|
|
3211
|
+
```
|
|
3212
|
+
|
|
3213
|
+
</details>
|
|
3214
|
+
|
|
3215
|
+
<details>
|
|
3216
|
+
<summary><strong>Messages & Reactions</strong></summary>
|
|
3217
|
+
|
|
3218
|
+
```javascript
|
|
3219
|
+
// Fetch recent messages
|
|
3220
|
+
const messages = await sock.newsletterFetchMessages(newsletterJid, 20)
|
|
3221
|
+
|
|
3222
|
+
// Fetch with pagination
|
|
3223
|
+
const older = await sock.newsletterFetchMessages(newsletterJid, 20, undefined, lastServerId)
|
|
3224
|
+
|
|
3225
|
+
// Fetch message updates (reactions, view counts, etc.)
|
|
3226
|
+
const updates = await sock.newsletterFetchMessageUpdates(newsletterJid, { count: 20 })
|
|
3227
|
+
const paged = await sock.newsletterFetchMessageUpdates(newsletterJid, { count: 20, before: serverId })
|
|
3228
|
+
|
|
3229
|
+
// Pin / unpin messages
|
|
3230
|
+
await sock.newsletterPinMessages(newsletterJid, serverId)
|
|
3231
|
+
await sock.newsletterPinMessages(newsletterJid, [serverId1, serverId2])
|
|
3232
|
+
await sock.newsletterUnpinMessages(newsletterJid, serverId)
|
|
3233
|
+
|
|
3234
|
+
// Label AI-generated content
|
|
3235
|
+
await sock.newsletterLabelAiContent(newsletterJid, serverId)
|
|
3236
|
+
|
|
3237
|
+
// Label paid partnership
|
|
3238
|
+
await sock.newsletterLabelPaidPartnership(newsletterJid, serverId)
|
|
3239
|
+
|
|
3240
|
+
// Single reaction on a message
|
|
3241
|
+
await sock.newsletterReactMessage(newsletterJid, serverId, '❤️')
|
|
3242
|
+
|
|
3243
|
+
// Remove a reaction
|
|
3244
|
+
await sock.newsletterReactMessage(newsletterJid, serverId, null)
|
|
3245
|
+
|
|
3246
|
+
// Bulk reactions — single emoji, 10 times
|
|
3247
|
+
await sock.newsletterBulkReactions(newsletterJid, serverId, '❤️', 10)
|
|
3248
|
+
|
|
3249
|
+
// Bulk reactions — cycle through multiple emojis (❤️ 🔥 ❤️ 🔥...), 20 total
|
|
3250
|
+
await sock.newsletterBulkReactions(newsletterJid, serverId, ['❤️', '🔥'], 20)
|
|
3251
|
+
|
|
3252
|
+
// Bulk reactions — random emoji each time, 20 total
|
|
3253
|
+
await sock.newsletterBulkReactions(newsletterJid, serverId, ['❤️', '🔥', '😂'], 20, { mode: 'random' })
|
|
3254
|
+
|
|
3255
|
+
// Bulk reactions — 10 of EACH emoji (30 total)
|
|
3256
|
+
await sock.newsletterBulkReactions(newsletterJid, serverId, ['❤️', '🔥', '😂'], 10, { mode: 'each' })
|
|
3257
|
+
|
|
3258
|
+
// Fake reactions (local events only, not sent to server)
|
|
3259
|
+
await sock.newsletterBulkReactions(newsletterJid, serverId, ['❤️', '🔥'], 100, { fake: true })
|
|
3260
|
+
|
|
3261
|
+
// Custom delay between reactions (default: 100ms)
|
|
3262
|
+
await sock.newsletterBulkReactions(newsletterJid, serverId, '🔥', 50, { delayMs: 200 })
|
|
3263
|
+
|
|
3264
|
+
// Get who reacted to a message
|
|
3265
|
+
const reactionSenders = await sock.newsletterReactionSenders(newsletterJid, serverId)
|
|
3266
|
+
```
|
|
3267
|
+
|
|
3268
|
+
</details>
|
|
3269
|
+
|
|
3270
|
+
<details>
|
|
3271
|
+
<summary><strong>Status Publishing & Management</strong></summary>
|
|
3272
|
+
|
|
3273
|
+
```javascript
|
|
3274
|
+
// Send a text status
|
|
3275
|
+
await sock.newsletterSendStatus(newsletterJid, { text: 'Hello from channel!' })
|
|
3276
|
+
|
|
3277
|
+
// Send an image status
|
|
3278
|
+
await sock.newsletterSendStatus(newsletterJid, { image: buffer, caption: 'Caption here' })
|
|
3279
|
+
|
|
3280
|
+
// Send a video status
|
|
3281
|
+
await sock.newsletterSendStatus(newsletterJid, { video: buffer, caption: 'Caption here' })
|
|
3282
|
+
|
|
3283
|
+
// Send an audio status
|
|
3284
|
+
await sock.newsletterSendStatus(newsletterJid, { audio: buffer })
|
|
3285
|
+
|
|
3286
|
+
// Send a question on top of media
|
|
3287
|
+
await sock.newsletterSendStatus(newsletterJid, { image: buffer, question: true })
|
|
3288
|
+
|
|
3289
|
+
// Send a question response (text reply to a question)
|
|
3290
|
+
await sock.newsletterSendStatus(newsletterJid, { text: 'My answer' }, {
|
|
3291
|
+
interactionType: 'question_response',
|
|
3292
|
+
parentServerId: questionServerId
|
|
3293
|
+
})
|
|
3294
|
+
|
|
3295
|
+
// Mark status as AI-generated
|
|
3296
|
+
await sock.newsletterSendStatus(newsletterJid, { text: 'AI content' }, { aiContent: true })
|
|
3297
|
+
|
|
3298
|
+
// Access the server id from the result
|
|
3299
|
+
const sent = await sock.newsletterSendStatus(newsletterJid, { text: 'Hello' })
|
|
3300
|
+
console.log(sent.newsletterStatusServerId) // use this for reactions, pins, etc.
|
|
3301
|
+
|
|
3302
|
+
// React to a status
|
|
3303
|
+
await sock.newsletterReactStatus(newsletterJid, serverId, '❤️')
|
|
3304
|
+
|
|
3305
|
+
// Remove a status reaction
|
|
3306
|
+
await sock.newsletterReactStatus(newsletterJid, serverId, null)
|
|
3307
|
+
|
|
3308
|
+
// Revoke / delete a status
|
|
3309
|
+
await sock.newsletterRevokeStatus(newsletterJid, statusId)
|
|
3310
|
+
|
|
3311
|
+
// Fetch published statuses
|
|
3312
|
+
const statuses = await sock.newsletterFetchStatus(newsletterJid, { count: 20 })
|
|
3313
|
+
const before = await sock.newsletterFetchStatus(newsletterJid, { count: 20, before: serverId })
|
|
3314
|
+
const after = await sock.newsletterFetchStatus(newsletterJid, { count: 20, after: serverId })
|
|
3315
|
+
```
|
|
3316
|
+
|
|
3317
|
+
</details>
|
|
3318
|
+
|
|
3319
|
+
<details>
|
|
3320
|
+
<summary><strong>Poll Votes, Questions, Analytics, Discovery</strong></summary>
|
|
3321
|
+
|
|
3322
|
+
```javascript
|
|
3323
|
+
// Vote on a poll
|
|
3324
|
+
await sock.newsletterSendPollVote(newsletterJid, serverId, 'Option A')
|
|
3325
|
+
await sock.newsletterSendPollVote(newsletterJid, serverId, ['Option A', 'Option B']) // multi-vote
|
|
3326
|
+
|
|
3327
|
+
// Get poll voters
|
|
3328
|
+
const voters = await sock.newsletterPollVoters(newsletterJid, serverId, { limit: 100 })
|
|
3329
|
+
const forOption = await sock.newsletterPollVoters(newsletterJid, serverId, { voteHash: 'abc123' })
|
|
3330
|
+
|
|
3331
|
+
// Fetch responses to a question status
|
|
3332
|
+
const responses = await sock.newsletterQuestionResponses(newsletterJid, serverId, { count: 20 })
|
|
3333
|
+
const filtered = await sock.newsletterQuestionResponses(newsletterJid, serverId, { filter: 'starred' })
|
|
3334
|
+
const searched = await sock.newsletterQuestionResponses(newsletterJid, serverId, { searchText: 'hello' })
|
|
3335
|
+
|
|
3336
|
+
// Update response state — e.g. star, reply
|
|
3337
|
+
await sock.newsletterQuestionResponseState(newsletterJid, serverId, responseServerId, 'STARRED')
|
|
3338
|
+
|
|
3339
|
+
// Analytics and insights
|
|
3340
|
+
const insights = await sock.newsletterInsights(newsletterJid)
|
|
3341
|
+
const custom = await sock.newsletterInsights(newsletterJid, { metrics: ['NET_FOLLOWS', 'UNFOLLOWS', 'IMPRESSIONS'] })
|
|
3342
|
+
|
|
3343
|
+
// Get enforcements (violations, suspensions, etc.)
|
|
3344
|
+
const enforcements = await sock.newsletterEnforcements(newsletterJid)
|
|
3345
|
+
const { adminProfiles, profilePictureDeletions, suspensions, violatingMessages, geoSuspensions } = enforcements
|
|
3346
|
+
|
|
3347
|
+
// Get all your channel reports
|
|
3348
|
+
const reports = await sock.newsletterReports()
|
|
3349
|
+
|
|
3350
|
+
// Appeal a report
|
|
3351
|
+
await sock.newsletterAppealReport(reportId, 'REASON_HERE')
|
|
3352
|
+
|
|
3353
|
+
// Browse recommended channels
|
|
3354
|
+
const recommended = await sock.newsletterRecommended({ limit: 20 })
|
|
3355
|
+
const local = await sock.newsletterRecommended({ countryCodes: ['NG', 'US'] })
|
|
3356
|
+
|
|
3357
|
+
// Search channels
|
|
3358
|
+
const results = await sock.newsletterDirectorySearch('football', { limit: 20 })
|
|
3359
|
+
|
|
3360
|
+
// Browse directory
|
|
3361
|
+
const directory = await sock.newsletterDirectoryList({ view: 'RECOMMENDED', limit: 20 })
|
|
3362
|
+
const byCountry = await sock.newsletterDirectoryList({ countryCodes: ['NG'], categories: ['SPORTS'] })
|
|
3363
|
+
|
|
3364
|
+
// Browse categories
|
|
3365
|
+
const categories = await sock.newsletterDirectoryCategories({ perCategoryLimit: 10 })
|
|
3366
|
+
|
|
3367
|
+
// Find similar channels
|
|
3368
|
+
const similar = await sock.newsletterSimilar(newsletterJid, { limit: 20 })
|
|
3369
|
+
```
|
|
3370
|
+
|
|
3371
|
+
</details>
|
|
3372
|
+
|
|
3373
|
+
---
|
|
3374
|
+
|
|
3375
|
+
## 🔧 Builder API
|
|
3376
|
+
|
|
3377
|
+
All builders can be used as a fluent chain. Call `.send(jid)` to send, or `.build(jid)` to get the proto message without sending.
|
|
3378
|
+
|
|
3379
|
+
<details>
|
|
3380
|
+
<summary><strong>AIRich Builder</strong></summary>
|
|
3381
|
+
|
|
3382
|
+
```javascript
|
|
3383
|
+
const r = sock.airich() // create a new builder
|
|
3384
|
+
r.setTitle('Title') // shown in message metadata
|
|
3385
|
+
r.setFooter('© zervonex') // shown below content
|
|
3386
|
+
r.setBotJid('867051314767696@bot') // custom bot JID
|
|
3387
|
+
r.setResponseId('my-id') // fix response ID (disables auto-refresh)
|
|
3388
|
+
r.setContextInfo({ ... }) // custom contextInfo fields
|
|
3389
|
+
|
|
3390
|
+
// Content methods — all chainable, all accept { id, replace, insertAt } opts
|
|
3391
|
+
r.addText('hello **world**')
|
|
3392
|
+
r.addCode('javascript', 'console.log("hi")')
|
|
3393
|
+
r.addTable([['Header1', 'Header2'], ['R1C1', 'R1C2']])
|
|
3394
|
+
r.addImage('https://example.com/image.jpg')
|
|
3395
|
+
r.addVideo('https://example.com/video.mp4')
|
|
3396
|
+
r.addReels([{ creator, avatar_url, thumbnail_url, reels_url }])
|
|
3397
|
+
r.addPost({ title, username, thumbnail_url, post_url, source_app, likes_count, is_verified })
|
|
3398
|
+
r.addProduct({ title, brand, price, sale_price, product_url, image_url })
|
|
3399
|
+
r.addSource([{ title, url, favicon }])
|
|
3400
|
+
r.addMap([{ latitude, longitude, name, address }])
|
|
3401
|
+
r.addWidget(ctas, title) // ctas: [{ label, tool_call_id, kind, toast }]
|
|
3402
|
+
r.addFooterAction({ cta_text, cta_type, cta_url })
|
|
3403
|
+
r.addMetadata('small info text')
|
|
3404
|
+
r.addFOAText('# Heading\n## Subheading')
|
|
3405
|
+
r.addTip('Tip callout text')
|
|
3406
|
+
r.addDivider() // or addDivider('DOT') for dotted line
|
|
3407
|
+
r.addSpacer(2) // spacing: number of blank lines
|
|
3408
|
+
r.addThinkingStatus('title', 'THINKING') // icons: THINKING | WEB_SEARCH | META_SEARCH
|
|
3409
|
+
r.addProgressStatus('title', true) // true = in progress, false = done
|
|
3410
|
+
r.addTask({ taskId, title, subtitle, status }) // status: PENDING | RUNNING | DONE
|
|
3411
|
+
r.addLatex({ expression, imageUrl, width, height, fontHeight, padding })
|
|
3412
|
+
r.addGenerating('GENERATING') // image generation placeholder
|
|
3413
|
+
r.addInlineImage('url', 'center') // alignment: center | left | right
|
|
3414
|
+
r.addHtml('<h2>Hello</h2>') // trustedSources: optional string[]
|
|
3415
|
+
r.addRichHtml('<p>Preview</p>', 'Preview')
|
|
3416
|
+
r.addSuggest(['Pill 1', 'Pill 2'], false) // false = action row, true = hscroll
|
|
3417
|
+
r.addSection(rawSectionObject) // raw section for advanced use
|
|
3418
|
+
r.addEmbeddedScreen(screenObject) // embedded tabbed panel
|
|
3419
|
+
r.addRawSections(sections, submessages) // escape hatch — raw unified sections
|
|
3420
|
+
|
|
3421
|
+
// Special methods
|
|
3422
|
+
r.loadFrom(msg) // load existing AIRich message for editing
|
|
3423
|
+
await r.send(jid, opts) // send
|
|
3424
|
+
await r.sendEdit(jid, targetId) // edit a previously sent message
|
|
3425
|
+
|
|
3426
|
+
// Standalone helpers
|
|
3427
|
+
await sock.sendRichGeneration(jid, { text, mediaType, url, status, estimatedMs, itemId, responseId })
|
|
3428
|
+
await sock.sendUnifiedResponse(jid, sections, submessages, options)
|
|
3429
|
+
```
|
|
3430
|
+
|
|
3431
|
+
</details>
|
|
3432
|
+
|
|
3433
|
+
<details>
|
|
3434
|
+
<summary><strong>Button Builder</strong></summary>
|
|
3435
|
+
|
|
3436
|
+
```javascript
|
|
3437
|
+
const b = sock.button()
|
|
3438
|
+
|
|
3439
|
+
// Text content
|
|
3440
|
+
b.setTitle('Menu')
|
|
3441
|
+
b.setSubtitle('Choose an option')
|
|
3442
|
+
b.setBody('What would you like to do?')
|
|
3443
|
+
b.setFooter('© Zervonex')
|
|
3444
|
+
|
|
3445
|
+
// Header — pick one
|
|
3446
|
+
b.setImage('https://example.com/image.jpg')
|
|
3447
|
+
b.setVideo('https://example.com/video.mp4')
|
|
3448
|
+
b.setDocument('https://example.com/file.pdf', 'file.pdf')
|
|
3449
|
+
b.setText('Header text')
|
|
3450
|
+
b.setLocation(6.5244, 3.3792, 'Lagos', { address: 'Lagos Island', thumbnail: buffer })
|
|
3451
|
+
b.setLocationHeader(6.5244, 3.3792, 'Lagos') // legacy header — buttons render horizontally
|
|
3452
|
+
|
|
3453
|
+
// Native-flow buttons
|
|
3454
|
+
b.reply('Quick Reply', 'reply_id')
|
|
3455
|
+
b.url('Visit Website', 'https://zervonex.com')
|
|
3456
|
+
b.url('Visit Website', 'https://zervonex.com', 'https://merchant.com') // with merchant URL
|
|
3457
|
+
b.call('Call Us', '+2341234567890')
|
|
3458
|
+
b.copy('Copy Code', 'NEXUS2025')
|
|
3459
|
+
b.openWebview('Open App', 'https://app.zervonex.com')
|
|
3460
|
+
b.catalog('View Catalog')
|
|
3461
|
+
b.flow('Start Flow', 'flow_id_here')
|
|
3462
|
+
b.flow('Start Flow', 'flow_id_here', { token: 'custom_token' })
|
|
3463
|
+
b.remind('Set Reminder')
|
|
3464
|
+
b.cancelReminder('Cancel Reminder')
|
|
3465
|
+
b.address('Share Address')
|
|
3466
|
+
b.sendLocation('Share Location')
|
|
3467
|
+
b.reviewAndPay('Review & Pay')
|
|
3468
|
+
b.reviewOrder('Review Order')
|
|
3469
|
+
b.orderDetails('Order Details')
|
|
3470
|
+
b.paymentStatus('Payment Status')
|
|
3471
|
+
b.transactionDetails('Transaction Details')
|
|
3472
|
+
b.select('Choose Option', [
|
|
3473
|
+
{ title: 'Section Title', rows: [{ title: 'Option 1', description: 'optional', id: 'opt1' }] }
|
|
3474
|
+
])
|
|
3475
|
+
|
|
3476
|
+
// Legacy buttons — renders side by side, max 3
|
|
3477
|
+
b.legacyButton('Button 1', 'btn1_id')
|
|
3478
|
+
b.legacyButton('Button 2', 'btn2_id')
|
|
3479
|
+
b.legacyButton('Button 3', 'btn3_id')
|
|
3480
|
+
|
|
3481
|
+
// Template buttons
|
|
3482
|
+
b.templateReply('Quick Reply', 'reply_id')
|
|
3483
|
+
b.templateUrl('Visit', 'https://zervonex.com')
|
|
3484
|
+
b.templateCall('Call', '+2341234567890')
|
|
3485
|
+
|
|
3486
|
+
// Message-level params
|
|
3487
|
+
b.setParams({ key: 'value' })
|
|
3488
|
+
b.setLimitedTimeOffer(Date.now() + 3600000)
|
|
3489
|
+
b.setBottomSheet({ title: 'Select' })
|
|
3490
|
+
b.setTapTargetConfiguration({ dismissible: true })
|
|
3491
|
+
|
|
3492
|
+
// Convert to carousel card
|
|
3493
|
+
const card = b.toCard()
|
|
3494
|
+
|
|
3495
|
+
// Send
|
|
3496
|
+
await b.send(jid)
|
|
3497
|
+
await b.send(jid, { messageId: 'custom_id' })
|
|
3498
|
+
```
|
|
3499
|
+
|
|
3500
|
+
</details>
|
|
3501
|
+
|
|
3502
|
+
<details>
|
|
3503
|
+
<summary><strong>Carousel Builder</strong></summary>
|
|
3504
|
+
|
|
3505
|
+
```javascript
|
|
3506
|
+
const c = sock.carousel()
|
|
3507
|
+
|
|
3508
|
+
c.setCaption('Our Products')
|
|
3509
|
+
c.setFooter('Powered by zervonex')
|
|
3510
|
+
c.setCardType('HSCROLL_CARDS') // 'HSCROLL_CARDS' (default) | 'ALBUM_IMAGE'
|
|
3511
|
+
|
|
3512
|
+
// Add cards — pass a Button builder instance or a raw card object (max 10 cards)
|
|
3513
|
+
c.card(sock.button().setBody('Card 1').reply('Select', 'card1').url('Learn More', 'https://example.com'))
|
|
3514
|
+
c.card(sock.button().setImage('https://example.com/img.jpg').setBody('Card 2').reply('Select', 'card2'))
|
|
3515
|
+
|
|
3516
|
+
await c.send(jid)
|
|
3517
|
+
```
|
|
3518
|
+
|
|
3519
|
+
</details>
|
|
3520
|
+
|
|
3521
|
+
<details>
|
|
3522
|
+
<summary><strong>Album Builder</strong></summary>
|
|
3523
|
+
|
|
3524
|
+
```javascript
|
|
3525
|
+
const a = sock.album()
|
|
3526
|
+
|
|
3527
|
+
// Add items — URLs, Buffers, or file paths
|
|
3528
|
+
a.image('https://example.com/1.jpg', 'Caption for photo 1')
|
|
3529
|
+
a.image(buffer, 'Caption for photo 2')
|
|
3530
|
+
a.video('https://example.com/video.mp4', 'Caption for video')
|
|
3531
|
+
a.add([ // add multiple at once
|
|
3532
|
+
{ image: { url: 'https://example.com/3.jpg' }, caption: 'Photo 3' },
|
|
3533
|
+
{ video: { url: 'https://example.com/4.mp4' }, caption: 'Video 2' }
|
|
3534
|
+
])
|
|
3535
|
+
|
|
3536
|
+
a.setDelay(1500) // ms between each item send (default: 1500)
|
|
3537
|
+
|
|
3538
|
+
// Requires at least 2 items
|
|
3539
|
+
await a.send(jid)
|
|
3540
|
+
```
|
|
3541
|
+
|
|
3542
|
+
</details>
|
|
3543
|
+
|
|
3544
|
+
<details>
|
|
3545
|
+
<summary><strong>VerticalAlbum Builder</strong></summary>
|
|
3546
|
+
|
|
3547
|
+
Sends a full-width stacked media album using the AIRich unified response format. Unlike the standard Album builder (which sends individual messages), this renders all items in a single rich message.
|
|
3548
|
+
|
|
3549
|
+
```javascript
|
|
3550
|
+
await sock.sendMessage(jid, {
|
|
3551
|
+
verticalAlbumMessage: [
|
|
3552
|
+
{ type: 'image', image: { url: 'https://example.com/1.jpg' } },
|
|
3553
|
+
{ type: 'video', video: { url: 'https://example.com/2.mp4' }, duration: 10 },
|
|
3554
|
+
{ type: 'image', image: { url: 'https://example.com/3.jpg' }, width: 1280, height: 720 }
|
|
3555
|
+
]
|
|
3556
|
+
})
|
|
3557
|
+
|
|
3558
|
+
// Via shorthand
|
|
3559
|
+
await sock.sendVerticalAlbumMessage(jid, {
|
|
3560
|
+
items: [
|
|
3561
|
+
{ type: 'image', image: { url: 'https://example.com/1.jpg' } },
|
|
3562
|
+
{ type: 'video', video: { url: 'https://example.com/2.mp4' } }
|
|
3563
|
+
]
|
|
3564
|
+
})
|
|
3565
|
+
```
|
|
3566
|
+
|
|
3567
|
+
</details>
|
|
3568
|
+
|
|
3569
|
+
<details>
|
|
3570
|
+
<summary><strong>GridImage Builder</strong></summary>
|
|
3571
|
+
|
|
3572
|
+
```javascript
|
|
3573
|
+
await sock.sendMessage(jid, {
|
|
3574
|
+
gridImageMessage: {
|
|
3575
|
+
imageUrls: [
|
|
3576
|
+
{ url: 'https://example.com/1.jpg', width: 600, height: 400 },
|
|
3577
|
+
{ url: 'https://example.com/2.jpg', width: 600, height: 400 },
|
|
3578
|
+
{ url: 'https://example.com/3.jpg', width: 600, height: 400 }
|
|
3579
|
+
]
|
|
3580
|
+
}
|
|
3581
|
+
})
|
|
3582
|
+
|
|
3583
|
+
// Via shorthand
|
|
3584
|
+
await sock.sendGridImageMessage(jid, {
|
|
3585
|
+
imageUrls: [
|
|
3586
|
+
'https://example.com/1.jpg',
|
|
3587
|
+
'https://example.com/2.jpg'
|
|
3588
|
+
]
|
|
3589
|
+
})
|
|
3590
|
+
```
|
|
3591
|
+
|
|
3592
|
+
</details>
|
|
3593
|
+
|
|
3594
|
+
<details>
|
|
3595
|
+
<summary><strong>VideoGrid Builder</strong></summary>
|
|
3596
|
+
|
|
3597
|
+
```javascript
|
|
3598
|
+
await sock.sendMessage(jid, {
|
|
3599
|
+
videoGridMessage: {
|
|
3600
|
+
videos: [
|
|
3601
|
+
{
|
|
3602
|
+
url: 'https://example.com/1.mp4',
|
|
3603
|
+
title: 'Video 1',
|
|
3604
|
+
thumbnailUrl: 'https://example.com/thumb1.jpg',
|
|
3605
|
+
creator: 'Creator Name',
|
|
3606
|
+
likes: 1200,
|
|
3607
|
+
isVerified: true
|
|
3608
|
+
},
|
|
3609
|
+
{
|
|
3610
|
+
url: 'https://example.com/2.mp4',
|
|
3611
|
+
title: 'Video 2',
|
|
3612
|
+
thumbnailUrl: 'https://example.com/thumb2.jpg'
|
|
3613
|
+
}
|
|
3614
|
+
]
|
|
3615
|
+
}
|
|
3616
|
+
})
|
|
3617
|
+
|
|
3618
|
+
// Via shorthand
|
|
3619
|
+
await sock.sendVideoGridMessage(jid, {
|
|
3620
|
+
videos: [
|
|
3621
|
+
{ url: 'https://example.com/1.mp4', title: 'Clip 1' },
|
|
3622
|
+
{ url: 'https://example.com/2.mp4', title: 'Clip 2' }
|
|
3623
|
+
]
|
|
3624
|
+
})
|
|
3625
|
+
```
|
|
3626
|
+
|
|
3627
|
+
</details>
|
|
3628
|
+
|
|
3629
|
+
<details>
|
|
3630
|
+
<summary><strong>A2UI Builder</strong></summary>
|
|
3631
|
+
|
|
3632
|
+
> [!WARNING] The A2UI catalog (`v0.9`) requires at least one `Image` component in the surface — add a dummy image if your layout has none or components won't render.
|
|
3633
|
+
|
|
3634
|
+
```javascript
|
|
3635
|
+
import { A2UI } from '@zervonexx/baileys'
|
|
3636
|
+
|
|
3637
|
+
// Static helpers
|
|
3638
|
+
A2UI.text('id', 'Hello!', { variant: 'h1' })
|
|
3639
|
+
// variants: h1 | h2 | h3 | h4 | h5 | caption | body
|
|
3640
|
+
|
|
3641
|
+
A2UI.image('id', 'https://example.com/img.jpg', { variant: 'header', fit: 'cover' })
|
|
3642
|
+
// variants: icon | avatar | smallFeature | mediumFeature | largeFeature | header
|
|
3643
|
+
// fits: contain | cover | fill | none | scaleDown
|
|
3644
|
+
|
|
3645
|
+
A2UI.icon('id', 'send')
|
|
3646
|
+
A2UI.column('id', ['child1', 'child2'], { justify: 'start', align: 'stretch' })
|
|
3647
|
+
A2UI.row('id', ['left', 'right'], { justify: 'spaceEvenly', align: 'center' })
|
|
3648
|
+
A2UI.list('id', ['item1', 'item2'], { direction: 'vertical' })
|
|
3649
|
+
A2UI.card('id', 'childId')
|
|
3650
|
+
A2UI.tabs('id', [{ title: 'Tab 1', child: 'tab1_content' }, { title: 'Tab 2', child: 'tab2_content' }])
|
|
3651
|
+
A2UI.modal('id', 'triggerButtonId', 'contentId')
|
|
3652
|
+
A2UI.divider('id', { axis: 'horizontal' })
|
|
3653
|
+
A2UI.button('id', 'childId', { call: 'openUrl', args: { url: 'https://example.com' } }, { variant: 'primary' })
|
|
3654
|
+
A2UI.textField('id', 'Label', { value: '', variant: 'shortText' })
|
|
3655
|
+
A2UI.checkBox('id', 'Label', false)
|
|
3656
|
+
A2UI.choicePicker('id',
|
|
3657
|
+
[{ label: 'Option A', value: 'a' }, { label: 'Option B', value: 'b' }],
|
|
3658
|
+
['a'],
|
|
3659
|
+
{ label: 'Pick one', variant: 'mutuallyExclusive', displayStyle: 'chips' }
|
|
3660
|
+
)
|
|
3661
|
+
A2UI.slider('id', 5, 10, { label: 'Rating', min: 1 })
|
|
3662
|
+
A2UI.dateTimeInput('id', '', { label: 'Date', enableDate: true, enableTime: false })
|
|
3663
|
+
A2UI.surface(components, { surfaceId, catalogId, version })
|
|
3664
|
+
|
|
3665
|
+
// Fluent instance builder
|
|
3666
|
+
await new A2UI(sock)
|
|
3667
|
+
.addColumn('root', ['img', 'title', 'dummy'])
|
|
3668
|
+
.addImage('img', 'https://example.com/img.jpg', { variant: 'header', fit: 'cover' })
|
|
3669
|
+
.addText('title', 'Hello!', { variant: 'h1' })
|
|
3670
|
+
.addDivider('div1')
|
|
3671
|
+
.addCard('card1', 'card_col')
|
|
3672
|
+
.addColumn('card_col', ['card_text'])
|
|
3673
|
+
.addText('card_text', 'Card content', { variant: 'body' })
|
|
3674
|
+
.addImage('dummy', 'https://example.com/img.jpg', { variant: 'avatar', fit: 'cover' })
|
|
3675
|
+
.addButton('quick_reply', { display_text: 'Reply', id: 'reply_id' })
|
|
3676
|
+
.setFallback('Fallback text for unsupported clients')
|
|
3677
|
+
.setSurfaceId('my-custom-surface-id')
|
|
3678
|
+
.setImage('https://example.com/header.jpg')
|
|
3679
|
+
.send(jid)
|
|
3680
|
+
|
|
3681
|
+
// sock.sendA2UI shortcut
|
|
3682
|
+
await sock.sendA2UI(jid, [
|
|
3683
|
+
A2UI.column('root', ['img', 'title', 'dummy']),
|
|
3684
|
+
A2UI.image('img', 'https://example.com/img.jpg', { variant: 'header' }),
|
|
3685
|
+
A2UI.text('title', 'Hello!', { variant: 'h1' }),
|
|
3686
|
+
A2UI.image('dummy', 'https://example.com/img.jpg', { variant: 'avatar' })
|
|
3687
|
+
], {
|
|
3688
|
+
buttons: [
|
|
3689
|
+
{ name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: 'Hi', id: 'hi' }) }
|
|
3690
|
+
]
|
|
3691
|
+
})
|
|
3692
|
+
|
|
3693
|
+
// Command Menu Preset
|
|
3694
|
+
await sock.sendA2UICommandMenu(jid, {
|
|
3695
|
+
title: 'zervonex Menu',
|
|
3696
|
+
rows: [
|
|
3697
|
+
['!help', 'Show all commands'],
|
|
3698
|
+
['!ping', 'Check bot status'],
|
|
3699
|
+
['!ai', 'Ask AI a question']
|
|
3700
|
+
],
|
|
3701
|
+
buttons: [
|
|
3702
|
+
{ text: 'GitHub', url: 'https://github.com/nexustechpro2' }
|
|
3703
|
+
],
|
|
3704
|
+
footer: 'Powered by zervonex',
|
|
3705
|
+
image: 'https://example.com/header.jpg' // optional
|
|
3706
|
+
})
|
|
3707
|
+
```
|
|
3708
|
+
|
|
3709
|
+
</details>
|
|
3710
|
+
|
|
3711
|
+
<details>
|
|
3712
|
+
<summary><strong>Poll Builder</strong></summary>
|
|
3713
|
+
|
|
3714
|
+
```javascript
|
|
3715
|
+
const p = sock.poll()
|
|
3716
|
+
|
|
3717
|
+
p.name('What is your favorite color?')
|
|
3718
|
+
p.options(['Red', 'Blue', 'Green', 'Yellow'])
|
|
3719
|
+
p.addOption('Purple') // add one more option
|
|
3720
|
+
p.multiSelect(2) // allow selecting up to 2 (0 = unlimited)
|
|
3721
|
+
p.hideVoter() // hide who voted
|
|
3722
|
+
p.announcement() // for announcement groups
|
|
3723
|
+
|
|
3724
|
+
// Quiz mode — single correct answer
|
|
3725
|
+
p.quiz('Blue')
|
|
3726
|
+
|
|
3727
|
+
// Timed poll
|
|
3728
|
+
p.setEndTime(Math.floor(Date.now() / 1000) + 3600) // ends in 1 hour
|
|
3729
|
+
p.hideParticipantName() // hide voter names
|
|
3730
|
+
p.allowAddOption() // allow participants to add options
|
|
3731
|
+
|
|
3732
|
+
await p.send(jid)
|
|
3733
|
+
```
|
|
3734
|
+
|
|
3735
|
+
</details>
|
|
3736
|
+
|
|
3737
|
+
<details>
|
|
3738
|
+
<summary><strong>Event Builder</strong></summary>
|
|
3739
|
+
|
|
3740
|
+
```javascript
|
|
3741
|
+
const e = sock.event()
|
|
3742
|
+
|
|
3743
|
+
e.setName('NexusTech Conference 2026')
|
|
3744
|
+
e.setDescription('Annual developer meetup')
|
|
3745
|
+
e.setLocation({ degreesLatitude: 6.5244, degreesLongitude: 3.3792, name: 'Lagos, Nigeria' })
|
|
3746
|
+
e.setJoinLink('https://meet.example.com/nexusconf')
|
|
3747
|
+
e.setStartTime(Math.floor(Date.now() / 1000) + 86400)
|
|
3748
|
+
e.setEndTime(Math.floor(Date.now() / 1000) + 172800)
|
|
3749
|
+
e.setCanceled(false)
|
|
3750
|
+
e.setReminder(3600) // remind 1 hour before (sets hasReminder + reminderOffsetSec)
|
|
3751
|
+
e.setScheduledCall(true) // marks as a scheduled call event
|
|
3752
|
+
|
|
3753
|
+
await e.send(jid)
|
|
3754
|
+
```
|
|
3755
|
+
|
|
3756
|
+
</details>
|
|
3757
|
+
|
|
3758
|
+
<details>
|
|
3759
|
+
<summary><strong>Payment Builder</strong></summary>
|
|
3760
|
+
|
|
3761
|
+
```javascript
|
|
3762
|
+
const pay = sock.payment()
|
|
3763
|
+
|
|
3764
|
+
pay.setCurrency('NGN')
|
|
3765
|
+
pay.setAmount(10000000) // amount × 1000
|
|
3766
|
+
pay.setFrom('1234567890@s.whatsapp.net')
|
|
3767
|
+
pay.setNote('Payment for order #123')
|
|
3768
|
+
pay.setExpiry(Date.now() + 86400000)
|
|
3769
|
+
|
|
3770
|
+
await pay.send(jid)
|
|
3771
|
+
```
|
|
3772
|
+
|
|
3773
|
+
</details>
|
|
3774
|
+
|
|
3775
|
+
<details>
|
|
3776
|
+
<summary><strong>Order Builder</strong></summary>
|
|
3777
|
+
|
|
3778
|
+
```javascript
|
|
3779
|
+
const ord = sock.order()
|
|
3780
|
+
|
|
3781
|
+
ord.from({
|
|
3782
|
+
orderId: 'ORDER_001',
|
|
3783
|
+
itemCount: 3,
|
|
3784
|
+
totalAmount1000: 45000000,
|
|
3785
|
+
totalCurrencyCode: 'NGN',
|
|
3786
|
+
orderTitle: 'My Order',
|
|
3787
|
+
message: 'Thank you for your order',
|
|
3788
|
+
thumbnail: 'https://example.com/product.jpg'
|
|
3789
|
+
})
|
|
3790
|
+
|
|
3791
|
+
await ord.send(jid)
|
|
3792
|
+
```
|
|
3793
|
+
|
|
3794
|
+
</details>
|
|
3795
|
+
|
|
3796
|
+
---
|
|
3797
|
+
|
|
3798
|
+
## 🛠 Utility Methods
|
|
3799
|
+
|
|
3800
|
+
<details>
|
|
3801
|
+
<summary><strong>Show utility method examples</strong></summary>
|
|
3802
|
+
|
|
3803
|
+
```javascript
|
|
3804
|
+
// Refresh stale contacts — triggers WA to re-push contact data
|
|
3805
|
+
await sock.requestContactRefresh(['1234567890@s.whatsapp.net', '0987654321@s.whatsapp.net'])
|
|
3806
|
+
|
|
3807
|
+
// Fetch message history on demand
|
|
3808
|
+
await sock.fetchMessageHistory(50, oldestMessageKey, oldestMessageTimestamp)
|
|
3809
|
+
|
|
3810
|
+
// Request a placeholder message to be resent (for unavailable encrypted messages)
|
|
3811
|
+
await sock.requestPlaceholderResend(messageKey)
|
|
3812
|
+
|
|
3813
|
+
// Capture an AIRich message for forwarding
|
|
3814
|
+
const captured = sock.captureAiRich(msg.message)
|
|
3815
|
+
// { submessages, sections, contextInfo, messageType }
|
|
3816
|
+
|
|
3817
|
+
// Relay a captured AIRich message to another JID
|
|
3818
|
+
if (captured) await sock.relayAiRich(targetJid, captured)
|
|
3819
|
+
```
|
|
3820
|
+
|
|
3821
|
+
</details>
|
|
3822
|
+
|
|
3823
|
+
---
|
|
3824
|
+
|
|
3825
|
+
## 📦 Exported Utilities
|
|
3826
|
+
|
|
3827
|
+
<details>
|
|
3828
|
+
<summary><strong>Show all exports</strong></summary>
|
|
3829
|
+
|
|
3830
|
+
Everything exported from `@zervonexx/baileys` that you can import directly:
|
|
3831
|
+
|
|
3832
|
+
```javascript
|
|
3833
|
+
import {
|
|
3834
|
+
// Connection
|
|
3835
|
+
makeWASocket,
|
|
3836
|
+
useMultiFileAuthState,
|
|
3837
|
+
useKeyvAuthState,
|
|
3838
|
+
hasKeyvAuth,
|
|
3839
|
+
clearAdapterCache,
|
|
3840
|
+
makeCacheableSignalKeyStore,
|
|
3841
|
+
Browsers,
|
|
3842
|
+
DisconnectReason,
|
|
3843
|
+
|
|
3844
|
+
// Message generation
|
|
3845
|
+
generateWAMessage,
|
|
3846
|
+
generateWAMessageFromContent,
|
|
3847
|
+
generateWAMessageContent,
|
|
3848
|
+
generateMessageIDV2,
|
|
3849
|
+
|
|
3850
|
+
// Media
|
|
3851
|
+
downloadMediaMessage,
|
|
3852
|
+
downloadContentFromMessage,
|
|
3853
|
+
prepareWAMessageMedia,
|
|
3854
|
+
|
|
3855
|
+
// Media URL utilities
|
|
3856
|
+
isHttpUrl, // isHttpUrl(input) → boolean — true if input is a valid HTTP/HTTPS URL
|
|
3857
|
+
resolveToMediaUrl, // resolveToMediaUrl(input) → Promise<string> — resolves buffer/path/url to a hosted URL
|
|
3858
|
+
|
|
3859
|
+
// Message utils
|
|
3860
|
+
getContentType,
|
|
3861
|
+
normalizeMessageContent,
|
|
3862
|
+
extractMessageContent,
|
|
3863
|
+
getAggregateVotesInPollMessage,
|
|
3864
|
+
|
|
3865
|
+
// JID utils
|
|
3866
|
+
jidDecode,
|
|
3867
|
+
jidNormalizedUser,
|
|
3868
|
+
areJidsSameUser,
|
|
3869
|
+
isJidGroup,
|
|
3870
|
+
isJidNewsletterGroup,
|
|
3871
|
+
isJidUser,
|
|
3872
|
+
isLidUser,
|
|
3873
|
+
isJidBroadcast,
|
|
3874
|
+
isJidStatusBroadcast,
|
|
3875
|
+
|
|
3876
|
+
// Types / Enums
|
|
3877
|
+
WAMessageStubType,
|
|
3878
|
+
WAMessageStatus,
|
|
3879
|
+
WAMessageAddressingMode,
|
|
3880
|
+
resolveStubType, // resolveStubType(stubType) → name string
|
|
3881
|
+
WA_STUB_TYPE_NAMES, // { 196: 'SUPPORT_AI_EDUCATION', 225: 'SCHEDULED_MESSAGE_CREATED', ... }
|
|
3882
|
+
AIProvenanceType, // { NONE: 0, CREATED_WITH_GEN_AI: 1, EDITED_WITH_GEN_AI: 2 }
|
|
3883
|
+
DeviceCapabilityLevel, // { NONE: 0, INFRA: 1, FULL: 2 }
|
|
3884
|
+
|
|
3885
|
+
// Rich message helpers
|
|
3886
|
+
tokenizeCode, // tokenizeCode(code, language) → { codeBlocks, unified_codeBlock }
|
|
3887
|
+
extractIE, // extractIE(text, extraEntities?) → { text, inline_entities }
|
|
3888
|
+
waitAllPromises, // deep async resolver
|
|
3889
|
+
generateVerificationMetadata, // bot signature metadata
|
|
3890
|
+
|
|
3891
|
+
// AIRich utilities
|
|
3892
|
+
hasVerifiableProofs,
|
|
3893
|
+
wrapToBotForwardedMessage,
|
|
3894
|
+
attachBotVerificationProofs,
|
|
3895
|
+
buildImaginePrimitive,
|
|
3896
|
+
prepareRichGenerationMessage,
|
|
3897
|
+
extractVerificationMetadata,
|
|
3898
|
+
|
|
3899
|
+
// Status checker
|
|
3900
|
+
checkStatusWA,
|
|
3901
|
+
} from '@zervonexx/baileys'
|
|
3902
|
+
```
|
|
3903
|
+
|
|
3904
|
+
</details>
|
|
3905
|
+
|
|
3906
|
+
---
|
|
3907
|
+
|
|
3908
|
+
## 📡 Events Reference
|
|
3909
|
+
|
|
3910
|
+
<details>
|
|
3911
|
+
<summary><strong>Show events table</strong></summary>
|
|
3912
|
+
|
|
3913
|
+
| Event | Fields | Description |
|
|
3914
|
+
|-------|--------|-------------|
|
|
3915
|
+
| `connection.update` | `connection`, `qr`, `lastDisconnect`, `isNewLogin` | Connection state changed |
|
|
3916
|
+
| `creds.update` | partial `AuthenticationCreds` | Auth credentials updated |
|
|
3917
|
+
| `messaging-history.set` | `chats`, `contacts`, `messages`, `syncType`, `isLatest` | Initial history loaded |
|
|
3918
|
+
| `messages.upsert` | `messages[]`, `type` | New message(s) received |
|
|
3919
|
+
| `messages.update` | `[{ key, update }]` | Message status/content updated |
|
|
3920
|
+
| `messages.delete` | `keys[]` or `{ jid, all }` | Message(s) deleted |
|
|
3921
|
+
| `messages.reaction` | `[{ reaction, key }]` | Reaction added/removed |
|
|
3922
|
+
| `messages.media-update` | `[{ key, media?, error? }]` | Media upload status updated |
|
|
3923
|
+
| `message-receipt.update` | `[{ key, receipt }]` | Read/delivered receipts |
|
|
3924
|
+
| `chats.set` | `{ chats[], isLatest }` | Initial chat list loaded |
|
|
3925
|
+
| `chats.upsert` | `Chat[]` | New chat(s) appeared |
|
|
3926
|
+
| `chats.update` | `Partial<Chat>[]` | Chat metadata updated |
|
|
3927
|
+
| `chats.delete` | `string[]` | Chat(s) deleted |
|
|
3928
|
+
| `contacts.set` | `{ contacts[] }` | Initial contacts loaded |
|
|
3929
|
+
| `contacts.upsert` | `Contact[]` | New contact(s) added |
|
|
3930
|
+
| `contacts.update` | `Partial<Contact>[]` | Contact info updated |
|
|
3931
|
+
| `groups.upsert` | `GroupMetadata[]` | New group created/joined |
|
|
3932
|
+
| `groups.update` | `Partial<GroupMetadata>[]` | Group metadata changed |
|
|
3933
|
+
| `group-participants.update` | `{ id, author, authorPn, participants, action }` | Member added/removed/promoted/demoted |
|
|
3934
|
+
| `blocklist.set` | `{ blocklist[] }` | Initial blocklist loaded |
|
|
3935
|
+
| `blocklist.update` | `{ blocklist[], type }` | Block/unblock event |
|
|
3936
|
+
| `presence.update` | `{ id, presences }` | User presence changed |
|
|
3937
|
+
| `call` | `WACallEvent[]` | Incoming/outgoing call |
|
|
3938
|
+
| `labels.edit` | `Label` | Label created/updated |
|
|
3939
|
+
| `labels.association` | `[{ association, type }]` | Message/chat label assigned/removed |
|
|
3940
|
+
| `settings.update` | `{ setting, value }` | Account setting changed |
|
|
3941
|
+
|
|
3942
|
+
**`group-participants.update` fields:**
|
|
3943
|
+
|
|
3944
|
+
| Field | Type | Description |
|
|
3945
|
+
|-------|------|-------------|
|
|
3946
|
+
| `id` | `string` | Group JID |
|
|
3947
|
+
| `author` | `string` | JID of who performed the action |
|
|
3948
|
+
| `authorPn` | `string` | Phone number of the actor (PN format) |
|
|
3949
|
+
| `participants` | `string[]` | JIDs of affected participants |
|
|
3950
|
+
| `action` | `string` | `add` \| `remove` \| `promote` \| `demote` |
|
|
3951
|
+
|
|
3952
|
+
</details>
|
|
3953
|
+
|
|
3954
|
+
---
|
|
3955
|
+
|
|
3956
|
+
## 🤖 Meta AI Messages
|
|
3957
|
+
|
|
3958
|
+
<details>
|
|
3959
|
+
<summary><strong>Show Meta AI message handling</strong></summary>
|
|
3960
|
+
|
|
3961
|
+
Meta AI bot messages (`msmsg` encrypted responses) are automatically decrypted when received. They arrive as regular messages in `messages.upsert` once decrypted:
|
|
3962
|
+
|
|
3963
|
+
```javascript
|
|
3964
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
3965
|
+
for (const msg of messages) {
|
|
3966
|
+
if (!msg.message) continue
|
|
3967
|
+
|
|
3968
|
+
// Meta AI responses appear as regular extendedTextMessage or other content
|
|
3969
|
+
const content = extractMessageContent(msg.message)
|
|
3970
|
+
if (content?.extendedTextMessage?.text) {
|
|
3971
|
+
console.log('Message (possibly Meta AI):', content.extendedTextMessage.text)
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
})
|
|
3975
|
+
```
|
|
3976
|
+
|
|
3977
|
+
If decryption fails (e.g. missing message secret), the message is gracefully NACKed and logged — it won't crash your session.
|
|
3978
|
+
|
|
3979
|
+
</details>
|
|
3980
|
+
|
|
3981
|
+
---
|
|
3982
|
+
|
|
3983
|
+
## 🎯 Best Practices
|
|
3984
|
+
|
|
3985
|
+
<details>
|
|
3986
|
+
<summary><strong>Reconnection</strong></summary>
|
|
3987
|
+
|
|
3988
|
+
```javascript
|
|
3989
|
+
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
3990
|
+
if (connection === 'close') {
|
|
3991
|
+
const code = lastDisconnect?.error?.output?.statusCode
|
|
3992
|
+
const shouldReconnect = code !== DisconnectReason.loggedOut
|
|
3993
|
+
if (shouldReconnect) connectToWhatsApp()
|
|
3994
|
+
else console.log('Logged out — clear session and re-authenticate')
|
|
3995
|
+
}
|
|
3996
|
+
})
|
|
3997
|
+
```
|
|
3998
|
+
|
|
3999
|
+
</details>
|
|
4000
|
+
|
|
4001
|
+
<details>
|
|
4002
|
+
<summary><strong>Cache Group Metadata</strong></summary>
|
|
4003
|
+
|
|
4004
|
+
```javascript
|
|
4005
|
+
import NodeCache from '@cacheable/node-cache'
|
|
4006
|
+
|
|
4007
|
+
const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false })
|
|
4008
|
+
|
|
4009
|
+
const sock = makeWASocket({
|
|
4010
|
+
cachedGroupMetadata: async (jid) => groupCache.get(jid)
|
|
4011
|
+
})
|
|
4012
|
+
|
|
4013
|
+
sock.ev.on('groups.update', async ([event]) => {
|
|
4014
|
+
const metadata = await sock.groupMetadata(event.id)
|
|
4015
|
+
groupCache.set(event.id, metadata)
|
|
4016
|
+
})
|
|
4017
|
+
```
|
|
4018
|
+
|
|
4019
|
+
</details>
|
|
4020
|
+
|
|
4021
|
+
<details>
|
|
4022
|
+
<summary><strong>Rate Limiting</strong></summary>
|
|
4023
|
+
|
|
4024
|
+
```javascript
|
|
4025
|
+
const queue = []
|
|
4026
|
+
let sending = false
|
|
4027
|
+
|
|
4028
|
+
const queueMessage = (jid, content) => {
|
|
4029
|
+
queue.push({ jid, content })
|
|
4030
|
+
if (!sending) processQueue()
|
|
4031
|
+
}
|
|
4032
|
+
|
|
4033
|
+
const processQueue = async () => {
|
|
4034
|
+
sending = true
|
|
4035
|
+
while (queue.length > 0) {
|
|
4036
|
+
const { jid, content } = queue.shift()
|
|
4037
|
+
await sock.sendMessage(jid, content)
|
|
4038
|
+
await new Promise(r => setTimeout(r, 1000)) // 1s delay between messages
|
|
4039
|
+
}
|
|
4040
|
+
sending = false
|
|
4041
|
+
}
|
|
4042
|
+
```
|
|
4043
|
+
|
|
4044
|
+
</details>
|
|
4045
|
+
|
|
4046
|
+
<details>
|
|
4047
|
+
<summary><strong>Error Handling</strong></summary>
|
|
4048
|
+
|
|
4049
|
+
```javascript
|
|
4050
|
+
try {
|
|
4051
|
+
await sock.sendMessage(jid, { text: 'Hello' })
|
|
4052
|
+
} catch (error) {
|
|
4053
|
+
if (error.output?.statusCode === 401) console.log('Unauthorized')
|
|
4054
|
+
else console.error('Send failed:', error)
|
|
4055
|
+
}
|
|
4056
|
+
```
|
|
4057
|
+
|
|
4058
|
+
</details>
|
|
4059
|
+
|
|
4060
|
+
<details>
|
|
4061
|
+
<summary><strong>Poll Decryption</strong></summary>
|
|
4062
|
+
|
|
4063
|
+
```javascript
|
|
4064
|
+
import { getAggregateVotesInPollMessage } from '@zervonexx/baileys'
|
|
4065
|
+
|
|
4066
|
+
sock.ev.on('messages.update', async (event) => {
|
|
4067
|
+
for (const { key, update } of event) {
|
|
4068
|
+
if (update.pollUpdates) {
|
|
4069
|
+
const pollCreation = await getMessage(key)
|
|
4070
|
+
if (pollCreation) {
|
|
4071
|
+
const result = getAggregateVotesInPollMessage({
|
|
4072
|
+
message: pollCreation,
|
|
4073
|
+
pollUpdates: update.pollUpdates
|
|
4074
|
+
})
|
|
4075
|
+
console.log('Poll votes:', result)
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
})
|
|
4080
|
+
```
|
|
4081
|
+
|
|
4082
|
+
</details>
|
|
4083
|
+
|
|
4084
|
+
---
|
|
4085
|
+
|
|
4086
|
+
## ⚠️ Disclaimer
|
|
4087
|
+
|
|
4088
|
+
This project is **not** affiliated with WhatsApp or Meta. Use responsibly:
|
|
4089
|
+
|
|
4090
|
+
- Follow WhatsApp's Terms of Service
|
|
4091
|
+
- Do not spam or send unsolicited messages
|
|
4092
|
+
- Respect user privacy
|
|
4093
|
+
- Be aware of WhatsApp's rate limits
|
|
4094
|
+
- This library is for legitimate automation purposes only
|
|
4095
|
+
|
|
4096
|
+
---
|
|
4097
|
+
|
|
4098
|
+
## 🙏 Acknowledgments
|
|
4099
|
+
|
|
4100
|
+
- [WhiskeySockets](https://github.com/WhiskeySockets) for the original Baileys library
|
|
4101
|
+
- All contributors and the open-source community
|
|
4102
|
+
|
|
4103
|
+
---
|
|
4104
|
+
|
|
4105
|
+
<div align="center">
|
|
4106
|
+
|
|
4107
|
+
**Made with ❤️ by [nexustechpro2](https://github.com/nexustechpro2)**
|
|
4108
|
+
|
|
4109
|
+
⭐ **Star us on GitHub!** ⭐
|
|
4110
|
+
|
|
4111
|
+
[GitHub](https://github.com/nexustechpro2/baileys) • [NPM](https://www.npmjs.com/package/@zervonexx/baileys)
|
|
4112
|
+
|
|
4113
|
+
</div>
|