@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/README.md CHANGED
@@ -1,453 +1,57 @@
1
- <div align="center">
2
-
3
- <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&weight=700&size=15&duration=2500&pause=800&color=00B4D8&center=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
- [![npm version](https://img.shields.io/badge/npm-v2.0.0-CB3837?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@kyyinfinite/baileys)
8
- [![Baileys base](https://img.shields.io/badge/Baileys-7.0.0--rc14-00B4D8?style=for-the-badge)](https://github.com/WhiskeySockets/Baileys/releases/tag/v7.0.0-rc14)
9
- [![npm downloads](https://img.shields.io/badge/downloads-monthly-00B4D8?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@kyyinfinite/baileys)
10
- [![License](https://img.shields.io/badge/license-MIT-green?style=for-the-badge)](LICENSE)
11
- [![Node.js](https://img.shields.io/badge/node-%3E%3D20.0.0-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org)
12
- [![ESM Only](https://img.shields.io/badge/ESM-only-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
13
- [![TypeScript](https://img.shields.io/badge/TypeScript-ready-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
14
- [![GitHub](https://img.shields.io/badge/GitHub-kyyinfinite-181717?style=for-the-badge&logo=github&logoColor=white)](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
- If you prefer pairing code authentication over QR:
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
- ```js
299
- import makeWASocket, {
300
- useMultiFileAuthState,
301
- Browsers,
302
- } from "@kyyinfinite/baileys";
303
- import pino from "pino";
7
+ ## Installation
304
8
 
305
- const logger = pino({ level: "silent" });
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
- > [!TIP]
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
- After attaching the wrapper, the socket can use both the original Baileys API and the simpler fluent API.
18
+ const sock = makeWASocket(config)
400
19
 
401
- ### Text
20
+ attachKyyinfinite(sock)
402
21
 
403
- ```js
404
- await sock.text("Hello")
405
- .send(jid);
22
+ await sock
23
+ .text('Hello')
24
+ .send(jid)
406
25
  ```
407
26
 
408
- ### Media
27
+ The API is designed to keep common operations short while still allowing
28
+ advanced message builders when needed.
409
29
 
410
- ```js
411
- await sock.image({ url: "./image.jpg" })
412
- .caption("Hello")
413
- .send(jid);
30
+ ------------------------------------------------------------------------
414
31
 
415
- await sock.video({ url: "./video.mp4" })
416
- .caption("Video")
417
- .send(jid);
32
+ # API
418
33
 
419
- await sock.audio({ url: "./audio.mp3" })
420
- .send(jid);
34
+ ## Text
421
35
 
422
- await sock.voice({ url: "./voice.ogg" })
423
- .send(jid);
424
-
425
- await sock.sticker({ url: "./sticker.webp" })
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
- ### Message Builder
42
+ Additional text options:
440
43
 
441
- ```js
442
- await sock.text("Hello")
443
- .footer("Powered by @kyyinfinite/baileys")
444
- .mentions(["6281234567890@s.whatsapp.net"])
445
- .send(jid);
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
- Supported fluent options include:
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
- ### Buttons
66
+ ------------------------------------------------------------------------
463
67
 
464
- ```js
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
- CTA helpers are also available:
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
- The copy helper also supports the shorthand typo-compatible alias:
72
+ ``` js
73
+ await sock.image('./image.jpg')
74
+ .caption('Image')
75
+ .send(jid)
487
76
 
488
- ```js
489
- .copy("Copy", "KYY-001")
490
- .coppy("Copy", "KYY-001")
491
- ```
77
+ await sock.video('./video.mp4')
78
+ .caption('Video')
79
+ .send(jid)
492
80
 
493
- Additional button helpers:
81
+ await sock.audio('./audio.mp3')
82
+ .send(jid)
494
83
 
495
- ```text
496
- reply() / quickReply()
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
- ### ButtonV2
87
+ await sock.document('./file.pdf')
88
+ .fileName('document.pdf')
89
+ .send(jid)
510
90
 
511
- ```js
512
- await sock.buttonV2()
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
- The raw builder is still available when full low-level control is required.
95
+ Other media shortcuts:
519
96
 
520
- ### Carousel
97
+ ``` text
98
+ ptv()
99
+ gif()
100
+ ```
521
101
 
522
- The carousel API supports a nested fluent card builder:
102
+ ## Universal Media
523
103
 
524
- ```js
525
- await sock.carousel()
526
- .body("Choose a product")
527
- .footer("Kyyinfinite")
528
- .card()
529
- .image({ url: "./product-1.jpg" })
530
- .title("Product One")
531
- .body("Product description")
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
- Card helpers:
114
+ Supported types:
547
115
 
548
- ```text
549
- title()
550
- body() / text()
551
- footer()
552
- image()
553
- video()
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
- Carousel helpers:
124
+ Media builder options include:
570
125
 
571
- ```text
572
- card()
573
- addCard()
574
- cards()
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
- loadFrom()
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
- ### Generic Message Helpers
146
+ ------------------------------------------------------------------------
588
147
 
589
- ```js
590
- await sock.message({ text: "Hello" })
591
- .send(jid);
148
+ ## Unified Send
592
149
 
593
- await sock.poll(
594
- "What's your favorite language?",
595
- ["JavaScript", "TypeScript", "Python"],
596
- 1
597
- ).send(jid);
150
+ For simple messages, use:
598
151
 
599
- await sock.location({
600
- degreesLatitude: -6.2088,
601
- degreesLongitude: 106.8456,
602
- name: "Jakarta"
603
- }).send(jid);
152
+ ``` js
153
+ await sock.send(jid, 'Hello')
154
+ ```
604
155
 
605
- await sock.react(msg.key, "πŸ‘");
156
+ Object payloads are also supported:
606
157
 
607
- await sock.delete(msg.key);
158
+ ``` js
159
+ await sock.send(jid, {
160
+ text: 'Hello'
161
+ })
608
162
  ```
609
163
 
610
- Available helpers include:
164
+ Media:
611
165
 
612
- ```text
613
- message()
614
- poll()
615
- event()
616
- album()
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
- ### Non-mutating API
173
+ The unified API is intended for cases where you do not need to manually
174
+ create a builder.
634
175
 
635
- If you do not want to modify the socket object, create a separate API facade:
176
+ ------------------------------------------------------------------------
636
177
 
637
- ```js
638
- import {
639
- createKyyinfinite,
640
- } from "@kyyinfinite/baileys";
178
+ ## Quoted Messages
641
179
 
642
- const api = createKyyinfinite(sock);
180
+ Reply directly to an existing message:
643
181
 
644
- await api.text("Hello")
645
- .send(jid);
182
+ ``` js
183
+ await sock.reply(message, 'Hello')
646
184
  ```
647
185
 
648
- The facade keeps the original socket accessible through `api.raw`:
186
+ Or:
649
187
 
650
- ```js
651
- api.raw
188
+ ``` js
189
+ await sock.quoted(message, 'Hello')
652
190
  ```
653
191
 
654
- Raw wrapper classes are available through:
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
- Use the Simple API for everyday message construction while keeping the raw builders available whenever lower-level control is needed.
194
+ ``` js
195
+ const m = sock.wrapMessage(message)
667
196
 
668
- ### Native Baileys Still Works
197
+ await m.reply('Hello')
198
+ ```
669
199
 
670
- The Simple API does not replace native socket methods:
200
+ Available message actions:
671
201
 
672
- ```js
673
- await sock.sendMessage(jid, {
674
- text: "Hello from native Baileys"
675
- });
202
+ ``` text
203
+ reply()
204
+ react()
205
+ edit()
206
+ delete()
207
+ forward()
208
+ download()
209
+ ```
676
210
 
677
- await sock.sendPresenceUpdate("composing", jid);
211
+ Socket shortcuts:
678
212
 
679
- sock.ev.on("messages.upsert", ({ messages }) => {
680
- console.log(messages);
681
- });
213
+ ``` text
214
+ reply()
215
+ reactTo()
216
+ editMessage()
217
+ deleteMessage()
218
+ forwardMessage()
219
+ downloadMessage()
682
220
  ```
683
221
 
684
- Use the Simple API when you want shorter, cleaner code. Use the native API or `.raw` builders whenever you need lower-level control.
222
+ ------------------------------------------------------------------------
685
223
 
686
- ---
224
+ ## Message Parser
687
225
 
688
- ## πŸ’¬ Message Examples
226
+ Parse an incoming message into a simple object:
689
227
 
690
- ### Text
228
+ ``` js
229
+ const parsed = sock.parseMessage(message, {
230
+ prefix: '.'
231
+ })
691
232
 
692
- ```js
693
- await sock.sendMessage(jid, { text: "Hello, World! πŸ‘‹" });
233
+ console.log(parsed.text)
234
+ console.log(parsed.command)
235
+ console.log(parsed.args)
694
236
  ```
695
237
 
696
- ### Image
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
- ### Video
720
-
721
- ```js
722
- await sock.sendMessage(jid, {
723
- video: { url: "./video.mp4" },
724
- caption: "Check this out 🎬",
725
- gifPlayback: false, // set true for GIF-style playback
726
- });
727
- ```
728
-
729
- ### Audio & PTT
730
-
731
- ```js
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
- ### Sticker
255
+ Example command:
747
256
 
748
- ```js
749
- await sock.sendMessage(jid, {
750
- sticker: { url: "./sticker.webp" },
751
- });
257
+ ``` text
258
+ .menu game hard
752
259
  ```
753
260
 
754
- ### Document
261
+ can be consumed as:
755
262
 
756
- ```js
757
- await sock.sendMessage(jid, {
758
- document: { url: "./report.pdf" },
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
- ### Location
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
- ### Contact
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
- ### Poll
272
+ Text containing a WhatsApp-style number can be resolved automatically:
794
273
 
795
- ```js
796
- await sock.sendMessage(jid, {
797
- poll: {
798
- name: "What's your favorite language?",
799
- values: ["JavaScript", "TypeScript", "Python", "Go"],
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
- ### Reaction
281
+ Disable automatic mention resolution when required:
806
282
 
807
- ```js
808
- await sock.sendMessage(jid, {
809
- react: {
810
- key: msg.key, // key of the message to react to
811
- text: "πŸ‘", // use "" to remove reaction
812
- },
813
- });
283
+ ``` js
284
+ await sock.send(
285
+ jid,
286
+ 'Hello @628123456789',
287
+ {
288
+ autoMentions: false
289
+ }
290
+ )
814
291
  ```
815
292
 
816
- ### Delete & Edit
293
+ Explicit mentions can also be supplied through the builder API.
817
294
 
818
- ```js
819
- // Delete a message (for everyone)
820
- await sock.sendMessage(jid, { delete: msg.key });
295
+ ------------------------------------------------------------------------
821
296
 
822
- // Edit a sent message
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
- ```js
832
- // Forward a message
833
- await sock.sendMessage(jid, { forward: msg });
299
+ Parse a JID:
834
300
 
835
- // Reply (quoted message)
836
- await sock.sendMessage(
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
- ### Mention
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
- ### Context Info
853
-
854
- ```js
855
- await sock.sendMessage(jid, {
856
- text: "Message with custom context",
857
- contextInfo: {
858
- externalAdReply: {
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
- ### CTA URL Button
900
-
901
- ```js
902
- await sock.sendMessage(jid, {
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
- ### Copy Button
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
- ### List Menu (single_select)
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
- ### Carousel
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
- const message = generateWAMessageFromContent(
1026
- jid,
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
- ### Native Interactive
1050
-
1051
- Combine multiple button types in a single message:
1052
-
1053
- ```js
1054
- await sock.sendMessage(jid, {
1055
- interactiveMessage: {
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
- ## πŸ€– AI Rich Response
349
+ ## Buttons
1087
350
 
1088
- > [!NOTE]
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
- ### sendTable()
1093
-
1094
- ```js
1095
- await sock.sendTable(
1096
- jid,
1097
- "Java vs JavaScript",
1098
- ["Feature", "Java", "JavaScript"],
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
- ### sendList()
363
+ ## Reply
1115
364
 
1116
- ```js
1117
- await sock.sendList(
1118
- jid,
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
- ### sendCodeBlock()
370
+ Aliases:
1133
371
 
1134
- V1 supports: `javascript`, `typescript`, `python`
1135
-
1136
- ```js
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
- ### sendLink()
377
+ ## URL
1150
378
 
1151
- ```js
1152
- await sock.sendLink(
1153
- jid,
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
- ### sendUnifiedResponse()
384
+ ## Copy
1166
385
 
1167
- ```js
1168
- await sock.sendUnifiedResponse(
1169
- jid,
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
- ### sendTableV2()
391
+ Both aliases are supported:
1180
392
 
1181
- ```js
1182
- await sock.sendTableV2(
1183
- jid,
1184
- "Framework Comparison",
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
- ### sendCodeBlockV2()
1202
-
1203
- V2 supports: `javascript` / `js` / `typescript` / `ts`, `python` / `py`, `go` / `golang`, `lua`, `bash` / `sh` / `shell`
399
+ ## Call
1204
400
 
1205
- ```js
1206
- await sock.sendCodeBlockV2(
1207
- jid,
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
- **All supported V2 languages:**
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
- ```js
1232
- await sock.sendLinkV2(
1233
- jid,
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
- Send multiple images and/or videos as a grouped album in a single message:
1261
-
1262
- ```js
1263
- await sock.sendMessage(jid, {
1264
- albumMessage: [
1265
- { image: { url: "./photo1.jpg" }, caption: "First photo πŸŒ…" },
1266
- { image: { url: "./photo2.jpg" }, caption: "Second photo πŸŒ„" },
1267
- { image: { url: "https://example.com/photo3.jpg" }, caption: "Remote photo πŸŒƒ" },
1268
- { video: { url: "./clip.mp4" }, caption: "Bonus clip 🎬" },
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
- > [!NOTE]
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
- // Create a new newsletter channel
1294
- await sock.newsletterCreate("My Channel", "Channel description");
434
+ ## ButtonV2
1295
435
 
1296
- // Update newsletter metadata
1297
- await sock.newsletterUpdate("123456789@newsletter", {
1298
- name: "Updated Channel Name",
1299
- description: "Updated description",
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
- // Create a new group
1336
- const group = await sock.groupCreate("My New Group", [
1337
- "628111@s.whatsapp.net",
1338
- "628222@s.whatsapp.net",
1339
- ]);
1340
-
1341
- // Add / remove / promote / demote participants
1342
- await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "add");
1343
- await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "remove");
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
- ```js
1379
- // Create a community
1380
- const community = await sock.communityCreate("Our Community", "Community description");
458
+ ## Carousel
1381
459
 
1382
- // Link an existing group to a community
1383
- await sock.communityLinkGroup("groupid@g.us", "communityid@g.us");
460
+ Create multiple cards:
1384
461
 
1385
- // Unlink a group from a community
1386
- await sock.communityUnlinkGroup("groupid@g.us", "communityid@g.us");
462
+ ``` js
463
+ await sock
464
+ .carousel()
465
+ .body('Choose a product')
466
+ .footer('Kyyinfinite')
1387
467
 
1388
- // Fetch all groups linked to a community
1389
- const linked = await sock.communityFetchLinkedGroups("communityid@g.us");
1390
- console.log(linked);
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
- // Deactivate a community
1393
- await sock.communityDeactivate("communityid@g.us");
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
- // Update display name
1452
- await sock.updateProfileName("My New Name");
1453
-
1454
- // Update status/about
1455
- await sock.updateProfileStatus("πŸ€– Powered by @kyyinfinite/baileys");
1456
-
1457
- // Fetch someone's profile picture
1458
- const ppUrl = await sock.profilePictureUrl("628xxx@s.whatsapp.net", "image");
1459
- console.log(ppUrl);
1460
-
1461
- // Fetch your own profile
1462
- const me = sock.user;
1463
- console.log(me);
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
- // Archive / unarchive chat
1479
- await sock.chatModify({ archive: true, lastMessages: [msg] }, jid);
1480
- await sock.chatModify({ archive: false, lastMessages: [msg] }, jid);
1481
-
1482
- // Mute / unmute chat
1483
- await sock.chatModify(
1484
- { mute: 8 * 60 * 60 * 1000 }, // mute for 8 hours (in ms)
1485
- jid
1486
- );
1487
- await sock.chatModify({ mute: null }, jid); // unmute
1488
-
1489
- // Pin / unpin chat
1490
- await sock.chatModify({ pin: true }, jid);
1491
- await sock.chatModify({ pin: false }, jid);
1492
-
1493
- // Delete chat
1494
- await sock.chatModify({ delete: true, lastMessages: [msg] }, jid);
1495
-
1496
- // Block / unblock a user
1497
- await sock.updateBlockStatus(jid, "block");
1498
- await sock.updateBlockStatus(jid, "unblock");
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
- // Read receipts (blue ticks)
1516
- await sock.updateReadReceiptsPrivacy("all"); // 'all' | 'none'
535
+ ## Rich Messages
1517
536
 
1518
- // Who can add you to groups
1519
- await sock.updateGroupsAddPrivacy("all"); // 'all' | 'contacts' | 'contact_blacklist'
537
+ The advanced rich-message builder is available through:
1520
538
 
1521
- // Default disappearing message timer
1522
- await sock.updateDefaultDisappearingMode(86400); // seconds; 0 to disable
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
- // Message edits / status updates
1542
- sock.ev.on("messages.update", (updates) => {});
1543
-
1544
- // Messages deleted
1545
- sock.ev.on("messages.delete", (keys) => {});
1546
-
1547
- // Reactions on messages
1548
- sock.ev.on("messages.reaction", (reactions) => {});
1549
-
1550
- // Group metadata updates (subject, description, settings)
1551
- sock.ev.on("groups.update", (updates) => {});
1552
-
1553
- // Participants added/removed/promoted/demoted
1554
- sock.ev.on("group-participants.update", ({ id, participants, action }) => {});
1555
-
1556
- // Join request received in a group
1557
- sock.ev.on("group.join-request", (update) => {});
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
- // New or updated chats
1560
- sock.ev.on("chats.upsert", (chats) => {});
571
+ It also provides message/node management:
1561
572
 
1562
- // Chat updates (archive, mute, pin, etc.)
1563
- sock.ev.on("chats.update", (updates) => {});
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
- // Chats deleted
1566
- sock.ev.on("chats.delete", (ids) => {});
586
+ ------------------------------------------------------------------------
1567
587
 
1568
- // Contacts synced or updated
1569
- sock.ev.on("contacts.upsert", (contacts) => {});
1570
- sock.ev.on("contacts.update", (contacts) => {});
588
+ ## FOAD
1571
589
 
1572
- // Incoming calls
1573
- sock.ev.on("call", (calls) => {});
590
+ ``` js
591
+ await sock
592
+ .foad()
593
+ .addTitle('Example')
594
+ .addHtml('<p>Hello</p>')
595
+ .addTab(...)
596
+ .send(jid)
597
+ ```
1574
598
 
1575
- // Newsletter events
1576
- sock.ev.on("newsletter.update", (updates) => {});
1577
- sock.ev.on("newsletter.follow", (jid) => {});
599
+ Available operations include:
1578
600
 
1579
- // Privacy/settings updates
1580
- sock.ev.on("settings.update", (settings) => {});
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
- // Message history sync (on first connect)
1583
- sock.ev.on("messaging-history.set", ({ chats, contacts, messages, isLatest }) => {});
617
+ ------------------------------------------------------------------------
1584
618
 
1585
- // Blocklist updates
1586
- sock.ev.on("blocklist.update", ({ blocklist, type }) => {});
1587
- ```
619
+ ### FOAD2
1588
620
 
1589
- ---
1590
-
1591
- ## πŸ”§ Utility Exports
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
- Or better β€” migrate your project to ESM by adding `"type": "module"` to `package.json`.
630
+ ------------------------------------------------------------------------
1743
631
 
1744
- </details>
632
+ ## createKyyinfinite
1745
633
 
1746
- <details>
1747
- <summary><strong>How do I reconnect automatically?</strong></summary>
634
+ If you do not want to augment the socket directly:
1748
635
 
1749
- Listen to `connection.update` and call your `startBot()` function again if the disconnect reason is not `loggedOut`:
636
+ ``` js
637
+ const api = createKyyinfinite(sock)
1750
638
 
1751
- ```js
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
- For production, also use PM2 or Docker restart policies.
642
+ This creates a facade without replacing the socket.
1761
643
 
1762
- </details>
644
+ ------------------------------------------------------------------------
1763
645
 
1764
- <details>
1765
- <summary><strong>How do I use pairing code instead of QR?</strong></summary>
646
+ ## attachKyyinfinite
1766
647
 
1767
- Call `sock.requestPairingCode(phoneNumber)` when the connection status is `"connecting"`.
1768
- Phone number must include the country code without `+` (e.g. `6281234567890` for Indonesia).
648
+ For direct socket helpers:
1769
649
 
1770
- See the [Pairing Code Login](#5-pairing-code-login) section for a complete example.
650
+ ``` js
651
+ attachKyyinfinite(sock)
1771
652
 
1772
- </details>
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
- For production, implement a custom auth store backed by Redis, MongoDB, or PostgreSQL instead of local files.
656
+ The augmentation is additive. Existing socket methods are not
657
+ intentionally replaced when their names already exist.
1785
658
 
1786
- </details>
659
+ ------------------------------------------------------------------------
1787
660
 
1788
- <details>
1789
- <summary><strong>How do I deploy to a VPS or cloud?</strong></summary>
661
+ ## API Overview
1790
662
 
1791
- 1. Upload your project files (without `node_modules`)
1792
- 2. Run `npm install` on the server
1793
- 3. Use PM2 to keep the bot alive: `npm install -g pm2 && pm2 start index.js --name my-bot`
1794
- 4. Enable PM2 auto-start: `pm2 startup && pm2 save`
663
+ ``` text
664
+ Messaging
665
+ β”œβ”€β”€ text()
666
+ β”œβ”€β”€ send()
667
+ β”œβ”€β”€ quoted()
668
+ β”œβ”€β”€ reply()
669
+ β”œβ”€β”€ wrapMessage()
670
+ β”œβ”€β”€ parseMessage()
671
+ └── message actions
1795
672
 
1796
- > [!TIP]
1797
- > Use `pm2 logs my-bot` to monitor your bot in production.
673
+ Media
674
+ β”œβ”€β”€ media()
675
+ β”œβ”€β”€ image()
676
+ β”œβ”€β”€ video()
677
+ β”œβ”€β”€ audio()
678
+ β”œβ”€β”€ voice()
679
+ β”œβ”€β”€ document()
680
+ β”œβ”€β”€ sticker()
681
+ β”œβ”€β”€ ptv()
682
+ └── gif()
1798
683
 
1799
- </details>
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
- <details>
1802
- <summary><strong>How do I handle multiple sessions / multi-device?</strong></summary>
698
+ Interactive
699
+ β”œβ”€β”€ button()
700
+ β”œβ”€β”€ buttonV2()
701
+ └── carousel()
1803
702
 
1804
- Create a separate auth state directory for each session:
1805
-
1806
- ```js
1807
- const session1 = await useMultiFileAuthState("./sessions/bot1");
1808
- const session2 = await useMultiFileAuthState("./sessions/bot2");
703
+ Advanced
704
+ β”œβ”€β”€ ai()
705
+ β”œβ”€β”€ foad()
706
+ └── foad2()
1809
707
  ```
1810
708
 
1811
- Then instantiate a separate `makeWASocket` for each session.
1812
-
1813
- </details>
709
+ ------------------------------------------------------------------------
1814
710
 
1815
- <details>
1816
- <summary><strong>Interactive messages are not rendering. What's wrong?</strong></summary>
711
+ ## Design Goals
1817
712
 
1818
- Interactive messages depend on the message type, current WhatsApp client behavior, and server-side availability. Rendering can differ between WhatsApp Web, Android, and iOS. Test the specific interactive structure with the account and client versions you target.
713
+ The API is built around a few principles:
1819
714
 
1820
- </details>
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
- <details>
1823
- <summary><strong>What is the difference from official Baileys?</strong></summary>
725
+ The main idea is:
1824
726
 
1825
- | Area | Baileys v7.0.0-rc14 | @kyyinfinite/baileys |
1826
- |---|---|---|
1827
- | Native socket API | βœ… | βœ… Preserved |
1828
- | ESM | βœ… | βœ… |
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
- > [!TIP]
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
- > [!IMPORTANT]
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
- > [!WARNING]
1848
- > Do **not** share your `./session` folder publicly. It contains your authentication keys and allows full access to the linked WhatsApp account.
738
+ ``` ts
739
+ import { attachKyyinfinite } from '@kyyinfinite/baileys'
740
+ ```
1849
741
 
1850
- > [!NOTE]
1851
- > `@kyyinfinite/baileys` follows the same Signal Protocol as official Baileys. End-to-end encryption is preserved for all messages.
742
+ The Simple API declarations cover the builder and convenience APIs
743
+ exposed by the package.
1852
744
 
1853
- > [!CAUTION]
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
- ## πŸ“„ License
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
- Permission is hereby granted, free of charge, to any person obtaining a copy
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
- The above copyright notice and this permission notice shall be included in all
1873
- copies or substantial portions of the Software.
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
- <div align="center">
773
+ ## Roadmap
1879
774
 
1880
- [![npm](https://img.shields.io/badge/npm-%40kyyinfinite%2Fbaileys-CB3837?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@kyyinfinite/baileys)
1881
- [![GitHub](https://img.shields.io/badge/GitHub-kyyinfinite%2Fbaileys-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/kyyinfinite/baileys)
1882
- [![Star on GitHub](https://img.shields.io/badge/⭐_Star_this_repo-yellow?style=for-the-badge)](https://github.com/kyyinfinite/baileys/stargazers)
775
+ Planned improvements:
1883
776
 
1884
- <br/>
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
- [πŸ› Report Bug](https://github.com/kyyinfinite/baileys/issues/new?template=bug_report.md) Β· [πŸ’‘ Request Feature](https://github.com/kyyinfinite/baileys/issues/new?template=feature_request.md) Β· [πŸ“¦ npm Package](https://www.npmjs.com/package/@kyyinfinite/baileys)
784
+ ------------------------------------------------------------------------
1887
785
 
1888
- <br/>
786
+ ## Repository
1889
787
 
1890
- **Β© 2026 kyyinfinite β€” `@kyyinfinite/baileys` v2.0.0 β€’ MIT License**
788
+ ξˆ€urlξˆ‚GitHub Repositoryξˆ‚https://github.com/kyyinfinite/baileys
1891
789
 
1892
- *Built on top of [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)*
790
+ ## License
1893
791
 
1894
- </div>
792
+ MIT