@kyyinfinite/baileys 2.0.0 β 2.1.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 +21 -0
- package/README.md +546 -1648
- package/lib/Kyyinfinite/Simple/KyyMessage.js +46 -0
- package/lib/Kyyinfinite/Simple/MediaBuilder.js +9 -3
- package/lib/Kyyinfinite/Simple/MessageBuilder.js +16 -2
- package/lib/Kyyinfinite/Simple/SimpleClient.js +37 -0
- package/lib/Kyyinfinite/Simple/TextBuilder.js +8 -2
- package/lib/Kyyinfinite/Simple/UniversalMediaBuilder.js +21 -0
- package/lib/Kyyinfinite/Simple/index.d.ts +94 -3
- package/lib/Kyyinfinite/Simple/index.js +8 -1
- package/lib/Kyyinfinite/Simple/jid.js +55 -0
- package/lib/Kyyinfinite/Simple/messageUtils.js +49 -0
- package/lib/Kyyinfinite/Simple/parseMessage.js +55 -0
- package/package.json +19 -8
- package/test/core.test.js +38 -0
- package/test/simple-api.test.js +183 -0
package/README.md
CHANGED
|
@@ -1,453 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<img src="https://readme-typing-svg.demolab.com?font=Fira+Code&weight=700&size=15&duration=2500&pause=800&color=00B4D8¢er=true&vCenter=true&width=750&lines=@kyyinfinite%2Fbaileys+%E2%80%94+v2.0.0;Interactive+Messages+%7C+Flow+Buttons+%7C+List+Menus;AI+Rich+Response+%7C+Table+%7C+Code+Block+%7C+Link;Album+Messages+%7C+Multi-media+Grouped+Delivery;Based+on+WhiskeySockets%2FBaileys+v7.0.0-rc14;ESM-only+%7C+TypeScript+%7C+Signal+Protocol" alt="Typing SVG" />
|
|
4
|
-
|
|
5
|
-
<br/>
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@kyyinfinite/baileys)
|
|
8
|
-
[](https://github.com/WhiskeySockets/Baileys/releases/tag/v7.0.0-rc14)
|
|
9
|
-
[](https://www.npmjs.com/package/@kyyinfinite/baileys)
|
|
10
|
-
[](LICENSE)
|
|
11
|
-
[](https://nodejs.org)
|
|
12
|
-
[](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
|
|
13
|
-
[](https://www.typescriptlang.org)
|
|
14
|
-
[](https://github.com/kyyinfinite/baileys)
|
|
15
|
-
|
|
16
|
-
<br/>
|
|
17
|
-
|
|
18
|
-
**`@kyyinfinite/baileys`** is built on top of the official **[WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys) v7.0.0-rc14** release.
|
|
19
|
-
It keeps the native Baileys socket API intact while adding a cleaner **Kyyinfinite Simple API** for message building, media, buttons, carousels, and other helpers.
|
|
20
|
-
|
|
21
|
-
<br/>
|
|
22
|
-
|
|
23
|
-
> [!IMPORTANT]
|
|
24
|
-
> **`@kyyinfinite/baileys`** is **ESM-only**. You must set `"type": "module"` in your `package.json`.
|
|
25
|
-
> CommonJS projects must migrate or use dynamic `import()` wrappers.
|
|
26
|
-
>
|
|
27
|
-
> **Base:** `@whiskeysockets/baileys@7.0.0-rc14`
|
|
28
|
-
|
|
29
|
-
<br/>
|
|
30
|
-
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## π Table of Contents
|
|
36
|
-
|
|
37
|
-
- [β¨ Features](#-features)
|
|
38
|
-
- [β
Requirements](#-requirements)
|
|
39
|
-
- [π¦ Installation](#-installation)
|
|
40
|
-
- [π Quick Start](#-quick-start)
|
|
41
|
-
- [β¨ Simple API](#-simple-api)
|
|
42
|
-
- [Setup](#setup)
|
|
43
|
-
- [Text](#text-1)
|
|
44
|
-
- [Media](#media)
|
|
45
|
-
- [Message Builder](#message-builder)
|
|
46
|
-
- [Buttons](#buttons)
|
|
47
|
-
- [Carousel](#carousel-1)
|
|
48
|
-
- [Generic Message Helpers](#generic-message-helpers)
|
|
49
|
-
- [Non-mutating API](#non-mutating-api)
|
|
50
|
-
- [Native Baileys Still Works](#native-baileys-still-works)
|
|
51
|
-
- [π¬ Message Examples](#-message-examples)
|
|
52
|
-
- [Text](#text)
|
|
53
|
-
- [Image](#image)
|
|
54
|
-
- [Video](#video)
|
|
55
|
-
- [Audio & PTT](#audio--ptt)
|
|
56
|
-
- [Sticker](#sticker)
|
|
57
|
-
- [Document](#document)
|
|
58
|
-
- [Location](#location)
|
|
59
|
-
- [Contact](#contact)
|
|
60
|
-
- [Poll](#poll)
|
|
61
|
-
- [Reaction](#reaction)
|
|
62
|
-
- [Delete & Edit](#delete--edit)
|
|
63
|
-
- [Forward & Quoted](#forward--quoted)
|
|
64
|
-
- [Mention](#mention)
|
|
65
|
-
- [β‘ Interactive Messages](#-interactive-messages)
|
|
66
|
-
- [Flow Buttons](#flow-buttons)
|
|
67
|
-
- [CTA URL Button](#cta-url-button)
|
|
68
|
-
- [Copy Button](#copy-button)
|
|
69
|
-
- [List Menu (single_select)](#list-menu-single_select)
|
|
70
|
-
- [Carousel](#carousel)
|
|
71
|
-
- [Native Interactive](#native-interactive)
|
|
72
|
-
- [π€ AI Rich Response](#-ai-rich-response)
|
|
73
|
-
- [sendTable()](#sendtable)
|
|
74
|
-
- [sendList()](#sendlist)
|
|
75
|
-
- [sendCodeBlock()](#sendcodeblock)
|
|
76
|
-
- [sendLink()](#sendlink)
|
|
77
|
-
- [sendUnifiedResponse()](#sendunifiedresponse)
|
|
78
|
-
- [sendTableV2()](#sendtablev2)
|
|
79
|
-
- [sendCodeBlockV2()](#sendcodeblockv2)
|
|
80
|
-
- [sendLinkV2()](#sendlinkv2)
|
|
81
|
-
- [ποΈ Album Messages](#οΈ-album-messages)
|
|
82
|
-
- [π° Newsletter](#-newsletter)
|
|
83
|
-
- [π₯ Group](#-group)
|
|
84
|
-
- [ποΈ Community](#οΈ-community)
|
|
85
|
-
- [π’ Business](#-business)
|
|
86
|
-
- [π€ Profile](#-profile)
|
|
87
|
-
- [π¬ Chat](#-chat)
|
|
88
|
-
- [π Privacy](#-privacy)
|
|
89
|
-
- [π‘ Events](#-events)
|
|
90
|
-
- [π§ Utility Exports](#-utility-exports)
|
|
91
|
-
- [π API Reference](#-api-reference)
|
|
92
|
-
- [β FAQ](#-faq)
|
|
93
|
-
- [π License](#-license)
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## β¨ Features
|
|
98
|
-
|
|
99
|
-
| Feature | Description | Status |
|
|
100
|
-
|---|---|:---:|
|
|
101
|
-
| **Interactive Messages** | Native Baileys interactive messages, native flow buttons, list/select menus, and carousel structures | β
|
|
|
102
|
-
| **Flow Buttons** | `quick_reply`, `cta_url`, `cta_copy` and more button types | β
|
|
|
103
|
-
| **Native Button** | Native WhatsApp button structures | β
|
|
|
104
|
-
| **Carousel** | Multi-card carousel messages using Baileys `interactiveMessage` / `carouselMessage` structures | β
|
|
|
105
|
-
| **AI Rich Response** | Rich-response message structures plus Kyyinfinite helper methods such as `sendTable`, `sendList`, `sendCodeBlock`, and `sendUnifiedResponse` | β
|
|
|
106
|
-
| **Album Messages** | Multi-image/video album relay with count metadata and grouped delivery | β
|
|
|
107
|
-
| **Link Messages** | Rich inline links with citations, proofs, and forwarded bot context | β
|
|
|
108
|
-
| **Table Message** | `sendTable()` / `sendTableV2()` styled as Meta AI tables | β
|
|
|
109
|
-
| **Code Block** | `sendCodeBlock()` / `sendCodeBlockV2()` with multi-language syntax support | β
|
|
|
110
|
-
| **Unified Response** | `sendUnifiedResponse()` unified sections | β
|
|
|
111
|
-
| **Newsletter** | URL resolve, metadata fetch, create/update, bulk follow, admin utilities, live updates | β
|
|
|
112
|
-
| **Communities** | Community CRUD, linked groups, invite workflows, join approval, labels | β
|
|
|
113
|
-
| **Business API** | Business profile update, catalog management, product CRUD | β
|
|
|
114
|
-
| **Catalog** | Fetch, create, update, delete product listings and cover photos | β
|
|
|
115
|
-
| **Payment** | Request payment messages with note/sticker support | β
|
|
|
116
|
-
| **Poll** | Send and receive poll messages with `selectableCount` | β
|
|
|
117
|
-
| **Event** | Event message builders and poll result snapshots | β
|
|
|
118
|
-
| **Status Mention** | `sendStatusMention()` to mention users/groups in status flows | β
|
|
|
119
|
-
| **LID Mapping** | Full LIDβPN mapping + session migration and retry helpers | β
|
|
|
120
|
-
| **Pairing Code** | Request pairing code or use custom 8-char code | β
|
|
|
121
|
-
| **QR Login** | Scan QR code via `connection.update` event | β
|
|
|
122
|
-
| **Media Upload** | Image, video, audio, sticker, document via URL or Buffer | β
|
|
|
123
|
-
| **TypeScript** | Included `.d.ts` declarations for all exported APIs | β
|
|
|
124
|
-
| **ESM** | Native ES Module β no CommonJS bundle | β
|
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## β
Requirements
|
|
129
|
-
|
|
130
|
-
| Requirement | Version / Detail |
|
|
131
|
-
|---|---|
|
|
132
|
-
| **Node.js** | `>= 20.0.0` |
|
|
133
|
-
| **Baileys base** | `7.0.0-rc14` |
|
|
134
|
-
| **Module system** | ESM only β `"type": "module"` in `package.json` |
|
|
135
|
-
| **Auth store** | Persistent auth required for production use |
|
|
136
|
-
|
|
137
|
-
**Optional companion packages:**
|
|
138
|
-
|
|
139
|
-
| Package | Purpose |
|
|
140
|
-
|---|---|
|
|
141
|
-
| `pino` | Structured logging |
|
|
142
|
-
| `qrcode-terminal` | Render QR codes in terminal |
|
|
143
|
-
| `sharp` | Image processing for sticker/media utilities |
|
|
144
|
-
| `link-preview-js` | Generate link previews |
|
|
145
|
-
| `audio-decode` | Audio format decoding |
|
|
146
|
-
|
|
147
|
-
> [!NOTE]
|
|
148
|
-
> Peer dependencies like `sharp`, `jimp`, `audio-decode`, and `link-preview-js` are **optional**.
|
|
149
|
-
> Install only what your bot features actually need.
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## π¦ Installation
|
|
154
|
-
|
|
155
|
-
**npm**
|
|
156
|
-
```bash
|
|
157
|
-
npm install @kyyinfinite/baileys
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**pnpm**
|
|
161
|
-
```bash
|
|
162
|
-
pnpm add @kyyinfinite/baileys
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
**yarn**
|
|
166
|
-
```bash
|
|
167
|
-
yarn add @kyyinfinite/baileys
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
**bun**
|
|
171
|
-
```bash
|
|
172
|
-
bun add @kyyinfinite/baileys
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
**Recommended companion packages:**
|
|
176
|
-
```bash
|
|
177
|
-
npm install pino qrcode-terminal
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
> [!TIP]
|
|
181
|
-
> Always install `pino` and `qrcode-terminal` alongside `@kyyinfinite/baileys` for the best development experience β logger suppression and QR rendering are needed in almost every bot project.
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
## π Quick Start
|
|
186
|
-
|
|
187
|
-
### 1. Project Setup
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
mkdir my-bot && cd my-bot
|
|
191
|
-
npm init -y
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Open `package.json` and add `"type": "module"`:
|
|
195
|
-
|
|
196
|
-
```json
|
|
197
|
-
{
|
|
198
|
-
"name": "my-bot",
|
|
199
|
-
"version": "1.0.0",
|
|
200
|
-
"type": "module",
|
|
201
|
-
"main": "index.js",
|
|
202
|
-
"scripts": {
|
|
203
|
-
"start": "node index.js"
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
> [!IMPORTANT]
|
|
209
|
-
> **`"type": "module"` is required.** `@kyyinfinite/baileys` is ESM-only.
|
|
210
|
-
> Without this field, all imports will throw a syntax error.
|
|
211
|
-
|
|
212
|
-
---
|
|
213
|
-
|
|
214
|
-
### 2. Install Dependencies
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
npm install @kyyinfinite/baileys pino qrcode-terminal
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
### 3. Create index.js
|
|
223
|
-
|
|
224
|
-
```js
|
|
225
|
-
import makeWASocket, {
|
|
226
|
-
useMultiFileAuthState,
|
|
227
|
-
DisconnectReason,
|
|
228
|
-
Browsers,
|
|
229
|
-
} from "@kyyinfinite/baileys";
|
|
230
|
-
import pino from "pino";
|
|
231
|
-
import qrcode from "qrcode-terminal";
|
|
232
|
-
|
|
233
|
-
const logger = pino({ level: "silent" });
|
|
234
|
-
|
|
235
|
-
async function startBot() {
|
|
236
|
-
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
237
|
-
|
|
238
|
-
const sock = makeWASocket({
|
|
239
|
-
auth: state,
|
|
240
|
-
logger,
|
|
241
|
-
browser: Browsers.ubuntu("Chrome"),
|
|
242
|
-
syncFullHistory: false,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
sock.ev.on("creds.update", saveCreds);
|
|
246
|
-
|
|
247
|
-
sock.ev.on("connection.update", ({ connection, lastDisconnect, qr }) => {
|
|
248
|
-
if (qr) {
|
|
249
|
-
qrcode.generate(qr, { small: true });
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (connection === "close") {
|
|
253
|
-
const shouldReconnect =
|
|
254
|
-
lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut;
|
|
255
|
-
if (shouldReconnect) startBot();
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (connection === "open") {
|
|
259
|
-
console.log("β
Connected!");
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
sock.ev.on("messages.upsert", async ({ messages }) => {
|
|
264
|
-
const msg = messages[0];
|
|
265
|
-
if (!msg?.message || msg.key.fromMe) return;
|
|
266
|
-
|
|
267
|
-
const text =
|
|
268
|
-
msg.message.conversation ||
|
|
269
|
-
msg.message.extendedTextMessage?.text ||
|
|
270
|
-
"";
|
|
271
|
-
|
|
272
|
-
if (text === ".ping") {
|
|
273
|
-
await sock.sendMessage(msg.key.remoteJid, { text: "π Pong!" });
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
startBot();
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
---
|
|
282
|
-
|
|
283
|
-
### 4. Run & QR Code Login
|
|
284
|
-
|
|
285
|
-
```bash
|
|
286
|
-
node index.js
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
Scan the QR code in your terminal using **WhatsApp β Linked Devices β Link a Device**.
|
|
290
|
-
Wait until the socket reaches `connection === "open"`, then send `.ping` to test.
|
|
291
|
-
|
|
292
|
-
---
|
|
293
|
-
|
|
294
|
-
### 5. Pairing Code Login
|
|
1
|
+
# @kyyinfinite/baileys
|
|
295
2
|
|
|
296
|
-
|
|
3
|
+
A developer-friendly WhatsApp messaging API for Node.js with a fluent
|
|
4
|
+
builder interface, message utilities, JID helpers, interactive messages,
|
|
5
|
+
media handling, and advanced message composition.
|
|
297
6
|
|
|
298
|
-
|
|
299
|
-
import makeWASocket, {
|
|
300
|
-
useMultiFileAuthState,
|
|
301
|
-
Browsers,
|
|
302
|
-
} from "@kyyinfinite/baileys";
|
|
303
|
-
import pino from "pino";
|
|
7
|
+
## Installation
|
|
304
8
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
async function startBot() {
|
|
308
|
-
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
309
|
-
|
|
310
|
-
const sock = makeWASocket({
|
|
311
|
-
auth: state,
|
|
312
|
-
logger,
|
|
313
|
-
browser: Browsers.windows("Chrome"),
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
sock.ev.on("creds.update", saveCreds);
|
|
317
|
-
|
|
318
|
-
sock.ev.on("connection.update", async ({ connection }) => {
|
|
319
|
-
if (connection === "connecting") {
|
|
320
|
-
// Replace with your phone number (include country code, no +)
|
|
321
|
-
const code = await sock.requestPairingCode("6281234567890");
|
|
322
|
-
console.log("π Pairing code:", code);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (connection === "open") {
|
|
326
|
-
console.log("β
Connected via pairing code!");
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
startBot();
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
**Custom pairing code (exactly 8 characters):**
|
|
335
|
-
|
|
336
|
-
```js
|
|
337
|
-
const code = await sock.requestPairingCode("6281234567890", "A1B2C3D4");
|
|
338
|
-
console.log("π Custom pairing code:", code);
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
> [!WARNING]
|
|
342
|
-
> Custom pairing codes **must be exactly 8 characters**. Any other length will be rejected by WhatsApp.
|
|
343
|
-
|
|
344
|
-
> [!NOTE]
|
|
345
|
-
> `printQRInTerminal` still exists in the type surface for compatibility, but it is deprecated in this build.
|
|
346
|
-
> Prefer handling the `qr` value from `connection.update` directly with `qrcode-terminal`.
|
|
347
|
-
|
|
348
|
-
---
|
|
349
|
-
|
|
350
|
-
### 6. Auto Reconnect
|
|
351
|
-
|
|
352
|
-
```js
|
|
353
|
-
sock.ev.on("connection.update", ({ connection, lastDisconnect }) => {
|
|
354
|
-
if (connection === "close") {
|
|
355
|
-
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
|
356
|
-
const shouldReconnect = statusCode !== DisconnectReason.loggedOut;
|
|
357
|
-
|
|
358
|
-
console.log(`Connection closed (code: ${statusCode}). Reconnecting: ${shouldReconnect}`);
|
|
359
|
-
|
|
360
|
-
if (shouldReconnect) {
|
|
361
|
-
startBot(); // call your startBot function again
|
|
362
|
-
} else {
|
|
363
|
-
console.log("Logged out. Delete ./session and restart.");
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
});
|
|
9
|
+
``` bash
|
|
10
|
+
npm install @kyyinfinite/baileys
|
|
367
11
|
```
|
|
368
12
|
|
|
369
|
-
|
|
370
|
-
> For production bots, use a process manager like **PM2** (`pm2 start index.js`) so your bot automatically restarts after crashes, not just reconnects after disconnects.
|
|
371
|
-
|
|
372
|
-
---
|
|
373
|
-
|
|
374
|
-
## β¨ Simple API
|
|
375
|
-
|
|
376
|
-
> [!NOTE]
|
|
377
|
-
> **v2.0.0** introduces the `@kyyinfinite/baileys` Simple API β a fluent wrapper on top of the native socket.
|
|
378
|
-
> Native Baileys methods remain available and unchanged.
|
|
379
|
-
|
|
380
|
-
### Setup
|
|
13
|
+
## Quick Start
|
|
381
14
|
|
|
382
|
-
```js
|
|
383
|
-
import makeWASocket,
|
|
384
|
-
useMultiFileAuthState,
|
|
385
|
-
attachKyyinfinite,
|
|
386
|
-
} from "@kyyinfinite/baileys";
|
|
387
|
-
|
|
388
|
-
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
389
|
-
|
|
390
|
-
const sock = makeWASocket({
|
|
391
|
-
auth: state,
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
sock.ev.on("creds.update", saveCreds);
|
|
395
|
-
|
|
396
|
-
attachKyyinfinite(sock);
|
|
397
|
-
```
|
|
15
|
+
``` js
|
|
16
|
+
import { makeWASocket, attachKyyinfinite } from '@kyyinfinite/baileys'
|
|
398
17
|
|
|
399
|
-
|
|
18
|
+
const sock = makeWASocket(config)
|
|
400
19
|
|
|
401
|
-
|
|
20
|
+
attachKyyinfinite(sock)
|
|
402
21
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
.send(jid)
|
|
22
|
+
await sock
|
|
23
|
+
.text('Hello')
|
|
24
|
+
.send(jid)
|
|
406
25
|
```
|
|
407
26
|
|
|
408
|
-
|
|
27
|
+
The API is designed to keep common operations short while still allowing
|
|
28
|
+
advanced message builders when needed.
|
|
409
29
|
|
|
410
|
-
|
|
411
|
-
await sock.image({ url: "./image.jpg" })
|
|
412
|
-
.caption("Hello")
|
|
413
|
-
.send(jid);
|
|
30
|
+
------------------------------------------------------------------------
|
|
414
31
|
|
|
415
|
-
|
|
416
|
-
.caption("Video")
|
|
417
|
-
.send(jid);
|
|
32
|
+
# API
|
|
418
33
|
|
|
419
|
-
|
|
420
|
-
.send(jid);
|
|
34
|
+
## Text
|
|
421
35
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
.send(jid);
|
|
427
|
-
|
|
428
|
-
await sock.document({ url: "./file.pdf" })
|
|
429
|
-
.fileName("document.pdf")
|
|
430
|
-
.send(jid);
|
|
431
|
-
|
|
432
|
-
await sock.ptv({ url: "./video.mp4" })
|
|
433
|
-
.send(jid);
|
|
434
|
-
|
|
435
|
-
await sock.gif({ url: "./video.mp4" })
|
|
436
|
-
.send(jid);
|
|
36
|
+
``` js
|
|
37
|
+
await sock
|
|
38
|
+
.text('Hello')
|
|
39
|
+
.send(jid)
|
|
437
40
|
```
|
|
438
41
|
|
|
439
|
-
|
|
42
|
+
Additional text options:
|
|
440
43
|
|
|
441
|
-
```js
|
|
442
|
-
await sock
|
|
443
|
-
.
|
|
444
|
-
.
|
|
445
|
-
.
|
|
44
|
+
``` js
|
|
45
|
+
await sock
|
|
46
|
+
.text('Hello')
|
|
47
|
+
.footer('Kyyinfinite')
|
|
48
|
+
.mentions(['628123456789@s.whatsapp.net'])
|
|
49
|
+
.send(jid)
|
|
446
50
|
```
|
|
447
51
|
|
|
448
|
-
|
|
52
|
+
Available text builder methods:
|
|
449
53
|
|
|
450
|
-
```text
|
|
54
|
+
``` text
|
|
451
55
|
text()
|
|
452
56
|
footer()
|
|
453
57
|
context()
|
|
@@ -459,1436 +63,730 @@ build()
|
|
|
459
63
|
send()
|
|
460
64
|
```
|
|
461
65
|
|
|
462
|
-
|
|
66
|
+
------------------------------------------------------------------------
|
|
463
67
|
|
|
464
|
-
|
|
465
|
-
await sock.button()
|
|
466
|
-
.title("Welcome")
|
|
467
|
-
.body("Choose an option")
|
|
468
|
-
.footer("Powered by @kyyinfinite/baileys")
|
|
469
|
-
.addButton("Menu", "menu")
|
|
470
|
-
.send(jid);
|
|
471
|
-
```
|
|
68
|
+
# Media
|
|
472
69
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
```js
|
|
476
|
-
await sock.button()
|
|
477
|
-
.title("Actions")
|
|
478
|
-
.body("Choose an action")
|
|
479
|
-
.reply("Reply", "reply_1")
|
|
480
|
-
.url("Website", "https://example.com")
|
|
481
|
-
.copy("Copy", "KYY-001")
|
|
482
|
-
.call("Call", "628123456789")
|
|
483
|
-
.send(jid);
|
|
484
|
-
```
|
|
70
|
+
Shortcut builders:
|
|
485
71
|
|
|
486
|
-
|
|
72
|
+
``` js
|
|
73
|
+
await sock.image('./image.jpg')
|
|
74
|
+
.caption('Image')
|
|
75
|
+
.send(jid)
|
|
487
76
|
|
|
488
|
-
|
|
489
|
-
.
|
|
490
|
-
.
|
|
491
|
-
```
|
|
77
|
+
await sock.video('./video.mp4')
|
|
78
|
+
.caption('Video')
|
|
79
|
+
.send(jid)
|
|
492
80
|
|
|
493
|
-
|
|
81
|
+
await sock.audio('./audio.mp3')
|
|
82
|
+
.send(jid)
|
|
494
83
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
call()
|
|
498
|
-
url()
|
|
499
|
-
copy() / coppy()
|
|
500
|
-
reminder()
|
|
501
|
-
cancelReminder()
|
|
502
|
-
address()
|
|
503
|
-
location()
|
|
504
|
-
select()
|
|
505
|
-
section()
|
|
506
|
-
row()
|
|
507
|
-
```
|
|
84
|
+
await sock.voice('./voice.ogg')
|
|
85
|
+
.send(jid)
|
|
508
86
|
|
|
509
|
-
|
|
87
|
+
await sock.document('./file.pdf')
|
|
88
|
+
.fileName('document.pdf')
|
|
89
|
+
.send(jid)
|
|
510
90
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
.title("Button V2")
|
|
514
|
-
.body("Choose an option")
|
|
515
|
-
.send(jid);
|
|
91
|
+
await sock.sticker('./sticker.webp')
|
|
92
|
+
.send(jid)
|
|
516
93
|
```
|
|
517
94
|
|
|
518
|
-
|
|
95
|
+
Other media shortcuts:
|
|
519
96
|
|
|
520
|
-
|
|
97
|
+
``` text
|
|
98
|
+
ptv()
|
|
99
|
+
gif()
|
|
100
|
+
```
|
|
521
101
|
|
|
522
|
-
|
|
102
|
+
## Universal Media
|
|
523
103
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
.button("Pilih", "product_1")
|
|
533
|
-
.url("Website", "https://example.com")
|
|
534
|
-
.copy("Copy Code", "KYY-001")
|
|
535
|
-
.call("Call", "628123456789")
|
|
536
|
-
.add()
|
|
537
|
-
.card()
|
|
538
|
-
.image({ url: "./product-2.jpg" })
|
|
539
|
-
.title("Product Two")
|
|
540
|
-
.body("Product two")
|
|
541
|
-
.button("Pilih", "product_2")
|
|
542
|
-
.add()
|
|
543
|
-
.send(jid);
|
|
104
|
+
Use one builder when the media type needs to be selected dynamically:
|
|
105
|
+
|
|
106
|
+
``` js
|
|
107
|
+
await sock
|
|
108
|
+
.media(buffer)
|
|
109
|
+
.asImage()
|
|
110
|
+
.caption('Photo')
|
|
111
|
+
.send(jid)
|
|
544
112
|
```
|
|
545
113
|
|
|
546
|
-
|
|
114
|
+
Supported types:
|
|
547
115
|
|
|
548
|
-
```text
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
media()
|
|
555
|
-
button()
|
|
556
|
-
reply() / quickReply()
|
|
557
|
-
url()
|
|
558
|
-
copy() / coppy()
|
|
559
|
-
call()
|
|
560
|
-
buttons()
|
|
561
|
-
rawButton()
|
|
562
|
-
context()
|
|
563
|
-
payload()
|
|
564
|
-
build()
|
|
565
|
-
add()
|
|
566
|
-
end()
|
|
116
|
+
``` text
|
|
117
|
+
asImage()
|
|
118
|
+
asVideo()
|
|
119
|
+
asAudio()
|
|
120
|
+
asDocument()
|
|
121
|
+
asSticker()
|
|
567
122
|
```
|
|
568
123
|
|
|
569
|
-
|
|
124
|
+
Media builder options include:
|
|
570
125
|
|
|
571
|
-
```text
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
clear()
|
|
576
|
-
title()
|
|
577
|
-
subtitle()
|
|
578
|
-
body() / text()
|
|
579
|
-
footer()
|
|
126
|
+
``` text
|
|
127
|
+
caption()
|
|
128
|
+
fileName()
|
|
129
|
+
mimetype()
|
|
580
130
|
context()
|
|
131
|
+
mentions()
|
|
581
132
|
payload()
|
|
582
|
-
|
|
133
|
+
viewOnce()
|
|
134
|
+
ptt()
|
|
135
|
+
voice()
|
|
136
|
+
ptv()
|
|
137
|
+
videoNote()
|
|
138
|
+
gif()
|
|
139
|
+
animated()
|
|
140
|
+
dimensions()
|
|
141
|
+
thumbnail()
|
|
583
142
|
build()
|
|
584
143
|
send()
|
|
585
144
|
```
|
|
586
145
|
|
|
587
|
-
|
|
146
|
+
------------------------------------------------------------------------
|
|
588
147
|
|
|
589
|
-
|
|
590
|
-
await sock.message({ text: "Hello" })
|
|
591
|
-
.send(jid);
|
|
148
|
+
## Unified Send
|
|
592
149
|
|
|
593
|
-
|
|
594
|
-
"What's your favorite language?",
|
|
595
|
-
["JavaScript", "TypeScript", "Python"],
|
|
596
|
-
1
|
|
597
|
-
).send(jid);
|
|
150
|
+
For simple messages, use:
|
|
598
151
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
name: "Jakarta"
|
|
603
|
-
}).send(jid);
|
|
152
|
+
``` js
|
|
153
|
+
await sock.send(jid, 'Hello')
|
|
154
|
+
```
|
|
604
155
|
|
|
605
|
-
|
|
156
|
+
Object payloads are also supported:
|
|
606
157
|
|
|
607
|
-
|
|
158
|
+
``` js
|
|
159
|
+
await sock.send(jid, {
|
|
160
|
+
text: 'Hello'
|
|
161
|
+
})
|
|
608
162
|
```
|
|
609
163
|
|
|
610
|
-
|
|
164
|
+
Media:
|
|
611
165
|
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
contacts()
|
|
618
|
-
location()
|
|
619
|
-
buttonReply()
|
|
620
|
-
listReply()
|
|
621
|
-
react()
|
|
622
|
-
groupInvite()
|
|
623
|
-
product()
|
|
624
|
-
requestPhoneNumber()
|
|
625
|
-
sharePhoneNumber()
|
|
626
|
-
pin()
|
|
627
|
-
forward()
|
|
628
|
-
delete()
|
|
629
|
-
disappearing()
|
|
630
|
-
limitSharing()
|
|
166
|
+
``` js
|
|
167
|
+
await sock.send(jid, {
|
|
168
|
+
image: './image.jpg',
|
|
169
|
+
caption: 'Hello'
|
|
170
|
+
})
|
|
631
171
|
```
|
|
632
172
|
|
|
633
|
-
|
|
173
|
+
The unified API is intended for cases where you do not need to manually
|
|
174
|
+
create a builder.
|
|
634
175
|
|
|
635
|
-
|
|
176
|
+
------------------------------------------------------------------------
|
|
636
177
|
|
|
637
|
-
|
|
638
|
-
import {
|
|
639
|
-
createKyyinfinite,
|
|
640
|
-
} from "@kyyinfinite/baileys";
|
|
178
|
+
## Quoted Messages
|
|
641
179
|
|
|
642
|
-
|
|
180
|
+
Reply directly to an existing message:
|
|
643
181
|
|
|
644
|
-
|
|
645
|
-
|
|
182
|
+
``` js
|
|
183
|
+
await sock.reply(message, 'Hello')
|
|
646
184
|
```
|
|
647
185
|
|
|
648
|
-
|
|
186
|
+
Or:
|
|
649
187
|
|
|
650
|
-
```js
|
|
651
|
-
|
|
188
|
+
``` js
|
|
189
|
+
await sock.quoted(message, 'Hello')
|
|
652
190
|
```
|
|
653
191
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
```js
|
|
657
|
-
api.raw.Button
|
|
658
|
-
api.raw.ButtonV2
|
|
659
|
-
api.raw.Carousel
|
|
660
|
-
api.raw.AIRich
|
|
661
|
-
api.raw.Toolkit
|
|
662
|
-
api.raw.Foad
|
|
663
|
-
api.raw.Foad2
|
|
664
|
-
```
|
|
192
|
+
Message wrapper:
|
|
665
193
|
|
|
666
|
-
|
|
194
|
+
``` js
|
|
195
|
+
const m = sock.wrapMessage(message)
|
|
667
196
|
|
|
668
|
-
|
|
197
|
+
await m.reply('Hello')
|
|
198
|
+
```
|
|
669
199
|
|
|
670
|
-
|
|
200
|
+
Available message actions:
|
|
671
201
|
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
202
|
+
``` text
|
|
203
|
+
reply()
|
|
204
|
+
react()
|
|
205
|
+
edit()
|
|
206
|
+
delete()
|
|
207
|
+
forward()
|
|
208
|
+
download()
|
|
209
|
+
```
|
|
676
210
|
|
|
677
|
-
|
|
211
|
+
Socket shortcuts:
|
|
678
212
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
213
|
+
``` text
|
|
214
|
+
reply()
|
|
215
|
+
reactTo()
|
|
216
|
+
editMessage()
|
|
217
|
+
deleteMessage()
|
|
218
|
+
forwardMessage()
|
|
219
|
+
downloadMessage()
|
|
682
220
|
```
|
|
683
221
|
|
|
684
|
-
|
|
222
|
+
------------------------------------------------------------------------
|
|
685
223
|
|
|
686
|
-
|
|
224
|
+
## Message Parser
|
|
687
225
|
|
|
688
|
-
|
|
226
|
+
Parse an incoming message into a simple object:
|
|
689
227
|
|
|
690
|
-
|
|
228
|
+
``` js
|
|
229
|
+
const parsed = sock.parseMessage(message, {
|
|
230
|
+
prefix: '.'
|
|
231
|
+
})
|
|
691
232
|
|
|
692
|
-
|
|
693
|
-
|
|
233
|
+
console.log(parsed.text)
|
|
234
|
+
console.log(parsed.command)
|
|
235
|
+
console.log(parsed.args)
|
|
694
236
|
```
|
|
695
237
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
```js
|
|
699
|
-
// From URL
|
|
700
|
-
await sock.sendMessage(jid, {
|
|
701
|
-
image: { url: "https://example.com/photo.jpg" },
|
|
702
|
-
caption: "A beautiful photo πΈ",
|
|
703
|
-
});
|
|
704
|
-
|
|
705
|
-
// From file path
|
|
706
|
-
await sock.sendMessage(jid, {
|
|
707
|
-
image: { url: "./photo.jpg" },
|
|
708
|
-
caption: "Local photo",
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
// From Buffer
|
|
712
|
-
import { readFileSync } from "fs";
|
|
713
|
-
await sock.sendMessage(jid, {
|
|
714
|
-
image: readFileSync("./photo.jpg"),
|
|
715
|
-
caption: "From buffer",
|
|
716
|
-
});
|
|
717
|
-
```
|
|
238
|
+
Returned data includes:
|
|
718
239
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
// Audio file
|
|
733
|
-
await sock.sendMessage(jid, {
|
|
734
|
-
audio: { url: "./audio.mp3" },
|
|
735
|
-
mimetype: "audio/mp4",
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
// Push-to-talk (voice note)
|
|
739
|
-
await sock.sendMessage(jid, {
|
|
740
|
-
audio: { url: "./voice.ogg" },
|
|
741
|
-
mimetype: "audio/ogg; codecs=opus",
|
|
742
|
-
ptt: true,
|
|
743
|
-
});
|
|
240
|
+
``` text
|
|
241
|
+
message
|
|
242
|
+
content
|
|
243
|
+
messageType
|
|
244
|
+
text
|
|
245
|
+
command
|
|
246
|
+
args
|
|
247
|
+
jid
|
|
248
|
+
sender
|
|
249
|
+
isGroup
|
|
250
|
+
isReply
|
|
251
|
+
quoted
|
|
252
|
+
key
|
|
744
253
|
```
|
|
745
254
|
|
|
746
|
-
|
|
255
|
+
Example command:
|
|
747
256
|
|
|
748
|
-
```
|
|
749
|
-
|
|
750
|
-
sticker: { url: "./sticker.webp" },
|
|
751
|
-
});
|
|
257
|
+
``` text
|
|
258
|
+
.menu game hard
|
|
752
259
|
```
|
|
753
260
|
|
|
754
|
-
|
|
261
|
+
can be consumed as:
|
|
755
262
|
|
|
756
|
-
```js
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
fileName: "Monthly Report.pdf",
|
|
760
|
-
mimetype: "application/pdf",
|
|
761
|
-
caption: "Here is the report π",
|
|
762
|
-
});
|
|
263
|
+
``` js
|
|
264
|
+
parsed.command // "menu"
|
|
265
|
+
parsed.args // ["game", "hard"]
|
|
763
266
|
```
|
|
764
267
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
```js
|
|
768
|
-
await sock.sendMessage(jid, {
|
|
769
|
-
location: {
|
|
770
|
-
degreesLatitude: -6.2088,
|
|
771
|
-
degreesLongitude: 106.8456,
|
|
772
|
-
name: "Jakarta, Indonesia",
|
|
773
|
-
address: "Jakarta, Indonesia",
|
|
774
|
-
},
|
|
775
|
-
});
|
|
776
|
-
```
|
|
268
|
+
------------------------------------------------------------------------
|
|
777
269
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
```js
|
|
781
|
-
await sock.sendMessage(jid, {
|
|
782
|
-
contacts: {
|
|
783
|
-
displayName: "John Doe",
|
|
784
|
-
contacts: [
|
|
785
|
-
{
|
|
786
|
-
vcard: `BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL;type=CELL;type=VOICE;waid=6281234567890:+62 812-3456-7890\nEND:VCARD`,
|
|
787
|
-
},
|
|
788
|
-
],
|
|
789
|
-
},
|
|
790
|
-
});
|
|
791
|
-
```
|
|
270
|
+
## Mentions
|
|
792
271
|
|
|
793
|
-
|
|
272
|
+
Text containing a WhatsApp-style number can be resolved automatically:
|
|
794
273
|
|
|
795
|
-
```js
|
|
796
|
-
await sock.
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
selectableCount: 1, // 0 = allow multiple
|
|
801
|
-
},
|
|
802
|
-
});
|
|
274
|
+
``` js
|
|
275
|
+
await sock.send(
|
|
276
|
+
jid,
|
|
277
|
+
'Hello @628123456789'
|
|
278
|
+
)
|
|
803
279
|
```
|
|
804
280
|
|
|
805
|
-
|
|
281
|
+
Disable automatic mention resolution when required:
|
|
806
282
|
|
|
807
|
-
```js
|
|
808
|
-
await sock.
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
283
|
+
``` js
|
|
284
|
+
await sock.send(
|
|
285
|
+
jid,
|
|
286
|
+
'Hello @628123456789',
|
|
287
|
+
{
|
|
288
|
+
autoMentions: false
|
|
289
|
+
}
|
|
290
|
+
)
|
|
814
291
|
```
|
|
815
292
|
|
|
816
|
-
|
|
293
|
+
Explicit mentions can also be supplied through the builder API.
|
|
817
294
|
|
|
818
|
-
|
|
819
|
-
// Delete a message (for everyone)
|
|
820
|
-
await sock.sendMessage(jid, { delete: msg.key });
|
|
295
|
+
------------------------------------------------------------------------
|
|
821
296
|
|
|
822
|
-
|
|
823
|
-
await sock.sendMessage(jid, {
|
|
824
|
-
text: "This is the corrected text βοΈ",
|
|
825
|
-
edit: msg.key,
|
|
826
|
-
});
|
|
827
|
-
```
|
|
828
|
-
|
|
829
|
-
### Forward & Quoted
|
|
297
|
+
## JID Utilities
|
|
830
298
|
|
|
831
|
-
|
|
832
|
-
// Forward a message
|
|
833
|
-
await sock.sendMessage(jid, { forward: msg });
|
|
299
|
+
Parse a JID:
|
|
834
300
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
jid,
|
|
838
|
-
{ text: "This is a reply!" },
|
|
839
|
-
{ quoted: msg }
|
|
840
|
-
);
|
|
301
|
+
``` js
|
|
302
|
+
sock.parseJid('628123456789:7@s.whatsapp.net')
|
|
841
303
|
```
|
|
842
304
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
```js
|
|
846
|
-
await sock.sendMessage(jid, {
|
|
847
|
-
text: "Hey @628111222333, how are you?",
|
|
848
|
-
mentions: ["628111222333@s.whatsapp.net"],
|
|
849
|
-
});
|
|
850
|
-
```
|
|
305
|
+
Result:
|
|
851
306
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
title: "My Bot",
|
|
860
|
-
body: "Powered by @kyyinfinite/baileys",
|
|
861
|
-
thumbnail: readFileSync("./thumbnail.jpg"),
|
|
862
|
-
sourceUrl: "https://github.com/kyyinfinite/baileys",
|
|
863
|
-
mediaType: 1,
|
|
864
|
-
renderLargerThumbnail: true,
|
|
865
|
-
},
|
|
866
|
-
},
|
|
867
|
-
});
|
|
307
|
+
``` js
|
|
308
|
+
{
|
|
309
|
+
user: '628123456789',
|
|
310
|
+
device: '7',
|
|
311
|
+
server: 's.whatsapp.net',
|
|
312
|
+
jid: '628123456789:7@s.whatsapp.net'
|
|
313
|
+
}
|
|
868
314
|
```
|
|
869
315
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
## β‘ Interactive Messages
|
|
873
|
-
|
|
874
|
-
> [!NOTE]
|
|
875
|
-
> Interactive messages are based on the native **Baileys v7.0.0-rc14** message structures.
|
|
876
|
-
> The Kyyinfinite Simple API provides a shorter fluent interface on top of those native structures.
|
|
877
|
-
|
|
878
|
-
### Flow Buttons
|
|
879
|
-
|
|
880
|
-
```js
|
|
881
|
-
await sock.sendMessage(jid, {
|
|
882
|
-
interactiveMessage: {
|
|
883
|
-
title: "Welcome! π",
|
|
884
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
885
|
-
buttons: [
|
|
886
|
-
{
|
|
887
|
-
name: "quick_reply",
|
|
888
|
-
buttonParamsJson: JSON.stringify({
|
|
889
|
-
display_text: "π Menu",
|
|
890
|
-
id: "menu",
|
|
891
|
-
}),
|
|
892
|
-
},
|
|
893
|
-
],
|
|
894
|
-
header: "Choose an option below",
|
|
895
|
-
},
|
|
896
|
-
});
|
|
897
|
-
```
|
|
316
|
+
Access individual parts:
|
|
898
317
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
interactiveMessage: {
|
|
904
|
-
title: "Visit our website",
|
|
905
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
906
|
-
buttons: [
|
|
907
|
-
{
|
|
908
|
-
name: "cta_url",
|
|
909
|
-
buttonParamsJson: JSON.stringify({
|
|
910
|
-
display_text: "π Open Website",
|
|
911
|
-
url: "https://example.com",
|
|
912
|
-
merchant_url: "https://example.com",
|
|
913
|
-
}),
|
|
914
|
-
},
|
|
915
|
-
],
|
|
916
|
-
header: "External Link",
|
|
917
|
-
},
|
|
918
|
-
});
|
|
318
|
+
``` js
|
|
319
|
+
sock.jidUser(jid)
|
|
320
|
+
sock.jidServer(jid)
|
|
321
|
+
sock.jidDevice(jid)
|
|
919
322
|
```
|
|
920
323
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
```js
|
|
924
|
-
await sock.sendMessage(jid, {
|
|
925
|
-
interactiveMessage: {
|
|
926
|
-
title: "Your promo code",
|
|
927
|
-
footer: "Tap to copy",
|
|
928
|
-
buttons: [
|
|
929
|
-
{
|
|
930
|
-
name: "cta_copy",
|
|
931
|
-
buttonParamsJson: JSON.stringify({
|
|
932
|
-
display_text: "π Copy Code",
|
|
933
|
-
copy_code: "KYYBAILEYS2024",
|
|
934
|
-
}),
|
|
935
|
-
},
|
|
936
|
-
],
|
|
937
|
-
header: "Promo Code",
|
|
938
|
-
},
|
|
939
|
-
});
|
|
940
|
-
```
|
|
324
|
+
Normalize:
|
|
941
325
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
```js
|
|
945
|
-
await sock.sendMessage(jid, {
|
|
946
|
-
interactiveMessage: {
|
|
947
|
-
title: "Select a Category",
|
|
948
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
949
|
-
buttons: [
|
|
950
|
-
{
|
|
951
|
-
name: "single_select",
|
|
952
|
-
buttonParamsJson: JSON.stringify({
|
|
953
|
-
title: "π Open Menu",
|
|
954
|
-
sections: [
|
|
955
|
-
{
|
|
956
|
-
title: "π οΈ Tools",
|
|
957
|
-
rows: [
|
|
958
|
-
{ title: "πΌοΈ Sticker Maker", description: "Convert image to sticker", id: ".sticker" },
|
|
959
|
-
{ title: "π£οΈ Text to Speech", description: "Convert text to audio", id: ".tts" },
|
|
960
|
-
{ title: "π AI Search", description: "Ask the AI anything", id: ".ai" },
|
|
961
|
-
],
|
|
962
|
-
},
|
|
963
|
-
{
|
|
964
|
-
title: "βΉοΈ Info",
|
|
965
|
-
rows: [
|
|
966
|
-
{ title: "π Bot Stats", description: "View bot statistics", id: ".stats" },
|
|
967
|
-
{ title: "β Help", description: "How to use this bot", id: ".help" },
|
|
968
|
-
],
|
|
969
|
-
},
|
|
970
|
-
],
|
|
971
|
-
}),
|
|
972
|
-
},
|
|
973
|
-
],
|
|
974
|
-
header: "π€ Bot Menu",
|
|
975
|
-
},
|
|
976
|
-
});
|
|
326
|
+
``` js
|
|
327
|
+
sock.jid(jid)
|
|
977
328
|
```
|
|
978
329
|
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
For the native Baileys structure, a carousel is represented by an `interactiveMessage` containing a `carouselMessage`. Media headers are prepared before the message is relayed:
|
|
982
|
-
|
|
983
|
-
```js
|
|
984
|
-
import {
|
|
985
|
-
proto,
|
|
986
|
-
prepareWAMessageMedia,
|
|
987
|
-
generateWAMessageFromContent,
|
|
988
|
-
} from "@kyyinfinite/baileys";
|
|
989
|
-
|
|
990
|
-
const cards = [];
|
|
991
|
-
|
|
992
|
-
for (const [index, imageUrl] of [
|
|
993
|
-
"https://example.com/card1.jpg",
|
|
994
|
-
"https://example.com/card2.jpg",
|
|
995
|
-
]) {
|
|
996
|
-
const media = await prepareWAMessageMedia(
|
|
997
|
-
{ image: { url: imageUrl } },
|
|
998
|
-
{ upload: sock.waUploadToServer },
|
|
999
|
-
);
|
|
1000
|
-
|
|
1001
|
-
cards.push(
|
|
1002
|
-
proto.Message.InteractiveMessage.fromObject({
|
|
1003
|
-
header: {
|
|
1004
|
-
title: `Card ${index + 1}`,
|
|
1005
|
-
hasMediaAttachment: true,
|
|
1006
|
-
...media,
|
|
1007
|
-
},
|
|
1008
|
-
body: { text: `Description for card ${index + 1}` },
|
|
1009
|
-
footer: { text: "@kyyinfinite/baileys" },
|
|
1010
|
-
nativeFlowMessage: {
|
|
1011
|
-
buttons: [
|
|
1012
|
-
{
|
|
1013
|
-
name: "quick_reply",
|
|
1014
|
-
buttonParamsJson: JSON.stringify({
|
|
1015
|
-
display_text: "Select",
|
|
1016
|
-
id: `card_${index + 1}`,
|
|
1017
|
-
}),
|
|
1018
|
-
},
|
|
1019
|
-
],
|
|
1020
|
-
},
|
|
1021
|
-
}),
|
|
1022
|
-
);
|
|
1023
|
-
}
|
|
330
|
+
Create a JID:
|
|
1024
331
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
{
|
|
1028
|
-
viewOnceMessage: {
|
|
1029
|
-
message: {
|
|
1030
|
-
interactiveMessage: proto.Message.InteractiveMessage.fromObject({
|
|
1031
|
-
body: { text: "Choose a product" },
|
|
1032
|
-
footer: { text: "Swipe to see more" },
|
|
1033
|
-
carouselMessage: { cards },
|
|
1034
|
-
}),
|
|
1035
|
-
},
|
|
1036
|
-
},
|
|
1037
|
-
},
|
|
1038
|
-
{},
|
|
1039
|
-
);
|
|
1040
|
-
|
|
1041
|
-
await sock.relayMessage(
|
|
1042
|
-
jid,
|
|
1043
|
-
message.message,
|
|
1044
|
-
{ messageId: message.key.id },
|
|
1045
|
-
);
|
|
332
|
+
``` js
|
|
333
|
+
sock.makeJid('628123456789')
|
|
1046
334
|
```
|
|
1047
335
|
|
|
336
|
+
JID checks:
|
|
1048
337
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
title: "ποΈ Product Details",
|
|
1057
|
-
footer: "Free shipping above Rp 100.000",
|
|
1058
|
-
buttons: [
|
|
1059
|
-
{
|
|
1060
|
-
name: "quick_reply",
|
|
1061
|
-
buttonParamsJson: JSON.stringify({ display_text: "π Buy Now", id: "buy_now" }),
|
|
1062
|
-
},
|
|
1063
|
-
{
|
|
1064
|
-
name: "cta_url",
|
|
1065
|
-
buttonParamsJson: JSON.stringify({
|
|
1066
|
-
display_text: "π More Info",
|
|
1067
|
-
url: "https://example.com/product",
|
|
1068
|
-
}),
|
|
1069
|
-
},
|
|
1070
|
-
{
|
|
1071
|
-
name: "cta_copy",
|
|
1072
|
-
buttonParamsJson: JSON.stringify({
|
|
1073
|
-
display_text: "π Copy Product ID",
|
|
1074
|
-
copy_code: "PROD-12345",
|
|
1075
|
-
}),
|
|
1076
|
-
},
|
|
1077
|
-
],
|
|
1078
|
-
header: "Premium Package",
|
|
1079
|
-
image: { url: "https://example.com/product.jpg" },
|
|
1080
|
-
},
|
|
1081
|
-
});
|
|
338
|
+
``` js
|
|
339
|
+
sock.isGroup(jid)
|
|
340
|
+
sock.isPrivate(jid)
|
|
341
|
+
sock.isBroadcast(jid)
|
|
342
|
+
sock.isStatus(jid)
|
|
343
|
+
sock.isNewsletter(jid)
|
|
344
|
+
sock.isLid(jid)
|
|
1082
345
|
```
|
|
1083
346
|
|
|
1084
|
-
|
|
347
|
+
------------------------------------------------------------------------
|
|
1085
348
|
|
|
1086
|
-
##
|
|
349
|
+
## Buttons
|
|
1087
350
|
|
|
1088
|
-
|
|
1089
|
-
> These message types are styled to match **Meta AI's** WhatsApp response format β tables, code blocks, and rich linked text.
|
|
1090
|
-
> The underlying rich-response message types are part of the Baileys v7 line. The `sendTable()`, `sendList()`, `sendCodeBlock()`, and related convenience methods documented here are exposed by this package.
|
|
351
|
+
## Basic Button
|
|
1091
352
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
["Type", "Compiled", "Interpreted"],
|
|
1101
|
-
["Typing", "Static", "Dynamic"],
|
|
1102
|
-
["Runtime", "JVM", "V8 / Browser"],
|
|
1103
|
-
["Main Use", "Enterprise", "Web, Full-stack"],
|
|
1104
|
-
["Speed", "Faster", "Slightly Slower"],
|
|
1105
|
-
],
|
|
1106
|
-
quoted,
|
|
1107
|
-
{
|
|
1108
|
-
headerText: "π Comparison Table:",
|
|
1109
|
-
footer: "Hope this helps! π",
|
|
1110
|
-
}
|
|
1111
|
-
);
|
|
353
|
+
``` js
|
|
354
|
+
await sock
|
|
355
|
+
.button()
|
|
356
|
+
.title('Menu')
|
|
357
|
+
.body('Choose an option')
|
|
358
|
+
.addButton('Option 1', 'one')
|
|
359
|
+
.addButton('Option 2', 'two')
|
|
360
|
+
.send(jid)
|
|
1112
361
|
```
|
|
1113
362
|
|
|
1114
|
-
|
|
363
|
+
## Reply
|
|
1115
364
|
|
|
1116
|
-
```js
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
"Bot Information",
|
|
1120
|
-
[
|
|
1121
|
-
["Package", "@kyyinfinite/baileys"],
|
|
1122
|
-
["Version", "2.0.0"],
|
|
1123
|
-
["Developer", "kyyinfinite"],
|
|
1124
|
-
["License", "MIT"],
|
|
1125
|
-
["Node", ">= 20"],
|
|
1126
|
-
],
|
|
1127
|
-
quoted,
|
|
1128
|
-
{ footer: "Β© 2026 kyyinfinite" }
|
|
1129
|
-
);
|
|
365
|
+
``` js
|
|
366
|
+
sock.button()
|
|
367
|
+
.reply('Open', 'open')
|
|
1130
368
|
```
|
|
1131
369
|
|
|
1132
|
-
|
|
370
|
+
Aliases:
|
|
1133
371
|
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
await sock.sendCodeBlock(
|
|
1138
|
-
jid,
|
|
1139
|
-
`import makeWASocket from "@kyyinfinite/baileys";\n\nconst sock = makeWASocket({ auth: state });`,
|
|
1140
|
-
quoted,
|
|
1141
|
-
{
|
|
1142
|
-
language: "javascript",
|
|
1143
|
-
title: "Quick Start",
|
|
1144
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
1145
|
-
}
|
|
1146
|
-
);
|
|
372
|
+
``` text
|
|
373
|
+
reply()
|
|
374
|
+
quickReply()
|
|
1147
375
|
```
|
|
1148
376
|
|
|
1149
|
-
|
|
377
|
+
## URL
|
|
1150
378
|
|
|
1151
|
-
```js
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
"Upload results:\nπ Click: {{IE_0}}download here{{/IE_0}}",
|
|
1155
|
-
["https://example.com/file.zip"],
|
|
1156
|
-
quoted,
|
|
1157
|
-
{
|
|
1158
|
-
headerText: "π File Uploader",
|
|
1159
|
-
footer: "β¨ Upload complete!",
|
|
1160
|
-
citations: [{ sourceTitle: "FileHost", citationNumber: 1 }],
|
|
1161
|
-
}
|
|
1162
|
-
);
|
|
379
|
+
``` js
|
|
380
|
+
sock.button()
|
|
381
|
+
.url('Website', 'https://example.com')
|
|
1163
382
|
```
|
|
1164
383
|
|
|
1165
|
-
|
|
384
|
+
## Copy
|
|
1166
385
|
|
|
1167
|
-
```js
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
"Here is a unified response combining text and structured data.",
|
|
1171
|
-
quoted,
|
|
1172
|
-
{
|
|
1173
|
-
headerText: "π€ AI Response",
|
|
1174
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
1175
|
-
}
|
|
1176
|
-
);
|
|
386
|
+
``` js
|
|
387
|
+
sock.button()
|
|
388
|
+
.copy('Copy Code', 'KYY-001')
|
|
1177
389
|
```
|
|
1178
390
|
|
|
1179
|
-
|
|
391
|
+
Both aliases are supported:
|
|
1180
392
|
|
|
1181
|
-
```
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
["Framework", "Language", "Use Case"],
|
|
1186
|
-
[
|
|
1187
|
-
["Express", "JavaScript", "REST API"],
|
|
1188
|
-
["Fastify", "JavaScript", "High-perf API"],
|
|
1189
|
-
["Hono", "TypeScript", "Edge / Bun"],
|
|
1190
|
-
["Elysia", "TypeScript", "Bun Native"],
|
|
1191
|
-
],
|
|
1192
|
-
quoted,
|
|
1193
|
-
{
|
|
1194
|
-
text: "Here's a framework comparison you requested:",
|
|
1195
|
-
headerText: "π Frameworks",
|
|
1196
|
-
footer: "Updated 2026",
|
|
1197
|
-
}
|
|
1198
|
-
);
|
|
393
|
+
``` text
|
|
394
|
+
copy()
|
|
395
|
+
coppy()
|
|
396
|
+
ctaCopy()
|
|
1199
397
|
```
|
|
1200
398
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
V2 supports: `javascript` / `js` / `typescript` / `ts`, `python` / `py`, `go` / `golang`, `lua`, `bash` / `sh` / `shell`
|
|
399
|
+
## Call
|
|
1204
400
|
|
|
1205
|
-
```js
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
`func main() {\n fmt.Println("Hello, @kyyinfinite/baileys!")\n}`,
|
|
1209
|
-
quoted,
|
|
1210
|
-
{
|
|
1211
|
-
language: "go",
|
|
1212
|
-
title: "Go Example",
|
|
1213
|
-
text: "Here is a Go snippet:",
|
|
1214
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
1215
|
-
}
|
|
1216
|
-
);
|
|
401
|
+
``` js
|
|
402
|
+
sock.button()
|
|
403
|
+
.call('Call', '628123456789')
|
|
1217
404
|
```
|
|
1218
405
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
| Language Key | Aliases |
|
|
1222
|
-
|---|---|
|
|
1223
|
-
| `javascript` | `js`, `typescript`, `ts` |
|
|
1224
|
-
| `python` | `py` |
|
|
1225
|
-
| `go` | `golang` |
|
|
1226
|
-
| `lua` | β |
|
|
1227
|
-
| `bash` | `sh`, `shell` |
|
|
1228
|
-
|
|
1229
|
-
### sendLinkV2()
|
|
406
|
+
Aliases:
|
|
1230
407
|
|
|
1231
|
-
```
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
"Search results:\n- {{IE_0}}Official npm page{{/IE_0}}\n- {{IE_1}}GitHub repository{{/IE_1}}",
|
|
1235
|
-
[
|
|
1236
|
-
{
|
|
1237
|
-
url: "https://www.npmjs.com/package/@kyyinfinite/baileys",
|
|
1238
|
-
displayName: "Official npm page",
|
|
1239
|
-
sourceDisplayName: "npmjs.com",
|
|
1240
|
-
},
|
|
1241
|
-
{
|
|
1242
|
-
url: "https://github.com/kyyinfinite/baileys",
|
|
1243
|
-
displayName: "GitHub repository",
|
|
1244
|
-
sourceDisplayName: "github.com",
|
|
1245
|
-
},
|
|
1246
|
-
],
|
|
1247
|
-
quoted,
|
|
1248
|
-
{
|
|
1249
|
-
headerText: "@kyyinfinite/baileys",
|
|
1250
|
-
footer: "Reference links",
|
|
1251
|
-
searchEngine: "MAME",
|
|
1252
|
-
}
|
|
1253
|
-
);
|
|
408
|
+
``` text
|
|
409
|
+
call()
|
|
410
|
+
ctaCall()
|
|
1254
411
|
```
|
|
1255
412
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
## ποΈ Album Messages
|
|
413
|
+
Other button helpers:
|
|
1259
414
|
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
415
|
+
``` text
|
|
416
|
+
reminder()
|
|
417
|
+
cancelReminder()
|
|
418
|
+
address()
|
|
419
|
+
location()
|
|
420
|
+
select()
|
|
421
|
+
section()
|
|
422
|
+
row()
|
|
423
|
+
image()
|
|
424
|
+
document()
|
|
425
|
+
media()
|
|
426
|
+
context()
|
|
427
|
+
payload()
|
|
428
|
+
clear()
|
|
429
|
+
params()
|
|
1271
430
|
```
|
|
1272
431
|
|
|
1273
|
-
|
|
1274
|
-
> Albums automatically compute and set `expectedImageCount` and `expectedVideoCount`
|
|
1275
|
-
> based on the array content. You do not need to set these manually.
|
|
1276
|
-
|
|
1277
|
-
> [!TIP]
|
|
1278
|
-
> You can mix images and videos freely inside an album. Albums support both local file paths and remote URLs.
|
|
1279
|
-
|
|
1280
|
-
---
|
|
1281
|
-
|
|
1282
|
-
## π° Newsletter
|
|
1283
|
-
|
|
1284
|
-
All newsletter methods are available directly on the socket:
|
|
1285
|
-
|
|
1286
|
-
```js
|
|
1287
|
-
// Follow a newsletter channel
|
|
1288
|
-
await sock.newsletterFollow("123456789@newsletter");
|
|
1289
|
-
|
|
1290
|
-
// Unfollow a newsletter channel
|
|
1291
|
-
await sock.newsletterUnfollow("123456789@newsletter");
|
|
432
|
+
------------------------------------------------------------------------
|
|
1292
433
|
|
|
1293
|
-
|
|
1294
|
-
await sock.newsletterCreate("My Channel", "Channel description");
|
|
434
|
+
## ButtonV2
|
|
1295
435
|
|
|
1296
|
-
|
|
1297
|
-
await sock
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
// React to a newsletter message
|
|
1303
|
-
await sock.newsletterReactMessage("123456789@newsletter", serverId, "π");
|
|
1304
|
-
|
|
1305
|
-
// Fetch recent newsletter messages
|
|
1306
|
-
const msgs = await sock.newsletterFetchMessages("123456789@newsletter", 50, 0, 0);
|
|
1307
|
-
|
|
1308
|
-
// Fetch newsletter metadata
|
|
1309
|
-
const meta = await sock.newsletterMetadata("123456789@newsletter");
|
|
1310
|
-
|
|
1311
|
-
// Admin: Mute/unmute newsletter
|
|
1312
|
-
await sock.newsletterAdminMute("123456789@newsletter", true);
|
|
1313
|
-
|
|
1314
|
-
// Bulk follow multiple channels
|
|
1315
|
-
await sock.newsletterBulkFollow([
|
|
1316
|
-
"123456789@newsletter",
|
|
1317
|
-
"987654321@newsletter",
|
|
1318
|
-
]);
|
|
1319
|
-
|
|
1320
|
-
// Resolve newsletter URL
|
|
1321
|
-
const resolved = await sock.newsletterResolveUrl("https://whatsapp.com/channel/xxxxx");
|
|
436
|
+
``` js
|
|
437
|
+
await sock
|
|
438
|
+
.buttonV2()
|
|
439
|
+
.addButton(...)
|
|
440
|
+
.send(jid)
|
|
1322
441
|
```
|
|
1323
442
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
## π₯ Group
|
|
1327
|
-
|
|
1328
|
-
Complete group management API:
|
|
1329
|
-
|
|
1330
|
-
```js
|
|
1331
|
-
// Fetch group metadata
|
|
1332
|
-
const meta = await sock.groupMetadata("groupid@g.us");
|
|
1333
|
-
console.log(meta.subject, meta.participants);
|
|
443
|
+
The builder also supports:
|
|
1334
444
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "promote");
|
|
1345
|
-
await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "demote");
|
|
1346
|
-
|
|
1347
|
-
// Update group name / description
|
|
1348
|
-
await sock.groupUpdateSubject("groupid@g.us", "New Group Name");
|
|
1349
|
-
await sock.groupUpdateDescription("groupid@g.us", "New group description");
|
|
1350
|
-
|
|
1351
|
-
// Group settings
|
|
1352
|
-
await sock.groupSettingUpdate("groupid@g.us", "announcement"); // only admins send
|
|
1353
|
-
await sock.groupSettingUpdate("groupid@g.us", "not_announcement"); // everyone sends
|
|
1354
|
-
|
|
1355
|
-
// Toggle disappearing messages
|
|
1356
|
-
await sock.groupToggleEphemeral("groupid@g.us", 86400); // 24 hours; 0 to disable
|
|
1357
|
-
|
|
1358
|
-
// Get & reset invite link
|
|
1359
|
-
const code = await sock.groupInviteCode("groupid@g.us");
|
|
1360
|
-
await sock.groupRevokeInvite("groupid@g.us");
|
|
1361
|
-
|
|
1362
|
-
// Join via invite code
|
|
1363
|
-
await sock.groupAcceptInvite("INVITECODE");
|
|
1364
|
-
|
|
1365
|
-
// Leave a group
|
|
1366
|
-
await sock.groupLeave("groupid@g.us");
|
|
1367
|
-
|
|
1368
|
-
// Handle join requests
|
|
1369
|
-
await sock.groupRequestParticipantsList("groupid@g.us");
|
|
1370
|
-
await sock.groupRequestParticipantsUpdate("groupid@g.us", ["628xxx@s.whatsapp.net"], "approve");
|
|
1371
|
-
await sock.groupRequestParticipantsUpdate("groupid@g.us", ["628xxx@s.whatsapp.net"], "reject");
|
|
445
|
+
``` text
|
|
446
|
+
addButton()
|
|
447
|
+
addRawButton()
|
|
448
|
+
setRawThumbnail()
|
|
449
|
+
setThumbnail()
|
|
450
|
+
setMedia()
|
|
451
|
+
loadFrom()
|
|
452
|
+
build()
|
|
453
|
+
send()
|
|
1372
454
|
```
|
|
1373
455
|
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
## ποΈ Community
|
|
456
|
+
------------------------------------------------------------------------
|
|
1377
457
|
|
|
1378
|
-
|
|
1379
|
-
// Create a community
|
|
1380
|
-
const community = await sock.communityCreate("Our Community", "Community description");
|
|
458
|
+
## Carousel
|
|
1381
459
|
|
|
1382
|
-
|
|
1383
|
-
await sock.communityLinkGroup("groupid@g.us", "communityid@g.us");
|
|
460
|
+
Create multiple cards:
|
|
1384
461
|
|
|
1385
|
-
|
|
1386
|
-
await sock
|
|
462
|
+
``` js
|
|
463
|
+
await sock
|
|
464
|
+
.carousel()
|
|
465
|
+
.body('Choose a product')
|
|
466
|
+
.footer('Kyyinfinite')
|
|
1387
467
|
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
468
|
+
.card()
|
|
469
|
+
.image(image1)
|
|
470
|
+
.title('Product One')
|
|
471
|
+
.body('Product description')
|
|
472
|
+
.button('Pilih', 'product_1')
|
|
473
|
+
.url('Website', 'https://example.com')
|
|
474
|
+
.copy('Code', 'KYY-001')
|
|
475
|
+
.call('Call', '628123456789')
|
|
476
|
+
.add()
|
|
1391
477
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
478
|
+
.card()
|
|
479
|
+
.image(image2)
|
|
480
|
+
.title('Product Two')
|
|
481
|
+
.body('Another product')
|
|
482
|
+
.button('Pilih', 'product_2')
|
|
483
|
+
.add()
|
|
1395
484
|
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
## π’ Business
|
|
1399
|
-
|
|
1400
|
-
```js
|
|
1401
|
-
// Fetch product catalog
|
|
1402
|
-
const { products } = await sock.getCatalog({
|
|
1403
|
-
jid: "628xxx@s.whatsapp.net",
|
|
1404
|
-
limit: 10,
|
|
1405
|
-
});
|
|
1406
|
-
|
|
1407
|
-
// Create a product
|
|
1408
|
-
const product = await sock.productCreate({
|
|
1409
|
-
name: "Premium Package",
|
|
1410
|
-
description: "Full-featured premium plan",
|
|
1411
|
-
price: 150000,
|
|
1412
|
-
currency: "IDR",
|
|
1413
|
-
originCountryCode: "ID",
|
|
1414
|
-
isHidden: false,
|
|
1415
|
-
images: [mediaUpload],
|
|
1416
|
-
});
|
|
1417
|
-
|
|
1418
|
-
// Update a product
|
|
1419
|
-
await sock.productUpdate(productId, {
|
|
1420
|
-
name: "Premium Package Pro",
|
|
1421
|
-
price: 200000,
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
|
-
// Delete products
|
|
1425
|
-
await sock.productDelete([productId]);
|
|
1426
|
-
|
|
1427
|
-
// Update business profile
|
|
1428
|
-
await sock.updateBusinessProfile({
|
|
1429
|
-
address: "Jakarta, Indonesia",
|
|
1430
|
-
websites: ["https://example.com"],
|
|
1431
|
-
email: "hello@example.com",
|
|
1432
|
-
category: "Technology",
|
|
1433
|
-
description: "WhatsApp bot services",
|
|
1434
|
-
});
|
|
1435
|
-
|
|
1436
|
-
// Fetch business profile
|
|
1437
|
-
const profile = await sock.getBusinessProfile("628xxx@s.whatsapp.net");
|
|
1438
|
-
console.log(profile);
|
|
485
|
+
.send(jid)
|
|
1439
486
|
```
|
|
1440
487
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
## π€ Profile
|
|
1444
|
-
|
|
1445
|
-
```js
|
|
1446
|
-
// Update profile picture
|
|
1447
|
-
await sock.updateProfilePicture(jid, {
|
|
1448
|
-
url: "./avatar.jpg",
|
|
1449
|
-
});
|
|
488
|
+
Carousel methods:
|
|
1450
489
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
490
|
+
``` text
|
|
491
|
+
card()
|
|
492
|
+
addCard()
|
|
493
|
+
cards()
|
|
494
|
+
clear()
|
|
495
|
+
title()
|
|
496
|
+
subtitle()
|
|
497
|
+
body()
|
|
498
|
+
text()
|
|
499
|
+
footer()
|
|
500
|
+
context()
|
|
501
|
+
payload()
|
|
502
|
+
loadFrom()
|
|
503
|
+
build()
|
|
504
|
+
send()
|
|
1464
505
|
```
|
|
1465
506
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
## π¬ Chat
|
|
1469
|
-
|
|
1470
|
-
```js
|
|
1471
|
-
// Mark messages as read
|
|
1472
|
-
await sock.readMessages([msg.key]);
|
|
1473
|
-
|
|
1474
|
-
// Star / unstar messages
|
|
1475
|
-
await sock.star(jid, [{ id: msgId, fromMe: true }], true); // star
|
|
1476
|
-
await sock.star(jid, [{ id: msgId, fromMe: true }], false); // unstar
|
|
507
|
+
Card methods:
|
|
1477
508
|
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
)
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
509
|
+
``` text
|
|
510
|
+
title()
|
|
511
|
+
body()
|
|
512
|
+
text()
|
|
513
|
+
footer()
|
|
514
|
+
image()
|
|
515
|
+
video()
|
|
516
|
+
media()
|
|
517
|
+
button()
|
|
518
|
+
reply()
|
|
519
|
+
quickReply()
|
|
520
|
+
url()
|
|
521
|
+
copy()
|
|
522
|
+
coppy()
|
|
523
|
+
call()
|
|
524
|
+
buttons()
|
|
525
|
+
rawButton()
|
|
526
|
+
context()
|
|
527
|
+
payload()
|
|
528
|
+
build()
|
|
529
|
+
add()
|
|
530
|
+
end()
|
|
1499
531
|
```
|
|
1500
532
|
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
## π Privacy
|
|
1504
|
-
|
|
1505
|
-
```js
|
|
1506
|
-
// Last seen visibility
|
|
1507
|
-
await sock.updateLastSeenPrivacy("all"); // 'all' | 'contacts' | 'nobody'
|
|
1508
|
-
|
|
1509
|
-
// Online status visibility
|
|
1510
|
-
await sock.updateOnlinePrivacy("all"); // 'all' | 'match_last_seen'
|
|
1511
|
-
|
|
1512
|
-
// Profile picture visibility
|
|
1513
|
-
await sock.updateProfilePicturePrivacy("contacts"); // 'all' | 'contacts' | 'nobody'
|
|
533
|
+
------------------------------------------------------------------------
|
|
1514
534
|
|
|
1515
|
-
|
|
1516
|
-
await sock.updateReadReceiptsPrivacy("all"); // 'all' | 'none'
|
|
535
|
+
## Rich Messages
|
|
1517
536
|
|
|
1518
|
-
|
|
1519
|
-
await sock.updateGroupsAddPrivacy("all"); // 'all' | 'contacts' | 'contact_blacklist'
|
|
537
|
+
The advanced rich-message builder is available through:
|
|
1520
538
|
|
|
1521
|
-
|
|
1522
|
-
await sock
|
|
539
|
+
``` js
|
|
540
|
+
await sock
|
|
541
|
+
.ai()
|
|
542
|
+
.title('Example')
|
|
543
|
+
.text('Rich message')
|
|
544
|
+
.code('console.log("Hello")')
|
|
545
|
+
.send(jid)
|
|
1523
546
|
```
|
|
1524
547
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
## π‘ Events
|
|
1528
|
-
|
|
1529
|
-
Listen to all socket events via `sock.ev.on(...)`:
|
|
1530
|
-
|
|
1531
|
-
```js
|
|
1532
|
-
// Connection state changes (open, close, connecting)
|
|
1533
|
-
sock.ev.on("connection.update", ({ connection, lastDisconnect, qr, isNewLogin }) => {});
|
|
1534
|
-
|
|
1535
|
-
// Credentials updated β always save
|
|
1536
|
-
sock.ev.on("creds.update", (update) => {});
|
|
1537
|
-
|
|
1538
|
-
// New / updated messages
|
|
1539
|
-
sock.ev.on("messages.upsert", ({ messages, type }) => {});
|
|
548
|
+
The rich builder supports composition features such as:
|
|
1540
549
|
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
550
|
+
``` text
|
|
551
|
+
text
|
|
552
|
+
FOA text
|
|
553
|
+
code
|
|
554
|
+
table
|
|
555
|
+
source
|
|
556
|
+
reels
|
|
557
|
+
image
|
|
558
|
+
video
|
|
559
|
+
product
|
|
560
|
+
post
|
|
561
|
+
metadata
|
|
562
|
+
tip
|
|
563
|
+
HTML
|
|
564
|
+
widget
|
|
565
|
+
footer action
|
|
566
|
+
suggestion
|
|
567
|
+
section
|
|
568
|
+
submessage
|
|
569
|
+
```
|
|
1558
570
|
|
|
1559
|
-
|
|
1560
|
-
sock.ev.on("chats.upsert", (chats) => {});
|
|
571
|
+
It also provides message/node management:
|
|
1561
572
|
|
|
1562
|
-
|
|
1563
|
-
|
|
573
|
+
``` text
|
|
574
|
+
delete()
|
|
575
|
+
assignId()
|
|
576
|
+
hasId()
|
|
577
|
+
getIds()
|
|
578
|
+
peek()
|
|
579
|
+
loadFrom()
|
|
580
|
+
build()
|
|
581
|
+
buildEdit()
|
|
582
|
+
send()
|
|
583
|
+
sendEdit()
|
|
584
|
+
```
|
|
1564
585
|
|
|
1565
|
-
|
|
1566
|
-
sock.ev.on("chats.delete", (ids) => {});
|
|
586
|
+
------------------------------------------------------------------------
|
|
1567
587
|
|
|
1568
|
-
|
|
1569
|
-
sock.ev.on("contacts.upsert", (contacts) => {});
|
|
1570
|
-
sock.ev.on("contacts.update", (contacts) => {});
|
|
588
|
+
## FOAD
|
|
1571
589
|
|
|
1572
|
-
|
|
1573
|
-
sock
|
|
590
|
+
``` js
|
|
591
|
+
await sock
|
|
592
|
+
.foad()
|
|
593
|
+
.addTitle('Example')
|
|
594
|
+
.addHtml('<p>Hello</p>')
|
|
595
|
+
.addTab(...)
|
|
596
|
+
.send(jid)
|
|
597
|
+
```
|
|
1574
598
|
|
|
1575
|
-
|
|
1576
|
-
sock.ev.on("newsletter.update", (updates) => {});
|
|
1577
|
-
sock.ev.on("newsletter.follow", (jid) => {});
|
|
599
|
+
Available operations include:
|
|
1578
600
|
|
|
1579
|
-
|
|
1580
|
-
|
|
601
|
+
``` text
|
|
602
|
+
setResponseId()
|
|
603
|
+
refreshResponseId()
|
|
604
|
+
setBotResponseId()
|
|
605
|
+
refreshBotResponseId()
|
|
606
|
+
addTitle()
|
|
607
|
+
setPreviewTitle()
|
|
608
|
+
addHtml()
|
|
609
|
+
addTab()
|
|
610
|
+
clearTabs()
|
|
611
|
+
buildResponse()
|
|
612
|
+
build()
|
|
613
|
+
send()
|
|
614
|
+
sendEdit()
|
|
615
|
+
```
|
|
1581
616
|
|
|
1582
|
-
|
|
1583
|
-
sock.ev.on("messaging-history.set", ({ chats, contacts, messages, isLatest }) => {});
|
|
617
|
+
------------------------------------------------------------------------
|
|
1584
618
|
|
|
1585
|
-
|
|
1586
|
-
sock.ev.on("blocklist.update", ({ blocklist, type }) => {});
|
|
1587
|
-
```
|
|
619
|
+
### FOAD2
|
|
1588
620
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
All named exports available from `@kyyinfinite/baileys`:
|
|
1594
|
-
|
|
1595
|
-
```js
|
|
1596
|
-
import {
|
|
1597
|
-
//auth
|
|
1598
|
-
useMultiFileAuthState,
|
|
1599
|
-
makeCacheableSignalKeyStore,
|
|
1600
|
-
initAuthCreds,
|
|
1601
|
-
BufferJSON,
|
|
1602
|
-
fetchLatestBaileysVersion,
|
|
1603
|
-
|
|
1604
|
-
//rich message
|
|
1605
|
-
generateTableContent,
|
|
1606
|
-
generateTableContentV2,
|
|
1607
|
-
generateListContent,
|
|
1608
|
-
generateCodeBlockContent,
|
|
1609
|
-
generateCodeBlockContentV2,
|
|
1610
|
-
generateLinkContent,
|
|
1611
|
-
generateLinkContentV2,
|
|
1612
|
-
generateRichMessageContent,
|
|
1613
|
-
generateLatexContent,
|
|
1614
|
-
generateUnifiedResponseContent,
|
|
1615
|
-
captureUnifiedResponse,
|
|
1616
|
-
|
|
1617
|
-
buildRichContextInfo,
|
|
1618
|
-
buildBotForwardedMessage,
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
tokenizeCode,
|
|
1622
|
-
tokenizeCodeV2,
|
|
1623
|
-
CodeHighlightType,
|
|
1624
|
-
RichSubMessageType,
|
|
1625
|
-
|
|
1626
|
-
//jid utils
|
|
1627
|
-
jidEncode,
|
|
1628
|
-
jidDecode,
|
|
1629
|
-
jidNormalizedUser,
|
|
1630
|
-
areJidsSameUser,
|
|
1631
|
-
isJidGroup,
|
|
1632
|
-
isJidNewsletter,
|
|
1633
|
-
isLidUser,
|
|
1634
|
-
isPnUser,
|
|
1635
|
-
isJidBot,
|
|
1636
|
-
|
|
1637
|
-
//consecution helper
|
|
1638
|
-
DisconnectReason,
|
|
1639
|
-
Browsers,
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
} from "@kyyinfinite/baileys";
|
|
621
|
+
``` js
|
|
622
|
+
await sock
|
|
623
|
+
.foad2()
|
|
624
|
+
...
|
|
1643
625
|
```
|
|
1644
626
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
## π API Reference
|
|
1648
|
-
|
|
1649
|
-
### Socket Constructor Options
|
|
1650
|
-
|
|
1651
|
-
| Option | Type | Default | Description |
|
|
1652
|
-
|---|---|---|---|
|
|
1653
|
-
| `auth` | `AuthenticationState` | β | Auth state from `useMultiFileAuthState` |
|
|
1654
|
-
| `logger` | `Logger` | pino default | Logger instance (use `pino({ level: "silent" })`) |
|
|
1655
|
-
| `browser` | `WABrowserDescription` | β | Browser descriptor e.g. `Browsers.ubuntu("Chrome")` |
|
|
1656
|
-
| `version` | `WAVersion` | Latest | WhatsApp Web version tuple |
|
|
1657
|
-
| `connectTimeoutMs` | `number` | `20000` | Connection timeout in milliseconds |
|
|
1658
|
-
| `defaultQueryTimeoutMs` | `number` | `60000` | Default IQ query timeout |
|
|
1659
|
-
| `retryRequestDelayMs` | `number` | `250` | Delay between retries |
|
|
1660
|
-
| `maxMsgRetryCount` | `number` | `5` | Max message retry attempts |
|
|
1661
|
-
| `syncFullHistory` | `boolean` | `false` | Whether to sync full message history |
|
|
1662
|
-
| `enableAutoSessionRecreation` | `boolean` | `true` | Auto recreate session on failure |
|
|
1663
|
-
| `generateHighQualityLinkPreview` | `boolean` | `false` | Generate HQ link previews |
|
|
1664
|
-
| `qrTimeout` | `number` | `60000` | QR code expiry timeout in ms |
|
|
1665
|
-
|
|
1666
|
-
---
|
|
1667
|
-
|
|
1668
|
-
### Message Methods
|
|
1669
|
-
|
|
1670
|
-
| Method | Description | Returns |
|
|
1671
|
-
|---|---|---|
|
|
1672
|
-
| `sock.sendMessage(jid, content, opts?)` | Send any message type | `Promise<WAProto.WebMessageInfo>` |
|
|
1673
|
-
| `sock.sendTable(jid, title, headers, rows, quoted?, opts?)` | Send a styled table | `Promise<void>` |
|
|
1674
|
-
| `sock.sendTableV2(jid, title, headers, rows, quoted?, opts?)` | Send a V2 unified table | `Promise<void>` |
|
|
1675
|
-
| `sock.sendList(jid, title, rows, quoted?, opts?)` | Send a styled list | `Promise<void>` |
|
|
1676
|
-
| `sock.sendCodeBlock(jid, code, quoted?, opts?)` | Send V1 code block | `Promise<void>` |
|
|
1677
|
-
| `sock.sendCodeBlockV2(jid, code, quoted?, opts?)` | Send V2 unified code block | `Promise<void>` |
|
|
1678
|
-
| `sock.sendLink(jid, text, urls, quoted?, opts?)` | Send inline link message | `Promise<void>` |
|
|
1679
|
-
| `sock.sendLinkV2(jid, text, links, quoted?, opts?)` | Send V2 search-style links | `Promise<void>` |
|
|
1680
|
-
| `sock.sendUnifiedResponse(jid, text, quoted?, opts?)` | Send unified AI response | `Promise<void>` |
|
|
1681
|
-
|
|
1682
|
-
---
|
|
1683
|
-
|
|
1684
|
-
### Connection Methods
|
|
1685
|
-
|
|
1686
|
-
| Method | Description | Returns |
|
|
1687
|
-
|---|---|---|
|
|
1688
|
-
| `sock.requestPairingCode(phoneNumber, code?)` | Request or set pairing code | `Promise<string>` |
|
|
1689
|
-
| `sock.logout()` | Log out and invalidate session | `Promise<void>` |
|
|
1690
|
-
| `sock.end(error?)` | Close the socket connection | `void` |
|
|
1691
|
-
| `sock.waitForSocketOpen()` | Wait until socket is open | `Promise<void>` |
|
|
1692
|
-
| `sock.sendPresenceUpdate(presence, jid?)` | Set online/typing/recording status | `Promise<void>` |
|
|
1693
|
-
|
|
1694
|
-
---
|
|
1695
|
-
|
|
1696
|
-
### Group Methods
|
|
1697
|
-
|
|
1698
|
-
| Method | Description | Returns |
|
|
1699
|
-
|---|---|---|
|
|
1700
|
-
| `sock.groupMetadata(jid)` | Get group info | `Promise<GroupMetadata>` |
|
|
1701
|
-
| `sock.groupCreate(subject, participants)` | Create a new group | `Promise<GroupMetadata>` |
|
|
1702
|
-
| `sock.groupParticipantsUpdate(jid, participants, action)` | Add/remove/promote/demote | `Promise<ParticipantUpdate[]>` |
|
|
1703
|
-
| `sock.groupUpdateSubject(jid, subject)` | Change group name | `Promise<void>` |
|
|
1704
|
-
| `sock.groupUpdateDescription(jid, description)` | Change group description | `Promise<void>` |
|
|
1705
|
-
| `sock.groupSettingUpdate(jid, setting)` | Update group settings | `Promise<void>` |
|
|
1706
|
-
| `sock.groupToggleEphemeral(jid, expiration)` | Toggle disappearing messages | `Promise<void>` |
|
|
1707
|
-
| `sock.groupInviteCode(jid)` | Get invite link code | `Promise<string>` |
|
|
1708
|
-
| `sock.groupRevokeInvite(jid)` | Reset invite link | `Promise<string>` |
|
|
1709
|
-
| `sock.groupAcceptInvite(code)` | Join via invite code | `Promise<string>` |
|
|
1710
|
-
| `sock.groupLeave(jid)` | Leave a group | `Promise<void>` |
|
|
1711
|
-
|
|
1712
|
-
---
|
|
1713
|
-
|
|
1714
|
-
### Newsletter Methods
|
|
1715
|
-
|
|
1716
|
-
| Method | Description | Returns |
|
|
1717
|
-
|---|---|---|
|
|
1718
|
-
| `sock.newsletterFollow(jid)` | Follow a newsletter | `Promise<void>` |
|
|
1719
|
-
| `sock.newsletterUnfollow(jid)` | Unfollow a newsletter | `Promise<void>` |
|
|
1720
|
-
| `sock.newsletterCreate(name, desc)` | Create newsletter | `Promise<NewsletterMetadata>` |
|
|
1721
|
-
| `sock.newsletterUpdate(jid, metadata)` | Update newsletter info | `Promise<void>` |
|
|
1722
|
-
| `sock.newsletterReactMessage(jid, serverId, emoji)` | React to newsletter message | `Promise<void>` |
|
|
1723
|
-
| `sock.newsletterFetchMessages(jid, count, before, after)` | Fetch newsletter messages | `Promise<NewsletterMessage[]>` |
|
|
1724
|
-
| `sock.newsletterBulkFollow(jids)` | Follow multiple channels | `Promise<void>` |
|
|
1725
|
-
| `sock.newsletterMetadata(jid)` | Fetch channel metadata | `Promise<NewsletterMetadata>` |
|
|
1726
|
-
|
|
1727
|
-
---
|
|
1728
|
-
|
|
1729
|
-
## β FAQ
|
|
1730
|
-
|
|
1731
|
-
<details>
|
|
1732
|
-
<summary><strong>Why is @kyyinfinite/baileys ESM-only?</strong></summary>
|
|
1733
|
-
|
|
1734
|
-
ESM (ECMAScript Modules) is the modern JavaScript standard. It enables tree-shaking, top-level `await`, better static analysis, and aligns with the Node.js ecosystem roadmap. CommonJS support is intentionally dropped to keep the codebase clean and forward-compatible.
|
|
1735
|
-
|
|
1736
|
-
If your project is still CommonJS, wrap the import dynamically:
|
|
1737
|
-
|
|
1738
|
-
```js
|
|
1739
|
-
const { default: makeWASocket } = await import("@kyyinfinite/baileys");
|
|
1740
|
-
```
|
|
627
|
+
FOAD2 is exposed as a separate builder for its own response/composition
|
|
628
|
+
workflow.
|
|
1741
629
|
|
|
1742
|
-
|
|
630
|
+
------------------------------------------------------------------------
|
|
1743
631
|
|
|
1744
|
-
|
|
632
|
+
## createKyyinfinite
|
|
1745
633
|
|
|
1746
|
-
|
|
1747
|
-
<summary><strong>How do I reconnect automatically?</strong></summary>
|
|
634
|
+
If you do not want to augment the socket directly:
|
|
1748
635
|
|
|
1749
|
-
|
|
636
|
+
``` js
|
|
637
|
+
const api = createKyyinfinite(sock)
|
|
1750
638
|
|
|
1751
|
-
|
|
1752
|
-
sock.ev.on("connection.update", ({ connection, lastDisconnect }) => {
|
|
1753
|
-
if (connection === "close") {
|
|
1754
|
-
const code = lastDisconnect?.error?.output?.statusCode;
|
|
1755
|
-
if (code !== DisconnectReason.loggedOut) startBot();
|
|
1756
|
-
}
|
|
1757
|
-
});
|
|
639
|
+
await api.text('Hello').send(jid)
|
|
1758
640
|
```
|
|
1759
641
|
|
|
1760
|
-
|
|
642
|
+
This creates a facade without replacing the socket.
|
|
1761
643
|
|
|
1762
|
-
|
|
644
|
+
------------------------------------------------------------------------
|
|
1763
645
|
|
|
1764
|
-
|
|
1765
|
-
<summary><strong>How do I use pairing code instead of QR?</strong></summary>
|
|
646
|
+
## attachKyyinfinite
|
|
1766
647
|
|
|
1767
|
-
|
|
1768
|
-
Phone number must include the country code without `+` (e.g. `6281234567890` for Indonesia).
|
|
648
|
+
For direct socket helpers:
|
|
1769
649
|
|
|
1770
|
-
|
|
650
|
+
``` js
|
|
651
|
+
attachKyyinfinite(sock)
|
|
1771
652
|
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
<details>
|
|
1775
|
-
<summary><strong>How do I persist authentication between restarts?</strong></summary>
|
|
1776
|
-
|
|
1777
|
-
Use `useMultiFileAuthState("./session")` and save on every `creds.update` event:
|
|
1778
|
-
|
|
1779
|
-
```js
|
|
1780
|
-
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
1781
|
-
sock.ev.on("creds.update", saveCreds);
|
|
653
|
+
await sock.text('Hello').send(jid)
|
|
1782
654
|
```
|
|
1783
655
|
|
|
1784
|
-
|
|
656
|
+
The augmentation is additive. Existing socket methods are not
|
|
657
|
+
intentionally replaced when their names already exist.
|
|
1785
658
|
|
|
1786
|
-
|
|
659
|
+
------------------------------------------------------------------------
|
|
1787
660
|
|
|
1788
|
-
|
|
1789
|
-
<summary><strong>How do I deploy to a VPS or cloud?</strong></summary>
|
|
661
|
+
## API Overview
|
|
1790
662
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
663
|
+
``` text
|
|
664
|
+
Messaging
|
|
665
|
+
βββ text()
|
|
666
|
+
βββ send()
|
|
667
|
+
βββ quoted()
|
|
668
|
+
βββ reply()
|
|
669
|
+
βββ wrapMessage()
|
|
670
|
+
βββ parseMessage()
|
|
671
|
+
βββ message actions
|
|
1795
672
|
|
|
1796
|
-
|
|
1797
|
-
|
|
673
|
+
Media
|
|
674
|
+
βββ media()
|
|
675
|
+
βββ image()
|
|
676
|
+
βββ video()
|
|
677
|
+
βββ audio()
|
|
678
|
+
βββ voice()
|
|
679
|
+
βββ document()
|
|
680
|
+
βββ sticker()
|
|
681
|
+
βββ ptv()
|
|
682
|
+
βββ gif()
|
|
1798
683
|
|
|
1799
|
-
|
|
684
|
+
JID
|
|
685
|
+
βββ jid()
|
|
686
|
+
βββ parseJid()
|
|
687
|
+
βββ jidUser()
|
|
688
|
+
βββ jidServer()
|
|
689
|
+
βββ jidDevice()
|
|
690
|
+
βββ makeJid()
|
|
691
|
+
βββ isGroup()
|
|
692
|
+
βββ isPrivate()
|
|
693
|
+
βββ isBroadcast()
|
|
694
|
+
βββ isStatus()
|
|
695
|
+
βββ isNewsletter()
|
|
696
|
+
βββ isLid()
|
|
1800
697
|
|
|
1801
|
-
|
|
1802
|
-
|
|
698
|
+
Interactive
|
|
699
|
+
βββ button()
|
|
700
|
+
βββ buttonV2()
|
|
701
|
+
βββ carousel()
|
|
1803
702
|
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
const session2 = await useMultiFileAuthState("./sessions/bot2");
|
|
703
|
+
Advanced
|
|
704
|
+
βββ ai()
|
|
705
|
+
βββ foad()
|
|
706
|
+
βββ foad2()
|
|
1809
707
|
```
|
|
1810
708
|
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
</details>
|
|
709
|
+
------------------------------------------------------------------------
|
|
1814
710
|
|
|
1815
|
-
|
|
1816
|
-
<summary><strong>Interactive messages are not rendering. What's wrong?</strong></summary>
|
|
711
|
+
## Design Goals
|
|
1817
712
|
|
|
1818
|
-
|
|
713
|
+
The API is built around a few principles:
|
|
1819
714
|
|
|
1820
|
-
|
|
715
|
+
- short syntax for common operations;
|
|
716
|
+
- chainable builders;
|
|
717
|
+
- reusable message utilities;
|
|
718
|
+
- simple JID handling;
|
|
719
|
+
- flexible media input;
|
|
720
|
+
- advanced builders remain available;
|
|
721
|
+
- existing low-level access stays usable;
|
|
722
|
+
- no duplicate connection layer;
|
|
723
|
+
- builders keep isolated state.
|
|
1821
724
|
|
|
1822
|
-
|
|
1823
|
-
<summary><strong>What is the difference from official Baileys?</strong></summary>
|
|
725
|
+
The main idea is:
|
|
1824
726
|
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
| Interactive messages | β
Native structures | β
Plus fluent builders |
|
|
1830
|
-
| Carousel messages | β
Native `carouselMessage` structures | β
Plus nested carousel builder |
|
|
1831
|
-
| Rich responses | β
Native rich-response structures | β
Plus convenience helpers |
|
|
1832
|
-
| Media messages | β
| β
Plus fluent media builders |
|
|
1833
|
-
| Newsletter / Group / Business APIs | β
| β
Native API preserved |
|
|
1834
|
-
| Simple fluent API | β | β
`text()`, `image()`, `button()`, `carousel()`, etc. |
|
|
1835
|
-
| Raw escape hatch | β
Native socket / proto APIs | β
`api.raw` + native socket |
|
|
1836
|
-
|
|
1837
|
-
</details>
|
|
727
|
+
``` text
|
|
728
|
+
Simple when you need it.
|
|
729
|
+
Advanced when you want it.
|
|
730
|
+
```
|
|
1838
731
|
|
|
1839
|
-
|
|
732
|
+
------------------------------------------------------------------------
|
|
1840
733
|
|
|
1841
|
-
|
|
1842
|
-
> Use `browser: Browsers.ubuntu("Chrome")` for QR login and `Browsers.windows("Chrome")` for pairing code β this can affect compatibility with certain WhatsApp features.
|
|
734
|
+
## TypeScript
|
|
1843
735
|
|
|
1844
|
-
|
|
1845
|
-
> Always call `sock.ev.on("creds.update", saveCreds)` β missing this will cause your session to expire on every restart.
|
|
736
|
+
Type declarations are included with the package.
|
|
1846
737
|
|
|
1847
|
-
|
|
1848
|
-
|
|
738
|
+
``` ts
|
|
739
|
+
import { attachKyyinfinite } from '@kyyinfinite/baileys'
|
|
740
|
+
```
|
|
1849
741
|
|
|
1850
|
-
|
|
1851
|
-
|
|
742
|
+
The Simple API declarations cover the builder and convenience APIs
|
|
743
|
+
exposed by the package.
|
|
1852
744
|
|
|
1853
|
-
|
|
1854
|
-
> This library is intended for **educational and personal automation** purposes. Ensure your usage complies with [WhatsApp's Terms of Service](https://www.whatsapp.com/legal/terms-of-service). Mass messaging, spam, or unauthorized data collection may result in permanent account bans.
|
|
745
|
+
------------------------------------------------------------------------
|
|
1855
746
|
|
|
1856
|
-
|
|
747
|
+
## Version
|
|
1857
748
|
|
|
1858
|
-
|
|
749
|
+
Current release:
|
|
1859
750
|
|
|
751
|
+
``` text
|
|
752
|
+
@kyyinfinite/baileys 2.1.0
|
|
1860
753
|
```
|
|
1861
|
-
MIT License
|
|
1862
|
-
|
|
1863
|
-
Copyright (c) 2026 kyyinfinite
|
|
1864
754
|
|
|
1865
|
-
|
|
1866
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
1867
|
-
in the Software without restriction, including without limitation the rights
|
|
1868
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1869
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
1870
|
-
furnished to do so, subject to the following conditions:
|
|
755
|
+
### What's new in 2.1.0
|
|
1871
756
|
|
|
1872
|
-
|
|
1873
|
-
|
|
757
|
+
``` text
|
|
758
|
+
+ Unified send()
|
|
759
|
+
+ Quoted/reply helpers
|
|
760
|
+
+ KyyMessage
|
|
761
|
+
+ Message parser
|
|
762
|
+
+ Universal media builder
|
|
763
|
+
+ JID parser and utilities
|
|
764
|
+
+ JID classifiers
|
|
765
|
+
+ makeJid()
|
|
766
|
+
+ Automatic mention handling
|
|
767
|
+
+ Additional message shortcuts
|
|
768
|
+
+ Expanded Simple API declarations
|
|
1874
769
|
```
|
|
1875
770
|
|
|
1876
|
-
|
|
771
|
+
------------------------------------------------------------------------
|
|
1877
772
|
|
|
1878
|
-
|
|
773
|
+
## Roadmap
|
|
1879
774
|
|
|
1880
|
-
|
|
1881
|
-
[](https://github.com/kyyinfinite/baileys)
|
|
1882
|
-
[](https://github.com/kyyinfinite/baileys/stargazers)
|
|
775
|
+
Planned improvements:
|
|
1883
776
|
|
|
1884
|
-
|
|
777
|
+
- Native Baileys API compatibility
|
|
778
|
+
- More message shortcuts
|
|
779
|
+
- More media utilities
|
|
780
|
+
- Additional TypeScript improvements
|
|
781
|
+
- Expanded integration tests
|
|
782
|
+
- API documentation expansion
|
|
1885
783
|
|
|
1886
|
-
|
|
784
|
+
------------------------------------------------------------------------
|
|
1887
785
|
|
|
1888
|
-
|
|
786
|
+
## Repository
|
|
1889
787
|
|
|
1890
|
-
|
|
788
|
+
ξurlξGitHub Repositoryξhttps://github.com/kyyinfinite/baileysξ
|
|
1891
789
|
|
|
1892
|
-
|
|
790
|
+
## License
|
|
1893
791
|
|
|
1894
|
-
|
|
792
|
+
MIT
|