@kyyinfinite/baileys 1.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 +582 -1340
- package/WAProto/WAProto.proto +360 -916
- package/WAProto/fix-imports.js +22 -18
- package/WAProto/index.d.ts +14015 -0
- package/WAProto/index.js +47122 -81757
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.d.ts +15 -14
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +99 -107
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Kyyinfinite/AIRich.js +2041 -0
- package/lib/Kyyinfinite/BaseBuilder.js +64 -0
- package/lib/Kyyinfinite/Button.js +341 -0
- package/lib/Kyyinfinite/ButtonV2.js +175 -0
- package/lib/Kyyinfinite/Carousel.js +125 -0
- package/lib/Kyyinfinite/Foad.js +542 -0
- package/lib/Kyyinfinite/Foad2.js +466 -0
- package/lib/Kyyinfinite/Simple/AIBuilder.js +18 -0
- package/lib/Kyyinfinite/Simple/BuilderFactories.js +17 -0
- package/lib/Kyyinfinite/Simple/ButtonBuilder.js +107 -0
- package/lib/Kyyinfinite/Simple/CardBuilder.js +179 -0
- package/lib/Kyyinfinite/Simple/CarouselBuilder.js +97 -0
- package/lib/Kyyinfinite/Simple/FoadBuilder.js +18 -0
- package/lib/Kyyinfinite/Simple/KyyMessage.js +46 -0
- package/lib/Kyyinfinite/Simple/MediaBuilder.js +41 -0
- package/lib/Kyyinfinite/Simple/MessageBuilder.js +55 -0
- package/lib/Kyyinfinite/Simple/MessageTypesBuilder.js +3 -0
- package/lib/Kyyinfinite/Simple/SimpleBuilder.js +28 -0
- package/lib/Kyyinfinite/Simple/SimpleClient.js +120 -0
- package/lib/Kyyinfinite/Simple/TextBuilder.js +28 -0
- package/lib/Kyyinfinite/Simple/UniversalMediaBuilder.js +21 -0
- package/lib/Kyyinfinite/Simple/index.d.ts +232 -0
- package/lib/Kyyinfinite/Simple/index.js +38 -0
- 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/lib/Kyyinfinite/Toolkit.js +453 -0
- package/lib/Kyyinfinite/constants.js +1 -0
- package/lib/Kyyinfinite/errors.js +39 -0
- package/lib/Kyyinfinite/index.d.ts +2 -0
- package/lib/Kyyinfinite/index.js +2 -0
- package/lib/Kyyinfinite/wrapper.d.ts +2 -0
- package/lib/Kyyinfinite/wrapper.js +10 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -1
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -1
- package/lib/Signal/Group/sender-chain-key.js.map +1 -1
- package/lib/Signal/Group/sender-key-message.js.map +1 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -1
- package/lib/Signal/libsignal.d.ts.map +1 -1
- package/lib/Signal/libsignal.js +45 -17
- package/lib/Signal/libsignal.js.map +1 -1
- package/lib/Signal/lid-mapping.d.ts +4 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -1
- package/lib/Signal/lid-mapping.js +6 -0
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/business.d.ts +213 -532
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +358 -401
- package/lib/Socket/chats.d.ts +16 -2
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +247 -40
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +269 -641
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/groups.d.ts +13 -2
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +21 -1
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +255 -631
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +9 -10
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +23 -58
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +645 -181
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +195 -575
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +1099 -1549
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/mex.d.ts.map +1 -1
- package/lib/Socket/mex.js +2 -8
- package/lib/Socket/mex.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +11 -18
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +167 -302
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +6 -2
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +59 -25
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Auth.d.ts.map +1 -1
- package/lib/Types/Bussines.d.ts +22 -34
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Call.d.ts.map +1 -1
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Contact.d.ts +2 -0
- package/lib/Types/Contact.d.ts.map +1 -1
- package/lib/Types/Events.d.ts +20 -1
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/GroupMetadata.d.ts +4 -1
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/Message.d.ts +239 -341
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/{Newsletter.d.ts → Mex.d.ts} +11 -5
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/{Newsletter.js → Mex.js} +9 -3
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Signal.d.ts +12 -1
- package/lib/Types/Signal.d.ts.map +1 -1
- package/lib/Types/Socket.d.ts +126 -148
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/State.d.ts +58 -0
- package/lib/Types/State.d.ts.map +1 -1
- package/lib/Types/State.js +43 -0
- package/lib/Types/State.js.map +1 -1
- package/lib/Types/index.d.ts +52 -52
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js +23 -30
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts +5 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +12 -0
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts.map +1 -1
- package/lib/Utils/browser-utils.js +1 -0
- package/lib/Utils/browser-utils.js.map +1 -1
- package/lib/Utils/chat-utils.d.ts +34 -4
- package/lib/Utils/chat-utils.d.ts.map +1 -1
- package/lib/Utils/chat-utils.js +80 -20
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +35 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +12 -12
- package/lib/Utils/crypto.d.ts.map +1 -1
- package/lib/Utils/crypto.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts +18 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +34 -0
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +2 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +49 -1
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +3 -2
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +10 -1
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/history.d.ts +2 -0
- package/lib/Utils/history.d.ts.map +1 -1
- package/lib/Utils/history.js +12 -9
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/identity-change-handler.d.ts +7 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -1
- package/lib/Utils/identity-change-handler.js +1 -0
- package/lib/Utils/identity-change-handler.js.map +1 -1
- package/lib/Utils/index.d.ts +22 -25
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +2 -4
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/link-preview.js.map +1 -1
- package/lib/Utils/logger.d.ts +1 -2
- package/lib/Utils/logger.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.d.ts +5 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.js +40 -0
- package/lib/Utils/message-retry-manager.js.map +1 -1
- package/lib/Utils/messages-media.d.ts +16 -13
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +85 -79
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +1 -1
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +751 -1096
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/noise-handler.d.ts +1 -1
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +103 -1
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/signal.d.ts +13 -0
- package/lib/Utils/signal.d.ts.map +1 -1
- package/lib/Utils/signal.js +42 -0
- package/lib/Utils/signal.js.map +1 -1
- package/lib/Utils/sync-action-utils.d.ts.map +1 -1
- package/lib/Utils/sync-action-utils.js +1 -0
- package/lib/Utils/sync-action-utils.js.map +1 -1
- package/lib/Utils/tc-token-utils.d.ts +26 -1
- package/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/lib/Utils/tc-token-utils.js +151 -5
- package/lib/Utils/tc-token-utils.js.map +1 -1
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +12 -2
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/WABinary/decode.d.ts +1 -1
- package/lib/WABinary/decode.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.d.ts +1 -3
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +0 -78
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAM/encode.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +26 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +1 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -1
- package/lib/WAUSync/USyncQuery.d.ts +1 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
- package/lib/WAUSync/USyncQuery.js +6 -2
- package/lib/WAUSync/USyncQuery.js.map +1 -1
- package/lib/WAUSync/USyncUser.d.ts +4 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -1
- package/lib/WAUSync/USyncUser.js +8 -0
- package/lib/WAUSync/USyncUser.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -12
- package/lib/index.js.map +1 -1
- package/package.json +104 -23
- package/test/core.test.js +38 -0
- package/test/simple-api.test.js +183 -0
- package/lib/Socket/dugong.d.ts +0 -130
- package/lib/Socket/dugong.d.ts.map +0 -1
- package/lib/Socket/dugong.js +0 -768
- package/lib/Socket/dugong.js.map +0 -1
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Utils/kyy-features.d.ts +0 -158
- package/lib/Utils/kyy-features.js +0 -365
- package/lib/Utils/rich-messages.d.ts +0 -277
- package/lib/Utils/rich-messages.d.ts.map +0 -1
- package/lib/Utils/rich-messages.js +0 -1144
- package/lib/Utils/rich-messages.js.map +0 -1
- package/lib/Utils/sticker-pack.d.ts +0 -10
- package/lib/Utils/sticker-pack.js +0 -111
package/README.md
CHANGED
|
@@ -1,1550 +1,792 @@
|
|
|
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+v0.1.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;ESM-only+%7C+TypeScript+%7C+Signal+Protocol;Drop-in+replacement+for+whiskeysockets%2Fbaileys" alt="Typing SVG" />
|
|
4
|
-
|
|
5
|
-
<br/>
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@kyyinfinite/baileys)
|
|
8
|
-
[](https://www.npmjs.com/package/@kyyinfinite/baileys)
|
|
9
|
-
[](LICENSE)
|
|
10
|
-
[](https://nodejs.org)
|
|
11
|
-
[](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
|
|
12
|
-
[](https://www.typescriptlang.org)
|
|
13
|
-
[](https://github.com/kyyinfinite/baileys)
|
|
14
|
-
|
|
15
|
-
<br/>
|
|
16
|
-
|
|
17
|
-
**A modded build of [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)**
|
|
18
|
-
with native support for **interactive messages**, **album messages**, **unified AI rich responses**,
|
|
19
|
-
**newsletter helpers**, **status mentions**, and additional **business / community utilities**.
|
|
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
|
-
<br/>
|
|
28
|
-
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## 📋 Table of Contents
|
|
34
|
-
|
|
35
|
-
- [✨ Features](#-features)
|
|
36
|
-
- [✅ Requirements](#-requirements)
|
|
37
|
-
- [📦 Installation](#-installation)
|
|
38
|
-
- [🚀 Quick Start](#-quick-start)
|
|
39
|
-
- [Project Setup](#1-project-setup)
|
|
40
|
-
- [Install Dependencies](#2-install-dependencies)
|
|
41
|
-
- [Create index.js](#3-create-indexjs)
|
|
42
|
-
- [QR Code Login](#4-run--qr-code-login)
|
|
43
|
-
- [Pairing Code Login](#5-pairing-code-login)
|
|
44
|
-
- [Auto Reconnect](#6-auto-reconnect)
|
|
45
|
-
- [💬 Message Examples](#-message-examples)
|
|
46
|
-
- [Text](#text)
|
|
47
|
-
- [Image](#image)
|
|
48
|
-
- [Video](#video)
|
|
49
|
-
- [Audio & PTT](#audio--ptt)
|
|
50
|
-
- [Sticker](#sticker)
|
|
51
|
-
- [Document](#document)
|
|
52
|
-
- [Location](#location)
|
|
53
|
-
- [Contact](#contact)
|
|
54
|
-
- [Poll](#poll)
|
|
55
|
-
- [Reaction](#reaction)
|
|
56
|
-
- [Delete & Edit](#delete--edit)
|
|
57
|
-
- [Forward & Quoted](#forward--quoted)
|
|
58
|
-
- [Mention](#mention)
|
|
59
|
-
- [⚡ Interactive Messages](#-interactive-messages)
|
|
60
|
-
- [Flow Buttons](#flow-buttons)
|
|
61
|
-
- [CTA URL Button](#cta-url-button)
|
|
62
|
-
- [Copy Button](#copy-button)
|
|
63
|
-
- [List Menu (single_select)](#list-menu-single_select)
|
|
64
|
-
- [Carousel](#carousel)
|
|
65
|
-
- [Native Interactive](#native-interactive)
|
|
66
|
-
- [🤖 AI Rich Response](#-ai-rich-response)
|
|
67
|
-
- [sendTable()](#sendtable)
|
|
68
|
-
- [sendList()](#sendlist)
|
|
69
|
-
- [sendCodeBlock()](#sendcodeblock)
|
|
70
|
-
- [sendLink()](#sendlink)
|
|
71
|
-
- [sendUnifiedResponse()](#sendunifiedresponse)
|
|
72
|
-
- [sendTableV2()](#sendtablev2)
|
|
73
|
-
- [sendCodeBlockV2()](#sendcodeblockv2)
|
|
74
|
-
- [sendLinkV2()](#sendlinkv2)
|
|
75
|
-
- [🎞️ Album Messages](#️-album-messages)
|
|
76
|
-
- [📰 Newsletter](#-newsletter)
|
|
77
|
-
- [👥 Group](#-group)
|
|
78
|
-
- [🏘️ Community](#️-community)
|
|
79
|
-
- [🏢 Business](#-business)
|
|
80
|
-
- [👤 Profile](#-profile)
|
|
81
|
-
- [💬 Chat](#-chat)
|
|
82
|
-
- [🔒 Privacy](#-privacy)
|
|
83
|
-
- [📡 Events](#-events)
|
|
84
|
-
- [🔧 Utility Exports](#-utility-exports)
|
|
85
|
-
- [📚 API Reference](#-api-reference)
|
|
86
|
-
- [❓ FAQ](#-faq)
|
|
87
|
-
- [📄 License](#-license)
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## ✨ Features
|
|
92
|
-
|
|
93
|
-
| Feature | Description | Status |
|
|
94
|
-
|---|---|:---:|
|
|
95
|
-
| **Interactive Messages** | Native flow buttons, list/select menus, button wrappers, carousel support via Dugong | ✅ |
|
|
96
|
-
| **Flow Buttons** | `quick_reply`, `cta_url`, `cta_copy` and more button types | ✅ |
|
|
97
|
-
| **Native Button** | Native WhatsApp button structures | ✅ |
|
|
98
|
-
| **Carousel** | Multi-card carousel messages via Dugong | ✅ |
|
|
99
|
-
| **AI Rich Response** | `sendTable`, `sendList`, `sendCodeBlock`, `sendRichMessage`, `sendUnifiedResponse` | ✅ |
|
|
100
|
-
| **Album Messages** | Multi-image/video album relay with count metadata and grouped delivery | ✅ |
|
|
101
|
-
| **Link Messages** | Rich inline links with citations, proofs, and forwarded bot context | ✅ |
|
|
102
|
-
| **Table Message** | `sendTable()` / `sendTableV2()` styled as Meta AI tables | ✅ |
|
|
103
|
-
| **Code Block** | `sendCodeBlock()` / `sendCodeBlockV2()` with multi-language syntax support | ✅ |
|
|
104
|
-
| **Unified Response** | `sendUnifiedResponse()` unified sections | ✅ |
|
|
105
|
-
| **Newsletter** | URL resolve, metadata fetch, create/update, bulk follow, admin utilities, live updates | ✅ |
|
|
106
|
-
| **Communities** | Community CRUD, linked groups, invite workflows, join approval, labels | ✅ |
|
|
107
|
-
| **Business API** | Business profile update, catalog management, product CRUD | ✅ |
|
|
108
|
-
| **Catalog** | Fetch, create, update, delete product listings and cover photos | ✅ |
|
|
109
|
-
| **Payment** | Request payment messages with note/sticker support | ✅ |
|
|
110
|
-
| **Poll** | Send and receive poll messages with `selectableCount` | ✅ |
|
|
111
|
-
| **Event** | Event message builders and poll result snapshots | ✅ |
|
|
112
|
-
| **Status Mention** | `sendStatusMention()` to mention users/groups in status flows | ✅ |
|
|
113
|
-
| **LID Mapping** | Full LID↔PN mapping + session migration and retry helpers | ✅ |
|
|
114
|
-
| **Pairing Code** | Request pairing code or use custom 8-char code | ✅ |
|
|
115
|
-
| **QR Login** | Scan QR code via `connection.update` event | ✅ |
|
|
116
|
-
| **Media Upload** | Image, video, audio, sticker, document via URL or Buffer | ✅ |
|
|
117
|
-
| **TypeScript** | Included `.d.ts` declarations for all exported APIs | ✅ |
|
|
118
|
-
| **ESM** | Native ES Module — no CommonJS bundle | ✅ |
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## ✅ Requirements
|
|
123
|
-
|
|
124
|
-
| Requirement | Version / Detail |
|
|
125
|
-
|---|---|
|
|
126
|
-
| **Node.js** | `>= 20.0.0` |
|
|
127
|
-
| **Module system** | ESM only — `"type": "module"` in `package.json` |
|
|
128
|
-
| **Auth store** | Persistent auth required for production use |
|
|
129
|
-
|
|
130
|
-
**Optional companion packages:**
|
|
131
|
-
|
|
132
|
-
| Package | Purpose |
|
|
133
|
-
|---|---|
|
|
134
|
-
| `pino` | Structured logging |
|
|
135
|
-
| `qrcode-terminal` | Render QR codes in terminal |
|
|
136
|
-
| `sharp` | Image processing for sticker/media utilities |
|
|
137
|
-
| `link-preview-js` | Generate link previews |
|
|
138
|
-
| `audio-decode` | Audio format decoding |
|
|
139
|
-
|
|
140
|
-
> [!NOTE]
|
|
141
|
-
> Peer dependencies like `sharp`, `jimp`, `audio-decode`, and `link-preview-js` are **optional**.
|
|
142
|
-
> Install only what your bot features actually need.
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## 📦 Installation
|
|
147
|
-
|
|
148
|
-
**npm**
|
|
149
|
-
```bash
|
|
150
|
-
npm install @kyyinfinite/baileys
|
|
151
|
-
```
|
|
1
|
+
# @kyyinfinite/baileys
|
|
152
2
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```
|
|
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.
|
|
157
6
|
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
yarn add @kyyinfinite/baileys
|
|
161
|
-
```
|
|
7
|
+
## Installation
|
|
162
8
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
bun add @kyyinfinite/baileys
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
**Recommended companion packages:**
|
|
169
|
-
```bash
|
|
170
|
-
npm install pino qrcode-terminal
|
|
9
|
+
``` bash
|
|
10
|
+
npm install @kyyinfinite/baileys
|
|
171
11
|
```
|
|
172
12
|
|
|
173
|
-
|
|
174
|
-
> 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.
|
|
13
|
+
## Quick Start
|
|
175
14
|
|
|
176
|
-
|
|
15
|
+
``` js
|
|
16
|
+
import { makeWASocket, attachKyyinfinite } from '@kyyinfinite/baileys'
|
|
177
17
|
|
|
178
|
-
|
|
18
|
+
const sock = makeWASocket(config)
|
|
179
19
|
|
|
180
|
-
|
|
20
|
+
attachKyyinfinite(sock)
|
|
181
21
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
22
|
+
await sock
|
|
23
|
+
.text('Hello')
|
|
24
|
+
.send(jid)
|
|
185
25
|
```
|
|
186
26
|
|
|
187
|
-
|
|
27
|
+
The API is designed to keep common operations short while still allowing
|
|
28
|
+
advanced message builders when needed.
|
|
188
29
|
|
|
189
|
-
|
|
190
|
-
{
|
|
191
|
-
"name": "my-bot",
|
|
192
|
-
"version": "1.0.0",
|
|
193
|
-
"type": "module",
|
|
194
|
-
"main": "index.js",
|
|
195
|
-
"scripts": {
|
|
196
|
-
"start": "node index.js"
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
```
|
|
30
|
+
------------------------------------------------------------------------
|
|
200
31
|
|
|
201
|
-
|
|
202
|
-
> **`"type": "module"` is required.** `@kyyinfinite/baileys` is ESM-only.
|
|
203
|
-
> Without this field, all imports will throw a syntax error.
|
|
32
|
+
# API
|
|
204
33
|
|
|
205
|
-
|
|
34
|
+
## Text
|
|
206
35
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
36
|
+
``` js
|
|
37
|
+
await sock
|
|
38
|
+
.text('Hello')
|
|
39
|
+
.send(jid)
|
|
211
40
|
```
|
|
212
41
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
### 3. Create index.js
|
|
216
|
-
|
|
217
|
-
```js
|
|
218
|
-
import makeWASocket, {
|
|
219
|
-
useMultiFileAuthState,
|
|
220
|
-
DisconnectReason,
|
|
221
|
-
Browsers,
|
|
222
|
-
} from "@kyyinfinite/baileys";
|
|
223
|
-
import pino from "pino";
|
|
224
|
-
import qrcode from "qrcode-terminal";
|
|
225
|
-
|
|
226
|
-
const logger = pino({ level: "silent" });
|
|
227
|
-
|
|
228
|
-
async function startBot() {
|
|
229
|
-
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
230
|
-
|
|
231
|
-
const sock = makeWASocket({
|
|
232
|
-
auth: state,
|
|
233
|
-
logger,
|
|
234
|
-
browser: Browsers.ubuntu("Chrome"),
|
|
235
|
-
syncFullHistory: false,
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
sock.ev.on("creds.update", saveCreds);
|
|
239
|
-
|
|
240
|
-
sock.ev.on("connection.update", ({ connection, lastDisconnect, qr }) => {
|
|
241
|
-
if (qr) {
|
|
242
|
-
qrcode.generate(qr, { small: true });
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (connection === "close") {
|
|
246
|
-
const shouldReconnect =
|
|
247
|
-
lastDisconnect?.error?.output?.statusCode !== DisconnectReason.loggedOut;
|
|
248
|
-
if (shouldReconnect) startBot();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (connection === "open") {
|
|
252
|
-
console.log("✅ Connected!");
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
sock.ev.on("messages.upsert", async ({ messages }) => {
|
|
257
|
-
const msg = messages[0];
|
|
258
|
-
if (!msg?.message || msg.key.fromMe) return;
|
|
259
|
-
|
|
260
|
-
const text =
|
|
261
|
-
msg.message.conversation ||
|
|
262
|
-
msg.message.extendedTextMessage?.text ||
|
|
263
|
-
"";
|
|
264
|
-
|
|
265
|
-
if (text === ".ping") {
|
|
266
|
-
await sock.sendMessage(msg.key.remoteJid, { text: "🏓 Pong!" });
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
42
|
+
Additional text options:
|
|
270
43
|
|
|
271
|
-
|
|
44
|
+
``` js
|
|
45
|
+
await sock
|
|
46
|
+
.text('Hello')
|
|
47
|
+
.footer('Kyyinfinite')
|
|
48
|
+
.mentions(['628123456789@s.whatsapp.net'])
|
|
49
|
+
.send(jid)
|
|
272
50
|
```
|
|
273
51
|
|
|
274
|
-
|
|
52
|
+
Available text builder methods:
|
|
275
53
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
54
|
+
``` text
|
|
55
|
+
text()
|
|
56
|
+
footer()
|
|
57
|
+
context()
|
|
58
|
+
mentions()
|
|
59
|
+
viewOnce()
|
|
60
|
+
edit()
|
|
61
|
+
payload()
|
|
62
|
+
build()
|
|
63
|
+
send()
|
|
280
64
|
```
|
|
281
65
|
|
|
282
|
-
|
|
283
|
-
Wait until the socket reaches `connection === "open"`, then send `.ping` to test.
|
|
284
|
-
|
|
285
|
-
---
|
|
286
|
-
|
|
287
|
-
### 5. Pairing Code Login
|
|
288
|
-
|
|
289
|
-
If you prefer pairing code authentication over QR:
|
|
66
|
+
------------------------------------------------------------------------
|
|
290
67
|
|
|
291
|
-
|
|
292
|
-
import makeWASocket, {
|
|
293
|
-
useMultiFileAuthState,
|
|
294
|
-
Browsers,
|
|
295
|
-
} from "@kyyinfinite/baileys";
|
|
296
|
-
import pino from "pino";
|
|
68
|
+
# Media
|
|
297
69
|
|
|
298
|
-
|
|
70
|
+
Shortcut builders:
|
|
299
71
|
|
|
300
|
-
|
|
301
|
-
|
|
72
|
+
``` js
|
|
73
|
+
await sock.image('./image.jpg')
|
|
74
|
+
.caption('Image')
|
|
75
|
+
.send(jid)
|
|
302
76
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
browser: Browsers.windows("Chrome"),
|
|
307
|
-
});
|
|
77
|
+
await sock.video('./video.mp4')
|
|
78
|
+
.caption('Video')
|
|
79
|
+
.send(jid)
|
|
308
80
|
|
|
309
|
-
|
|
81
|
+
await sock.audio('./audio.mp3')
|
|
82
|
+
.send(jid)
|
|
310
83
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// Replace with your phone number (include country code, no +)
|
|
314
|
-
const code = await sock.requestPairingCode("6281234567890");
|
|
315
|
-
console.log("🔑 Pairing code:", code);
|
|
316
|
-
}
|
|
84
|
+
await sock.voice('./voice.ogg')
|
|
85
|
+
.send(jid)
|
|
317
86
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
322
|
-
}
|
|
87
|
+
await sock.document('./file.pdf')
|
|
88
|
+
.fileName('document.pdf')
|
|
89
|
+
.send(jid)
|
|
323
90
|
|
|
324
|
-
|
|
91
|
+
await sock.sticker('./sticker.webp')
|
|
92
|
+
.send(jid)
|
|
325
93
|
```
|
|
326
94
|
|
|
327
|
-
|
|
95
|
+
Other media shortcuts:
|
|
328
96
|
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
|
|
97
|
+
``` text
|
|
98
|
+
ptv()
|
|
99
|
+
gif()
|
|
332
100
|
```
|
|
333
101
|
|
|
334
|
-
|
|
335
|
-
> Custom pairing codes **must be exactly 8 characters**. Any other length will be rejected by WhatsApp.
|
|
336
|
-
|
|
337
|
-
> [!NOTE]
|
|
338
|
-
> `printQRInTerminal` still exists in the type surface for compatibility, but it is deprecated in this build.
|
|
339
|
-
> Prefer handling the `qr` value from `connection.update` directly with `qrcode-terminal`.
|
|
340
|
-
|
|
341
|
-
---
|
|
342
|
-
|
|
343
|
-
### 6. Auto Reconnect
|
|
344
|
-
|
|
345
|
-
```js
|
|
346
|
-
sock.ev.on("connection.update", ({ connection, lastDisconnect }) => {
|
|
347
|
-
if (connection === "close") {
|
|
348
|
-
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
|
349
|
-
const shouldReconnect = statusCode !== DisconnectReason.loggedOut;
|
|
102
|
+
## Universal Media
|
|
350
103
|
|
|
351
|
-
|
|
104
|
+
Use one builder when the media type needs to be selected dynamically:
|
|
352
105
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
});
|
|
106
|
+
``` js
|
|
107
|
+
await sock
|
|
108
|
+
.media(buffer)
|
|
109
|
+
.asImage()
|
|
110
|
+
.caption('Photo')
|
|
111
|
+
.send(jid)
|
|
360
112
|
```
|
|
361
113
|
|
|
362
|
-
|
|
363
|
-
> 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.
|
|
364
|
-
|
|
365
|
-
---
|
|
366
|
-
|
|
367
|
-
## 💬 Message Examples
|
|
368
|
-
|
|
369
|
-
### Text
|
|
114
|
+
Supported types:
|
|
370
115
|
|
|
371
|
-
```
|
|
372
|
-
|
|
116
|
+
``` text
|
|
117
|
+
asImage()
|
|
118
|
+
asVideo()
|
|
119
|
+
asAudio()
|
|
120
|
+
asDocument()
|
|
121
|
+
asSticker()
|
|
373
122
|
```
|
|
374
123
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
```js
|
|
378
|
-
// From URL
|
|
379
|
-
await sock.sendMessage(jid, {
|
|
380
|
-
image: { url: "https://example.com/photo.jpg" },
|
|
381
|
-
caption: "A beautiful photo 📸",
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
// From file path
|
|
385
|
-
await sock.sendMessage(jid, {
|
|
386
|
-
image: { url: "./photo.jpg" },
|
|
387
|
-
caption: "Local photo",
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
// From Buffer
|
|
391
|
-
import { readFileSync } from "fs";
|
|
392
|
-
await sock.sendMessage(jid, {
|
|
393
|
-
image: readFileSync("./photo.jpg"),
|
|
394
|
-
caption: "From buffer",
|
|
395
|
-
});
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
### Video
|
|
399
|
-
|
|
400
|
-
```js
|
|
401
|
-
await sock.sendMessage(jid, {
|
|
402
|
-
video: { url: "./video.mp4" },
|
|
403
|
-
caption: "Check this out 🎬",
|
|
404
|
-
gifPlayback: false, // set true for GIF-style playback
|
|
405
|
-
});
|
|
406
|
-
```
|
|
124
|
+
Media builder options include:
|
|
407
125
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
126
|
+
``` text
|
|
127
|
+
caption()
|
|
128
|
+
fileName()
|
|
129
|
+
mimetype()
|
|
130
|
+
context()
|
|
131
|
+
mentions()
|
|
132
|
+
payload()
|
|
133
|
+
viewOnce()
|
|
134
|
+
ptt()
|
|
135
|
+
voice()
|
|
136
|
+
ptv()
|
|
137
|
+
videoNote()
|
|
138
|
+
gif()
|
|
139
|
+
animated()
|
|
140
|
+
dimensions()
|
|
141
|
+
thumbnail()
|
|
142
|
+
build()
|
|
143
|
+
send()
|
|
423
144
|
```
|
|
424
145
|
|
|
425
|
-
|
|
146
|
+
------------------------------------------------------------------------
|
|
426
147
|
|
|
427
|
-
|
|
428
|
-
await sock.sendMessage(jid, {
|
|
429
|
-
sticker: { url: "./sticker.webp" },
|
|
430
|
-
});
|
|
431
|
-
```
|
|
148
|
+
## Unified Send
|
|
432
149
|
|
|
433
|
-
|
|
150
|
+
For simple messages, use:
|
|
434
151
|
|
|
435
|
-
```js
|
|
436
|
-
await sock.
|
|
437
|
-
document: { url: "./report.pdf" },
|
|
438
|
-
fileName: "Monthly Report.pdf",
|
|
439
|
-
mimetype: "application/pdf",
|
|
440
|
-
caption: "Here is the report 📄",
|
|
441
|
-
});
|
|
152
|
+
``` js
|
|
153
|
+
await sock.send(jid, 'Hello')
|
|
442
154
|
```
|
|
443
155
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
```js
|
|
447
|
-
await sock.sendMessage(jid, {
|
|
448
|
-
location: {
|
|
449
|
-
degreesLatitude: -6.2088,
|
|
450
|
-
degreesLongitude: 106.8456,
|
|
451
|
-
name: "Jakarta, Indonesia",
|
|
452
|
-
address: "Jakarta, Indonesia",
|
|
453
|
-
},
|
|
454
|
-
});
|
|
455
|
-
```
|
|
156
|
+
Object payloads are also supported:
|
|
456
157
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
contacts: {
|
|
462
|
-
displayName: "John Doe",
|
|
463
|
-
contacts: [
|
|
464
|
-
{
|
|
465
|
-
vcard: `BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL;type=CELL;type=VOICE;waid=6281234567890:+62 812-3456-7890\nEND:VCARD`,
|
|
466
|
-
},
|
|
467
|
-
],
|
|
468
|
-
},
|
|
469
|
-
});
|
|
158
|
+
``` js
|
|
159
|
+
await sock.send(jid, {
|
|
160
|
+
text: 'Hello'
|
|
161
|
+
})
|
|
470
162
|
```
|
|
471
163
|
|
|
472
|
-
|
|
164
|
+
Media:
|
|
473
165
|
|
|
474
|
-
```js
|
|
475
|
-
await sock.
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
selectableCount: 1, // 0 = allow multiple
|
|
480
|
-
},
|
|
481
|
-
});
|
|
166
|
+
``` js
|
|
167
|
+
await sock.send(jid, {
|
|
168
|
+
image: './image.jpg',
|
|
169
|
+
caption: 'Hello'
|
|
170
|
+
})
|
|
482
171
|
```
|
|
483
172
|
|
|
484
|
-
|
|
173
|
+
The unified API is intended for cases where you do not need to manually
|
|
174
|
+
create a builder.
|
|
485
175
|
|
|
486
|
-
|
|
487
|
-
await sock.sendMessage(jid, {
|
|
488
|
-
react: {
|
|
489
|
-
key: msg.key, // key of the message to react to
|
|
490
|
-
text: "👍", // use "" to remove reaction
|
|
491
|
-
},
|
|
492
|
-
});
|
|
493
|
-
```
|
|
176
|
+
------------------------------------------------------------------------
|
|
494
177
|
|
|
495
|
-
|
|
178
|
+
## Quoted Messages
|
|
496
179
|
|
|
497
|
-
|
|
498
|
-
// Delete a message (for everyone)
|
|
499
|
-
await sock.sendMessage(jid, { delete: msg.key });
|
|
180
|
+
Reply directly to an existing message:
|
|
500
181
|
|
|
501
|
-
|
|
502
|
-
await sock.
|
|
503
|
-
text: "This is the corrected text ✏️",
|
|
504
|
-
edit: msg.key,
|
|
505
|
-
});
|
|
182
|
+
``` js
|
|
183
|
+
await sock.reply(message, 'Hello')
|
|
506
184
|
```
|
|
507
185
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
```js
|
|
511
|
-
// Forward a message
|
|
512
|
-
await sock.sendMessage(jid, { forward: msg });
|
|
186
|
+
Or:
|
|
513
187
|
|
|
514
|
-
|
|
515
|
-
await sock.
|
|
516
|
-
jid,
|
|
517
|
-
{ text: "This is a reply!" },
|
|
518
|
-
{ quoted: msg }
|
|
519
|
-
);
|
|
188
|
+
``` js
|
|
189
|
+
await sock.quoted(message, 'Hello')
|
|
520
190
|
```
|
|
521
191
|
|
|
522
|
-
|
|
192
|
+
Message wrapper:
|
|
523
193
|
|
|
524
|
-
```js
|
|
525
|
-
|
|
526
|
-
text: "Hey @628111222333, how are you?",
|
|
527
|
-
mentions: ["628111222333@s.whatsapp.net"],
|
|
528
|
-
});
|
|
529
|
-
```
|
|
194
|
+
``` js
|
|
195
|
+
const m = sock.wrapMessage(message)
|
|
530
196
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
```js
|
|
534
|
-
await sock.sendMessage(jid, {
|
|
535
|
-
text: "Message with custom context",
|
|
536
|
-
contextInfo: {
|
|
537
|
-
externalAdReply: {
|
|
538
|
-
title: "My Bot",
|
|
539
|
-
body: "Powered by @kyyinfinite/baileys",
|
|
540
|
-
thumbnail: readFileSync("./thumbnail.jpg"),
|
|
541
|
-
sourceUrl: "https://github.com/kyyinfinite/baileys",
|
|
542
|
-
mediaType: 1,
|
|
543
|
-
renderLargerThumbnail: true,
|
|
544
|
-
},
|
|
545
|
-
},
|
|
546
|
-
});
|
|
197
|
+
await m.reply('Hello')
|
|
547
198
|
```
|
|
548
199
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
## ⚡ Interactive Messages
|
|
552
|
-
|
|
553
|
-
> [!NOTE]
|
|
554
|
-
> Interactive messages are powered by the **Dugong** layer in `@kyyinfinite/baileys`.
|
|
555
|
-
> These are not available in the official WhiskeySockets/Baileys.
|
|
556
|
-
|
|
557
|
-
### Flow Buttons
|
|
558
|
-
|
|
559
|
-
```js
|
|
560
|
-
await sock.sendMessage(jid, {
|
|
561
|
-
interactiveMessage: {
|
|
562
|
-
title: "Welcome! 👋",
|
|
563
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
564
|
-
buttons: [
|
|
565
|
-
{
|
|
566
|
-
name: "quick_reply",
|
|
567
|
-
buttonParamsJson: JSON.stringify({
|
|
568
|
-
display_text: "📋 Menu",
|
|
569
|
-
id: "menu",
|
|
570
|
-
}),
|
|
571
|
-
},
|
|
572
|
-
],
|
|
573
|
-
header: "Choose an option below",
|
|
574
|
-
},
|
|
575
|
-
});
|
|
576
|
-
```
|
|
200
|
+
Available message actions:
|
|
577
201
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
buttons: [
|
|
586
|
-
{
|
|
587
|
-
name: "cta_url",
|
|
588
|
-
buttonParamsJson: JSON.stringify({
|
|
589
|
-
display_text: "🌐 Open Website",
|
|
590
|
-
url: "https://example.com",
|
|
591
|
-
merchant_url: "https://example.com",
|
|
592
|
-
}),
|
|
593
|
-
},
|
|
594
|
-
],
|
|
595
|
-
header: "External Link",
|
|
596
|
-
},
|
|
597
|
-
});
|
|
202
|
+
``` text
|
|
203
|
+
reply()
|
|
204
|
+
react()
|
|
205
|
+
edit()
|
|
206
|
+
delete()
|
|
207
|
+
forward()
|
|
208
|
+
download()
|
|
598
209
|
```
|
|
599
210
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
```js
|
|
603
|
-
await sock.sendMessage(jid, {
|
|
604
|
-
interactiveMessage: {
|
|
605
|
-
title: "Your promo code",
|
|
606
|
-
footer: "Tap to copy",
|
|
607
|
-
buttons: [
|
|
608
|
-
{
|
|
609
|
-
name: "cta_copy",
|
|
610
|
-
buttonParamsJson: JSON.stringify({
|
|
611
|
-
display_text: "📋 Copy Code",
|
|
612
|
-
copy_code: "KYYBAILEYS2024",
|
|
613
|
-
}),
|
|
614
|
-
},
|
|
615
|
-
],
|
|
616
|
-
header: "Promo Code",
|
|
617
|
-
},
|
|
618
|
-
});
|
|
619
|
-
```
|
|
211
|
+
Socket shortcuts:
|
|
620
212
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
buttons: [
|
|
629
|
-
{
|
|
630
|
-
name: "single_select",
|
|
631
|
-
buttonParamsJson: JSON.stringify({
|
|
632
|
-
title: "📋 Open Menu",
|
|
633
|
-
sections: [
|
|
634
|
-
{
|
|
635
|
-
title: "🛠️ Tools",
|
|
636
|
-
rows: [
|
|
637
|
-
{ title: "🖼️ Sticker Maker", description: "Convert image to sticker", id: ".sticker" },
|
|
638
|
-
{ title: "🗣️ Text to Speech", description: "Convert text to audio", id: ".tts" },
|
|
639
|
-
{ title: "🔍 AI Search", description: "Ask the AI anything", id: ".ai" },
|
|
640
|
-
],
|
|
641
|
-
},
|
|
642
|
-
{
|
|
643
|
-
title: "ℹ️ Info",
|
|
644
|
-
rows: [
|
|
645
|
-
{ title: "📊 Bot Stats", description: "View bot statistics", id: ".stats" },
|
|
646
|
-
{ title: "❓ Help", description: "How to use this bot", id: ".help" },
|
|
647
|
-
],
|
|
648
|
-
},
|
|
649
|
-
],
|
|
650
|
-
}),
|
|
651
|
-
},
|
|
652
|
-
],
|
|
653
|
-
header: "🤖 Bot Menu",
|
|
654
|
-
},
|
|
655
|
-
});
|
|
213
|
+
``` text
|
|
214
|
+
reply()
|
|
215
|
+
reactTo()
|
|
216
|
+
editMessage()
|
|
217
|
+
deleteMessage()
|
|
218
|
+
forwardMessage()
|
|
219
|
+
downloadMessage()
|
|
656
220
|
```
|
|
657
221
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
```js
|
|
661
|
-
import { Dugong } from "@kyyinfinite/baileys";
|
|
662
|
-
|
|
663
|
-
await sock.sendMessage(jid, {
|
|
664
|
-
interactiveMessage: Dugong.carousel({
|
|
665
|
-
cards: [
|
|
666
|
-
{
|
|
667
|
-
header: {
|
|
668
|
-
imageUrl: "https://example.com/card1.jpg",
|
|
669
|
-
},
|
|
670
|
-
title: "Card One",
|
|
671
|
-
body: "Description for the first card.",
|
|
672
|
-
buttons: [
|
|
673
|
-
{
|
|
674
|
-
name: "quick_reply",
|
|
675
|
-
buttonParamsJson: JSON.stringify({ display_text: "Select", id: "card_1" }),
|
|
676
|
-
},
|
|
677
|
-
],
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
header: {
|
|
681
|
-
imageUrl: "https://example.com/card2.jpg",
|
|
682
|
-
},
|
|
683
|
-
title: "Card Two",
|
|
684
|
-
body: "Description for the second card.",
|
|
685
|
-
buttons: [
|
|
686
|
-
{
|
|
687
|
-
name: "quick_reply",
|
|
688
|
-
buttonParamsJson: JSON.stringify({ display_text: "Select", id: "card_2" }),
|
|
689
|
-
},
|
|
690
|
-
],
|
|
691
|
-
},
|
|
692
|
-
],
|
|
693
|
-
}),
|
|
694
|
-
});
|
|
695
|
-
```
|
|
222
|
+
------------------------------------------------------------------------
|
|
696
223
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
Combine multiple button types in a single message:
|
|
700
|
-
|
|
701
|
-
```js
|
|
702
|
-
await sock.sendMessage(jid, {
|
|
703
|
-
interactiveMessage: {
|
|
704
|
-
title: "🛍️ Product Details",
|
|
705
|
-
footer: "Free shipping above Rp 100.000",
|
|
706
|
-
buttons: [
|
|
707
|
-
{
|
|
708
|
-
name: "quick_reply",
|
|
709
|
-
buttonParamsJson: JSON.stringify({ display_text: "🛒 Buy Now", id: "buy_now" }),
|
|
710
|
-
},
|
|
711
|
-
{
|
|
712
|
-
name: "cta_url",
|
|
713
|
-
buttonParamsJson: JSON.stringify({
|
|
714
|
-
display_text: "📄 More Info",
|
|
715
|
-
url: "https://example.com/product",
|
|
716
|
-
}),
|
|
717
|
-
},
|
|
718
|
-
{
|
|
719
|
-
name: "cta_copy",
|
|
720
|
-
buttonParamsJson: JSON.stringify({
|
|
721
|
-
display_text: "📋 Copy Product ID",
|
|
722
|
-
copy_code: "PROD-12345",
|
|
723
|
-
}),
|
|
724
|
-
},
|
|
725
|
-
],
|
|
726
|
-
header: "Premium Package",
|
|
727
|
-
image: { url: "https://example.com/product.jpg" },
|
|
728
|
-
},
|
|
729
|
-
});
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
---
|
|
224
|
+
## Message Parser
|
|
733
225
|
|
|
734
|
-
|
|
226
|
+
Parse an incoming message into a simple object:
|
|
735
227
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
228
|
+
``` js
|
|
229
|
+
const parsed = sock.parseMessage(message, {
|
|
230
|
+
prefix: '.'
|
|
231
|
+
})
|
|
739
232
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
await sock.sendTable(
|
|
744
|
-
jid,
|
|
745
|
-
"Java vs JavaScript",
|
|
746
|
-
["Feature", "Java", "JavaScript"],
|
|
747
|
-
[
|
|
748
|
-
["Type", "Compiled", "Interpreted"],
|
|
749
|
-
["Typing", "Static", "Dynamic"],
|
|
750
|
-
["Runtime", "JVM", "V8 / Browser"],
|
|
751
|
-
["Main Use", "Enterprise", "Web, Full-stack"],
|
|
752
|
-
["Speed", "Faster", "Slightly Slower"],
|
|
753
|
-
],
|
|
754
|
-
quoted,
|
|
755
|
-
{
|
|
756
|
-
headerText: "📊 Comparison Table:",
|
|
757
|
-
footer: "Hope this helps! 😊",
|
|
758
|
-
}
|
|
759
|
-
);
|
|
233
|
+
console.log(parsed.text)
|
|
234
|
+
console.log(parsed.command)
|
|
235
|
+
console.log(parsed.args)
|
|
760
236
|
```
|
|
761
237
|
|
|
762
|
-
|
|
238
|
+
Returned data includes:
|
|
763
239
|
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
);
|
|
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
|
|
778
253
|
```
|
|
779
254
|
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
V1 supports: `javascript`, `typescript`, `python`
|
|
255
|
+
Example command:
|
|
783
256
|
|
|
784
|
-
```
|
|
785
|
-
|
|
786
|
-
jid,
|
|
787
|
-
`import makeWASocket from "@kyyinfinite/baileys";\n\nconst sock = makeWASocket({ auth: state });`,
|
|
788
|
-
quoted,
|
|
789
|
-
{
|
|
790
|
-
language: "javascript",
|
|
791
|
-
title: "Quick Start",
|
|
792
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
793
|
-
}
|
|
794
|
-
);
|
|
257
|
+
``` text
|
|
258
|
+
.menu game hard
|
|
795
259
|
```
|
|
796
260
|
|
|
797
|
-
|
|
261
|
+
can be consumed as:
|
|
798
262
|
|
|
799
|
-
```js
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
"Upload results:\n🔗 Click: {{IE_0}}download here{{/IE_0}}",
|
|
803
|
-
["https://example.com/file.zip"],
|
|
804
|
-
quoted,
|
|
805
|
-
{
|
|
806
|
-
headerText: "📁 File Uploader",
|
|
807
|
-
footer: "✨ Upload complete!",
|
|
808
|
-
citations: [{ sourceTitle: "FileHost", citationNumber: 1 }],
|
|
809
|
-
}
|
|
810
|
-
);
|
|
263
|
+
``` js
|
|
264
|
+
parsed.command // "menu"
|
|
265
|
+
parsed.args // ["game", "hard"]
|
|
811
266
|
```
|
|
812
267
|
|
|
813
|
-
|
|
268
|
+
------------------------------------------------------------------------
|
|
814
269
|
|
|
815
|
-
|
|
816
|
-
await sock.sendUnifiedResponse(
|
|
817
|
-
jid,
|
|
818
|
-
"Here is a unified response combining text and structured data.",
|
|
819
|
-
quoted,
|
|
820
|
-
{
|
|
821
|
-
headerText: "🤖 AI Response",
|
|
822
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
823
|
-
}
|
|
824
|
-
);
|
|
825
|
-
```
|
|
270
|
+
## Mentions
|
|
826
271
|
|
|
827
|
-
|
|
272
|
+
Text containing a WhatsApp-style number can be resolved automatically:
|
|
828
273
|
|
|
829
|
-
```js
|
|
830
|
-
await sock.
|
|
274
|
+
``` js
|
|
275
|
+
await sock.send(
|
|
831
276
|
jid,
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
[
|
|
835
|
-
["Express", "JavaScript", "REST API"],
|
|
836
|
-
["Fastify", "JavaScript", "High-perf API"],
|
|
837
|
-
["Hono", "TypeScript", "Edge / Bun"],
|
|
838
|
-
["Elysia", "TypeScript", "Bun Native"],
|
|
839
|
-
],
|
|
840
|
-
quoted,
|
|
841
|
-
{
|
|
842
|
-
text: "Here's a framework comparison you requested:",
|
|
843
|
-
headerText: "📊 Frameworks",
|
|
844
|
-
footer: "Updated 2026",
|
|
845
|
-
}
|
|
846
|
-
);
|
|
277
|
+
'Hello @628123456789'
|
|
278
|
+
)
|
|
847
279
|
```
|
|
848
280
|
|
|
849
|
-
|
|
281
|
+
Disable automatic mention resolution when required:
|
|
850
282
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
```js
|
|
854
|
-
await sock.sendCodeBlockV2(
|
|
283
|
+
``` js
|
|
284
|
+
await sock.send(
|
|
855
285
|
jid,
|
|
856
|
-
|
|
857
|
-
quoted,
|
|
286
|
+
'Hello @628123456789',
|
|
858
287
|
{
|
|
859
|
-
|
|
860
|
-
title: "Go Example",
|
|
861
|
-
text: "Here is a Go snippet:",
|
|
862
|
-
footer: "Powered by @kyyinfinite/baileys",
|
|
288
|
+
autoMentions: false
|
|
863
289
|
}
|
|
864
|
-
)
|
|
290
|
+
)
|
|
865
291
|
```
|
|
866
292
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
| Language Key | Aliases |
|
|
870
|
-
|---|---|
|
|
871
|
-
| `javascript` | `js`, `typescript`, `ts` |
|
|
872
|
-
| `python` | `py` |
|
|
873
|
-
| `go` | `golang` |
|
|
874
|
-
| `lua` | — |
|
|
875
|
-
| `bash` | `sh`, `shell` |
|
|
876
|
-
|
|
877
|
-
### sendLinkV2()
|
|
878
|
-
|
|
879
|
-
```js
|
|
880
|
-
await sock.sendLinkV2(
|
|
881
|
-
jid,
|
|
882
|
-
"Search results:\n- {{IE_0}}Official npm page{{/IE_0}}\n- {{IE_1}}GitHub repository{{/IE_1}}",
|
|
883
|
-
[
|
|
884
|
-
{
|
|
885
|
-
url: "https://www.npmjs.com/package/@kyyinfinite/baileys",
|
|
886
|
-
displayName: "Official npm page",
|
|
887
|
-
sourceDisplayName: "npmjs.com",
|
|
888
|
-
},
|
|
889
|
-
{
|
|
890
|
-
url: "https://github.com/kyyinfinite/baileys",
|
|
891
|
-
displayName: "GitHub repository",
|
|
892
|
-
sourceDisplayName: "github.com",
|
|
893
|
-
},
|
|
894
|
-
],
|
|
895
|
-
quoted,
|
|
896
|
-
{
|
|
897
|
-
headerText: "@kyyinfinite/baileys",
|
|
898
|
-
footer: "Reference links",
|
|
899
|
-
searchEngine: "MAME",
|
|
900
|
-
}
|
|
901
|
-
);
|
|
902
|
-
```
|
|
293
|
+
Explicit mentions can also be supplied through the builder API.
|
|
903
294
|
|
|
904
|
-
|
|
295
|
+
------------------------------------------------------------------------
|
|
905
296
|
|
|
906
|
-
##
|
|
297
|
+
## JID Utilities
|
|
907
298
|
|
|
908
|
-
|
|
299
|
+
Parse a JID:
|
|
909
300
|
|
|
910
|
-
```js
|
|
911
|
-
|
|
912
|
-
albumMessage: [
|
|
913
|
-
{ image: { url: "./photo1.jpg" }, caption: "First photo 🌅" },
|
|
914
|
-
{ image: { url: "./photo2.jpg" }, caption: "Second photo 🌄" },
|
|
915
|
-
{ image: { url: "https://example.com/photo3.jpg" }, caption: "Remote photo 🌃" },
|
|
916
|
-
{ video: { url: "./clip.mp4" }, caption: "Bonus clip 🎬" },
|
|
917
|
-
],
|
|
918
|
-
});
|
|
301
|
+
``` js
|
|
302
|
+
sock.parseJid('628123456789:7@s.whatsapp.net')
|
|
919
303
|
```
|
|
920
304
|
|
|
921
|
-
|
|
922
|
-
> Albums automatically compute and set `expectedImageCount` and `expectedVideoCount`
|
|
923
|
-
> based on the array content. You do not need to set these manually.
|
|
305
|
+
Result:
|
|
924
306
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
All newsletter methods are available directly on the socket:
|
|
933
|
-
|
|
934
|
-
```js
|
|
935
|
-
// Follow a newsletter channel
|
|
936
|
-
await sock.newsletterFollow("123456789@newsletter");
|
|
937
|
-
|
|
938
|
-
// Unfollow a newsletter channel
|
|
939
|
-
await sock.newsletterUnfollow("123456789@newsletter");
|
|
940
|
-
|
|
941
|
-
// Create a new newsletter channel
|
|
942
|
-
await sock.newsletterCreate("My Channel", "Channel description");
|
|
943
|
-
|
|
944
|
-
// Update newsletter metadata
|
|
945
|
-
await sock.newsletterUpdate("123456789@newsletter", {
|
|
946
|
-
name: "Updated Channel Name",
|
|
947
|
-
description: "Updated description",
|
|
948
|
-
});
|
|
949
|
-
|
|
950
|
-
// React to a newsletter message
|
|
951
|
-
await sock.newsletterReactMessage("123456789@newsletter", serverId, "👍");
|
|
952
|
-
|
|
953
|
-
// Fetch recent newsletter messages
|
|
954
|
-
const msgs = await sock.newsletterFetchMessages("123456789@newsletter", 50, 0, 0);
|
|
955
|
-
|
|
956
|
-
// Fetch newsletter metadata
|
|
957
|
-
const meta = await sock.newsletterMetadata("123456789@newsletter");
|
|
958
|
-
|
|
959
|
-
// Admin: Mute/unmute newsletter
|
|
960
|
-
await sock.newsletterAdminMute("123456789@newsletter", true);
|
|
961
|
-
|
|
962
|
-
// Bulk follow multiple channels
|
|
963
|
-
await sock.newsletterBulkFollow([
|
|
964
|
-
"123456789@newsletter",
|
|
965
|
-
"987654321@newsletter",
|
|
966
|
-
]);
|
|
967
|
-
|
|
968
|
-
// Resolve newsletter URL
|
|
969
|
-
const resolved = await sock.newsletterResolveUrl("https://whatsapp.com/channel/xxxxx");
|
|
307
|
+
``` js
|
|
308
|
+
{
|
|
309
|
+
user: '628123456789',
|
|
310
|
+
device: '7',
|
|
311
|
+
server: 's.whatsapp.net',
|
|
312
|
+
jid: '628123456789:7@s.whatsapp.net'
|
|
313
|
+
}
|
|
970
314
|
```
|
|
971
315
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
## 👥 Group
|
|
975
|
-
|
|
976
|
-
Complete group management API:
|
|
316
|
+
Access individual parts:
|
|
977
317
|
|
|
978
|
-
```js
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
// Create a new group
|
|
984
|
-
const group = await sock.groupCreate("My New Group", [
|
|
985
|
-
"628111@s.whatsapp.net",
|
|
986
|
-
"628222@s.whatsapp.net",
|
|
987
|
-
]);
|
|
988
|
-
|
|
989
|
-
// Add / remove / promote / demote participants
|
|
990
|
-
await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "add");
|
|
991
|
-
await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "remove");
|
|
992
|
-
await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "promote");
|
|
993
|
-
await sock.groupParticipantsUpdate("groupid@g.us", ["628111@s.whatsapp.net"], "demote");
|
|
994
|
-
|
|
995
|
-
// Update group name / description
|
|
996
|
-
await sock.groupUpdateSubject("groupid@g.us", "New Group Name");
|
|
997
|
-
await sock.groupUpdateDescription("groupid@g.us", "New group description");
|
|
998
|
-
|
|
999
|
-
// Group settings
|
|
1000
|
-
await sock.groupSettingUpdate("groupid@g.us", "announcement"); // only admins send
|
|
1001
|
-
await sock.groupSettingUpdate("groupid@g.us", "not_announcement"); // everyone sends
|
|
1002
|
-
|
|
1003
|
-
// Toggle disappearing messages
|
|
1004
|
-
await sock.groupToggleEphemeral("groupid@g.us", 86400); // 24 hours; 0 to disable
|
|
1005
|
-
|
|
1006
|
-
// Get & reset invite link
|
|
1007
|
-
const code = await sock.groupInviteCode("groupid@g.us");
|
|
1008
|
-
await sock.groupRevokeInvite("groupid@g.us");
|
|
1009
|
-
|
|
1010
|
-
// Join via invite code
|
|
1011
|
-
await sock.groupAcceptInvite("INVITECODE");
|
|
1012
|
-
|
|
1013
|
-
// Leave a group
|
|
1014
|
-
await sock.groupLeave("groupid@g.us");
|
|
1015
|
-
|
|
1016
|
-
// Handle join requests
|
|
1017
|
-
await sock.groupRequestParticipantsList("groupid@g.us");
|
|
1018
|
-
await sock.groupRequestParticipantsUpdate("groupid@g.us", ["628xxx@s.whatsapp.net"], "approve");
|
|
1019
|
-
await sock.groupRequestParticipantsUpdate("groupid@g.us", ["628xxx@s.whatsapp.net"], "reject");
|
|
318
|
+
``` js
|
|
319
|
+
sock.jidUser(jid)
|
|
320
|
+
sock.jidServer(jid)
|
|
321
|
+
sock.jidDevice(jid)
|
|
1020
322
|
```
|
|
1021
323
|
|
|
1022
|
-
|
|
324
|
+
Normalize:
|
|
1023
325
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
```js
|
|
1027
|
-
// Create a community
|
|
1028
|
-
const community = await sock.communityCreate("Our Community", "Community description");
|
|
1029
|
-
|
|
1030
|
-
// Link an existing group to a community
|
|
1031
|
-
await sock.communityLinkGroup("groupid@g.us", "communityid@g.us");
|
|
1032
|
-
|
|
1033
|
-
// Unlink a group from a community
|
|
1034
|
-
await sock.communityUnlinkGroup("groupid@g.us", "communityid@g.us");
|
|
1035
|
-
|
|
1036
|
-
// Fetch all groups linked to a community
|
|
1037
|
-
const linked = await sock.communityFetchLinkedGroups("communityid@g.us");
|
|
1038
|
-
console.log(linked);
|
|
1039
|
-
|
|
1040
|
-
// Deactivate a community
|
|
1041
|
-
await sock.communityDeactivate("communityid@g.us");
|
|
1042
|
-
```
|
|
1043
|
-
|
|
1044
|
-
---
|
|
1045
|
-
|
|
1046
|
-
## 🏢 Business
|
|
1047
|
-
|
|
1048
|
-
```js
|
|
1049
|
-
// Fetch product catalog
|
|
1050
|
-
const { products } = await sock.getCatalog({
|
|
1051
|
-
jid: "628xxx@s.whatsapp.net",
|
|
1052
|
-
limit: 10,
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
// Create a product
|
|
1056
|
-
const product = await sock.productCreate({
|
|
1057
|
-
name: "Premium Package",
|
|
1058
|
-
description: "Full-featured premium plan",
|
|
1059
|
-
price: 150000,
|
|
1060
|
-
currency: "IDR",
|
|
1061
|
-
originCountryCode: "ID",
|
|
1062
|
-
isHidden: false,
|
|
1063
|
-
images: [mediaUpload],
|
|
1064
|
-
});
|
|
1065
|
-
|
|
1066
|
-
// Update a product
|
|
1067
|
-
await sock.productUpdate(productId, {
|
|
1068
|
-
name: "Premium Package Pro",
|
|
1069
|
-
price: 200000,
|
|
1070
|
-
});
|
|
1071
|
-
|
|
1072
|
-
// Delete products
|
|
1073
|
-
await sock.productDelete([productId]);
|
|
1074
|
-
|
|
1075
|
-
// Update business profile
|
|
1076
|
-
await sock.updateBusinessProfile({
|
|
1077
|
-
address: "Jakarta, Indonesia",
|
|
1078
|
-
websites: ["https://example.com"],
|
|
1079
|
-
email: "hello@example.com",
|
|
1080
|
-
category: "Technology",
|
|
1081
|
-
description: "WhatsApp bot services",
|
|
1082
|
-
});
|
|
1083
|
-
|
|
1084
|
-
// Fetch business profile
|
|
1085
|
-
const profile = await sock.getBusinessProfile("628xxx@s.whatsapp.net");
|
|
1086
|
-
console.log(profile);
|
|
326
|
+
``` js
|
|
327
|
+
sock.jid(jid)
|
|
1087
328
|
```
|
|
1088
329
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
## 👤 Profile
|
|
330
|
+
Create a JID:
|
|
1092
331
|
|
|
1093
|
-
```js
|
|
1094
|
-
|
|
1095
|
-
await sock.updateProfilePicture(jid, {
|
|
1096
|
-
url: "./avatar.jpg",
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
// Update display name
|
|
1100
|
-
await sock.updateProfileName("My New Name");
|
|
1101
|
-
|
|
1102
|
-
// Update status/about
|
|
1103
|
-
await sock.updateProfileStatus("🤖 Powered by @kyyinfinite/baileys");
|
|
1104
|
-
|
|
1105
|
-
// Fetch someone's profile picture
|
|
1106
|
-
const ppUrl = await sock.profilePictureUrl("628xxx@s.whatsapp.net", "image");
|
|
1107
|
-
console.log(ppUrl);
|
|
1108
|
-
|
|
1109
|
-
// Fetch your own profile
|
|
1110
|
-
const me = sock.user;
|
|
1111
|
-
console.log(me);
|
|
332
|
+
``` js
|
|
333
|
+
sock.makeJid('628123456789')
|
|
1112
334
|
```
|
|
1113
335
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
## 💬 Chat
|
|
336
|
+
JID checks:
|
|
1117
337
|
|
|
1118
|
-
```js
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
// Archive / unarchive chat
|
|
1127
|
-
await sock.chatModify({ archive: true, lastMessages: [msg] }, jid);
|
|
1128
|
-
await sock.chatModify({ archive: false, lastMessages: [msg] }, jid);
|
|
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)
|
|
345
|
+
```
|
|
1129
346
|
|
|
1130
|
-
|
|
1131
|
-
await sock.chatModify(
|
|
1132
|
-
{ mute: 8 * 60 * 60 * 1000 }, // mute for 8 hours (in ms)
|
|
1133
|
-
jid
|
|
1134
|
-
);
|
|
1135
|
-
await sock.chatModify({ mute: null }, jid); // unmute
|
|
347
|
+
------------------------------------------------------------------------
|
|
1136
348
|
|
|
1137
|
-
|
|
1138
|
-
await sock.chatModify({ pin: true }, jid);
|
|
1139
|
-
await sock.chatModify({ pin: false }, jid);
|
|
349
|
+
## Buttons
|
|
1140
350
|
|
|
1141
|
-
|
|
1142
|
-
await sock.chatModify({ delete: true, lastMessages: [msg] }, jid);
|
|
351
|
+
## Basic Button
|
|
1143
352
|
|
|
1144
|
-
|
|
1145
|
-
await sock
|
|
1146
|
-
|
|
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)
|
|
1147
361
|
```
|
|
1148
362
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
## 🔒 Privacy
|
|
363
|
+
## Reply
|
|
1152
364
|
|
|
1153
|
-
```js
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
// Online status visibility
|
|
1158
|
-
await sock.updateOnlinePrivacy("all"); // 'all' | 'match_last_seen'
|
|
365
|
+
``` js
|
|
366
|
+
sock.button()
|
|
367
|
+
.reply('Open', 'open')
|
|
368
|
+
```
|
|
1159
369
|
|
|
1160
|
-
|
|
1161
|
-
await sock.updateProfilePicturePrivacy("contacts"); // 'all' | 'contacts' | 'nobody'
|
|
370
|
+
Aliases:
|
|
1162
371
|
|
|
1163
|
-
|
|
1164
|
-
|
|
372
|
+
``` text
|
|
373
|
+
reply()
|
|
374
|
+
quickReply()
|
|
375
|
+
```
|
|
1165
376
|
|
|
1166
|
-
|
|
1167
|
-
await sock.updateGroupsAddPrivacy("all"); // 'all' | 'contacts' | 'contact_blacklist'
|
|
377
|
+
## URL
|
|
1168
378
|
|
|
1169
|
-
|
|
1170
|
-
|
|
379
|
+
``` js
|
|
380
|
+
sock.button()
|
|
381
|
+
.url('Website', 'https://example.com')
|
|
1171
382
|
```
|
|
1172
383
|
|
|
1173
|
-
|
|
384
|
+
## Copy
|
|
1174
385
|
|
|
1175
|
-
|
|
386
|
+
``` js
|
|
387
|
+
sock.button()
|
|
388
|
+
.copy('Copy Code', 'KYY-001')
|
|
389
|
+
```
|
|
1176
390
|
|
|
1177
|
-
|
|
391
|
+
Both aliases are supported:
|
|
1178
392
|
|
|
1179
|
-
```
|
|
1180
|
-
|
|
1181
|
-
|
|
393
|
+
``` text
|
|
394
|
+
copy()
|
|
395
|
+
coppy()
|
|
396
|
+
ctaCopy()
|
|
397
|
+
```
|
|
1182
398
|
|
|
1183
|
-
|
|
1184
|
-
sock.ev.on("creds.update", (update) => {});
|
|
399
|
+
## Call
|
|
1185
400
|
|
|
1186
|
-
|
|
1187
|
-
sock.
|
|
401
|
+
``` js
|
|
402
|
+
sock.button()
|
|
403
|
+
.call('Call', '628123456789')
|
|
404
|
+
```
|
|
1188
405
|
|
|
1189
|
-
|
|
1190
|
-
sock.ev.on("messages.update", (updates) => {});
|
|
406
|
+
Aliases:
|
|
1191
407
|
|
|
1192
|
-
|
|
1193
|
-
|
|
408
|
+
``` text
|
|
409
|
+
call()
|
|
410
|
+
ctaCall()
|
|
411
|
+
```
|
|
1194
412
|
|
|
1195
|
-
|
|
1196
|
-
sock.ev.on("messages.reaction", (reactions) => {});
|
|
413
|
+
Other button helpers:
|
|
1197
414
|
|
|
1198
|
-
|
|
1199
|
-
|
|
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()
|
|
430
|
+
```
|
|
1200
431
|
|
|
1201
|
-
|
|
1202
|
-
sock.ev.on("group-participants.update", ({ id, participants, action }) => {});
|
|
432
|
+
------------------------------------------------------------------------
|
|
1203
433
|
|
|
1204
|
-
|
|
1205
|
-
sock.ev.on("group.join-request", (update) => {});
|
|
434
|
+
## ButtonV2
|
|
1206
435
|
|
|
1207
|
-
|
|
1208
|
-
sock
|
|
436
|
+
``` js
|
|
437
|
+
await sock
|
|
438
|
+
.buttonV2()
|
|
439
|
+
.addButton(...)
|
|
440
|
+
.send(jid)
|
|
441
|
+
```
|
|
1209
442
|
|
|
1210
|
-
|
|
1211
|
-
sock.ev.on("chats.update", (updates) => {});
|
|
443
|
+
The builder also supports:
|
|
1212
444
|
|
|
1213
|
-
|
|
1214
|
-
|
|
445
|
+
``` text
|
|
446
|
+
addButton()
|
|
447
|
+
addRawButton()
|
|
448
|
+
setRawThumbnail()
|
|
449
|
+
setThumbnail()
|
|
450
|
+
setMedia()
|
|
451
|
+
loadFrom()
|
|
452
|
+
build()
|
|
453
|
+
send()
|
|
454
|
+
```
|
|
1215
455
|
|
|
1216
|
-
|
|
1217
|
-
sock.ev.on("contacts.upsert", (contacts) => {});
|
|
1218
|
-
sock.ev.on("contacts.update", (contacts) => {});
|
|
456
|
+
------------------------------------------------------------------------
|
|
1219
457
|
|
|
1220
|
-
|
|
1221
|
-
sock.ev.on("call", (calls) => {});
|
|
458
|
+
## Carousel
|
|
1222
459
|
|
|
1223
|
-
|
|
1224
|
-
sock.ev.on("newsletter.update", (updates) => {});
|
|
1225
|
-
sock.ev.on("newsletter.follow", (jid) => {});
|
|
460
|
+
Create multiple cards:
|
|
1226
461
|
|
|
1227
|
-
|
|
1228
|
-
sock
|
|
462
|
+
``` js
|
|
463
|
+
await sock
|
|
464
|
+
.carousel()
|
|
465
|
+
.body('Choose a product')
|
|
466
|
+
.footer('Kyyinfinite')
|
|
1229
467
|
|
|
1230
|
-
|
|
1231
|
-
|
|
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()
|
|
477
|
+
|
|
478
|
+
.card()
|
|
479
|
+
.image(image2)
|
|
480
|
+
.title('Product Two')
|
|
481
|
+
.body('Another product')
|
|
482
|
+
.button('Pilih', 'product_2')
|
|
483
|
+
.add()
|
|
484
|
+
|
|
485
|
+
.send(jid)
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Carousel methods:
|
|
489
|
+
|
|
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()
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
Card methods:
|
|
508
|
+
|
|
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()
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
------------------------------------------------------------------------
|
|
534
|
+
|
|
535
|
+
## Rich Messages
|
|
536
|
+
|
|
537
|
+
The advanced rich-message builder is available through:
|
|
538
|
+
|
|
539
|
+
``` js
|
|
540
|
+
await sock
|
|
541
|
+
.ai()
|
|
542
|
+
.title('Example')
|
|
543
|
+
.text('Rich message')
|
|
544
|
+
.code('console.log("Hello")')
|
|
545
|
+
.send(jid)
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
The rich builder supports composition features such as:
|
|
549
|
+
|
|
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
|
+
```
|
|
570
|
+
|
|
571
|
+
It also provides message/node management:
|
|
1232
572
|
|
|
1233
|
-
|
|
1234
|
-
|
|
573
|
+
``` text
|
|
574
|
+
delete()
|
|
575
|
+
assignId()
|
|
576
|
+
hasId()
|
|
577
|
+
getIds()
|
|
578
|
+
peek()
|
|
579
|
+
loadFrom()
|
|
580
|
+
build()
|
|
581
|
+
buildEdit()
|
|
582
|
+
send()
|
|
583
|
+
sendEdit()
|
|
1235
584
|
```
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
##
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
buildBotForwardedMessage,
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
tokenizeCode,
|
|
1270
|
-
tokenizeCodeV2,
|
|
1271
|
-
CodeHighlightType,
|
|
1272
|
-
RichSubMessageType,
|
|
1273
|
-
|
|
1274
|
-
//jid utils
|
|
1275
|
-
jidEncode,
|
|
1276
|
-
jidDecode,
|
|
1277
|
-
jidNormalizedUser,
|
|
1278
|
-
areJidsSameUser,
|
|
1279
|
-
isJidGroup,
|
|
1280
|
-
isJidNewsletter,
|
|
1281
|
-
isLidUser,
|
|
1282
|
-
isPnUser,
|
|
1283
|
-
isJidBot,
|
|
1284
|
-
|
|
1285
|
-
//consecution helper
|
|
1286
|
-
DisconnectReason,
|
|
1287
|
-
Browsers,
|
|
1288
|
-
|
|
1289
|
-
//advance
|
|
1290
|
-
Dugong,
|
|
1291
|
-
|
|
1292
|
-
} from "@kyyinfinite/baileys";
|
|
585
|
+
|
|
586
|
+
------------------------------------------------------------------------
|
|
587
|
+
|
|
588
|
+
## FOAD
|
|
589
|
+
|
|
590
|
+
``` js
|
|
591
|
+
await sock
|
|
592
|
+
.foad()
|
|
593
|
+
.addTitle('Example')
|
|
594
|
+
.addHtml('<p>Hello</p>')
|
|
595
|
+
.addTab(...)
|
|
596
|
+
.send(jid)
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Available operations include:
|
|
600
|
+
|
|
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()
|
|
1293
615
|
```
|
|
1294
616
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
## 📚 API Reference
|
|
1298
|
-
|
|
1299
|
-
### Socket Constructor Options
|
|
1300
|
-
|
|
1301
|
-
| Option | Type | Default | Description |
|
|
1302
|
-
|---|---|---|---|
|
|
1303
|
-
| `auth` | `AuthenticationState` | — | Auth state from `useMultiFileAuthState` |
|
|
1304
|
-
| `logger` | `Logger` | pino default | Logger instance (use `pino({ level: "silent" })`) |
|
|
1305
|
-
| `browser` | `WABrowserDescription` | — | Browser descriptor e.g. `Browsers.ubuntu("Chrome")` |
|
|
1306
|
-
| `version` | `WAVersion` | Latest | WhatsApp Web version tuple |
|
|
1307
|
-
| `connectTimeoutMs` | `number` | `20000` | Connection timeout in milliseconds |
|
|
1308
|
-
| `defaultQueryTimeoutMs` | `number` | `60000` | Default IQ query timeout |
|
|
1309
|
-
| `retryRequestDelayMs` | `number` | `250` | Delay between retries |
|
|
1310
|
-
| `maxMsgRetryCount` | `number` | `5` | Max message retry attempts |
|
|
1311
|
-
| `syncFullHistory` | `boolean` | `false` | Whether to sync full message history |
|
|
1312
|
-
| `enableAutoSessionRecreation` | `boolean` | `true` | Auto recreate session on failure |
|
|
1313
|
-
| `generateHighQualityLinkPreview` | `boolean` | `false` | Generate HQ link previews |
|
|
1314
|
-
| `qrTimeout` | `number` | `60000` | QR code expiry timeout in ms |
|
|
1315
|
-
|
|
1316
|
-
---
|
|
1317
|
-
|
|
1318
|
-
### Message Methods
|
|
1319
|
-
|
|
1320
|
-
| Method | Description | Returns |
|
|
1321
|
-
|---|---|---|
|
|
1322
|
-
| `sock.sendMessage(jid, content, opts?)` | Send any message type | `Promise<WAProto.WebMessageInfo>` |
|
|
1323
|
-
| `sock.sendTable(jid, title, headers, rows, quoted?, opts?)` | Send a styled table | `Promise<void>` |
|
|
1324
|
-
| `sock.sendTableV2(jid, title, headers, rows, quoted?, opts?)` | Send a V2 unified table | `Promise<void>` |
|
|
1325
|
-
| `sock.sendList(jid, title, rows, quoted?, opts?)` | Send a styled list | `Promise<void>` |
|
|
1326
|
-
| `sock.sendCodeBlock(jid, code, quoted?, opts?)` | Send V1 code block | `Promise<void>` |
|
|
1327
|
-
| `sock.sendCodeBlockV2(jid, code, quoted?, opts?)` | Send V2 unified code block | `Promise<void>` |
|
|
1328
|
-
| `sock.sendLink(jid, text, urls, quoted?, opts?)` | Send inline link message | `Promise<void>` |
|
|
1329
|
-
| `sock.sendLinkV2(jid, text, links, quoted?, opts?)` | Send V2 search-style links | `Promise<void>` |
|
|
1330
|
-
| `sock.sendUnifiedResponse(jid, text, quoted?, opts?)` | Send unified AI response | `Promise<void>` |
|
|
1331
|
-
|
|
1332
|
-
---
|
|
1333
|
-
|
|
1334
|
-
### Connection Methods
|
|
1335
|
-
|
|
1336
|
-
| Method | Description | Returns |
|
|
1337
|
-
|---|---|---|
|
|
1338
|
-
| `sock.requestPairingCode(phoneNumber, code?)` | Request or set pairing code | `Promise<string>` |
|
|
1339
|
-
| `sock.logout()` | Log out and invalidate session | `Promise<void>` |
|
|
1340
|
-
| `sock.end(error?)` | Close the socket connection | `void` |
|
|
1341
|
-
| `sock.waitForSocketOpen()` | Wait until socket is open | `Promise<void>` |
|
|
1342
|
-
| `sock.sendPresenceUpdate(presence, jid?)` | Set online/typing/recording status | `Promise<void>` |
|
|
1343
|
-
|
|
1344
|
-
---
|
|
1345
|
-
|
|
1346
|
-
### Group Methods
|
|
1347
|
-
|
|
1348
|
-
| Method | Description | Returns |
|
|
1349
|
-
|---|---|---|
|
|
1350
|
-
| `sock.groupMetadata(jid)` | Get group info | `Promise<GroupMetadata>` |
|
|
1351
|
-
| `sock.groupCreate(subject, participants)` | Create a new group | `Promise<GroupMetadata>` |
|
|
1352
|
-
| `sock.groupParticipantsUpdate(jid, participants, action)` | Add/remove/promote/demote | `Promise<ParticipantUpdate[]>` |
|
|
1353
|
-
| `sock.groupUpdateSubject(jid, subject)` | Change group name | `Promise<void>` |
|
|
1354
|
-
| `sock.groupUpdateDescription(jid, description)` | Change group description | `Promise<void>` |
|
|
1355
|
-
| `sock.groupSettingUpdate(jid, setting)` | Update group settings | `Promise<void>` |
|
|
1356
|
-
| `sock.groupToggleEphemeral(jid, expiration)` | Toggle disappearing messages | `Promise<void>` |
|
|
1357
|
-
| `sock.groupInviteCode(jid)` | Get invite link code | `Promise<string>` |
|
|
1358
|
-
| `sock.groupRevokeInvite(jid)` | Reset invite link | `Promise<string>` |
|
|
1359
|
-
| `sock.groupAcceptInvite(code)` | Join via invite code | `Promise<string>` |
|
|
1360
|
-
| `sock.groupLeave(jid)` | Leave a group | `Promise<void>` |
|
|
1361
|
-
|
|
1362
|
-
---
|
|
1363
|
-
|
|
1364
|
-
### Newsletter Methods
|
|
1365
|
-
|
|
1366
|
-
| Method | Description | Returns |
|
|
1367
|
-
|---|---|---|
|
|
1368
|
-
| `sock.newsletterFollow(jid)` | Follow a newsletter | `Promise<void>` |
|
|
1369
|
-
| `sock.newsletterUnfollow(jid)` | Unfollow a newsletter | `Promise<void>` |
|
|
1370
|
-
| `sock.newsletterCreate(name, desc)` | Create newsletter | `Promise<NewsletterMetadata>` |
|
|
1371
|
-
| `sock.newsletterUpdate(jid, metadata)` | Update newsletter info | `Promise<void>` |
|
|
1372
|
-
| `sock.newsletterReactMessage(jid, serverId, emoji)` | React to newsletter message | `Promise<void>` |
|
|
1373
|
-
| `sock.newsletterFetchMessages(jid, count, before, after)` | Fetch newsletter messages | `Promise<NewsletterMessage[]>` |
|
|
1374
|
-
| `sock.newsletterBulkFollow(jids)` | Follow multiple channels | `Promise<void>` |
|
|
1375
|
-
| `sock.newsletterMetadata(jid)` | Fetch channel metadata | `Promise<NewsletterMetadata>` |
|
|
1376
|
-
|
|
1377
|
-
---
|
|
1378
|
-
|
|
1379
|
-
## ❓ FAQ
|
|
1380
|
-
|
|
1381
|
-
<details>
|
|
1382
|
-
<summary><strong>Why is @kyyinfinite/baileys ESM-only?</strong></summary>
|
|
1383
|
-
|
|
1384
|
-
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.
|
|
1385
|
-
|
|
1386
|
-
If your project is still CommonJS, wrap the import dynamically:
|
|
1387
|
-
|
|
1388
|
-
```js
|
|
1389
|
-
const { default: makeWASocket } = await import("@kyyinfinite/baileys");
|
|
1390
|
-
```
|
|
617
|
+
------------------------------------------------------------------------
|
|
1391
618
|
|
|
1392
|
-
|
|
619
|
+
### FOAD2
|
|
1393
620
|
|
|
1394
|
-
|
|
621
|
+
``` js
|
|
622
|
+
await sock
|
|
623
|
+
.foad2()
|
|
624
|
+
...
|
|
625
|
+
```
|
|
1395
626
|
|
|
1396
|
-
|
|
1397
|
-
|
|
627
|
+
FOAD2 is exposed as a separate builder for its own response/composition
|
|
628
|
+
workflow.
|
|
1398
629
|
|
|
1399
|
-
|
|
630
|
+
------------------------------------------------------------------------
|
|
1400
631
|
|
|
1401
|
-
|
|
1402
|
-
sock.ev.on("connection.update", ({ connection, lastDisconnect }) => {
|
|
1403
|
-
if (connection === "close") {
|
|
1404
|
-
const code = lastDisconnect?.error?.output?.statusCode;
|
|
1405
|
-
if (code !== DisconnectReason.loggedOut) startBot();
|
|
1406
|
-
}
|
|
1407
|
-
});
|
|
1408
|
-
```
|
|
632
|
+
## createKyyinfinite
|
|
1409
633
|
|
|
1410
|
-
|
|
634
|
+
If you do not want to augment the socket directly:
|
|
1411
635
|
|
|
1412
|
-
|
|
636
|
+
``` js
|
|
637
|
+
const api = createKyyinfinite(sock)
|
|
1413
638
|
|
|
1414
|
-
|
|
1415
|
-
|
|
639
|
+
await api.text('Hello').send(jid)
|
|
640
|
+
```
|
|
1416
641
|
|
|
1417
|
-
|
|
1418
|
-
Phone number must include the country code without `+` (e.g. `6281234567890` for Indonesia).
|
|
642
|
+
This creates a facade without replacing the socket.
|
|
1419
643
|
|
|
1420
|
-
|
|
644
|
+
------------------------------------------------------------------------
|
|
1421
645
|
|
|
1422
|
-
|
|
646
|
+
## attachKyyinfinite
|
|
1423
647
|
|
|
1424
|
-
|
|
1425
|
-
<summary><strong>How do I persist authentication between restarts?</strong></summary>
|
|
648
|
+
For direct socket helpers:
|
|
1426
649
|
|
|
1427
|
-
|
|
650
|
+
``` js
|
|
651
|
+
attachKyyinfinite(sock)
|
|
1428
652
|
|
|
1429
|
-
|
|
1430
|
-
const { state, saveCreds } = await useMultiFileAuthState("./session");
|
|
1431
|
-
sock.ev.on("creds.update", saveCreds);
|
|
653
|
+
await sock.text('Hello').send(jid)
|
|
1432
654
|
```
|
|
1433
655
|
|
|
1434
|
-
|
|
656
|
+
The augmentation is additive. Existing socket methods are not
|
|
657
|
+
intentionally replaced when their names already exist.
|
|
1435
658
|
|
|
1436
|
-
|
|
659
|
+
------------------------------------------------------------------------
|
|
1437
660
|
|
|
1438
|
-
|
|
1439
|
-
<summary><strong>How do I deploy to a VPS or cloud?</strong></summary>
|
|
661
|
+
## API Overview
|
|
1440
662
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
663
|
+
``` text
|
|
664
|
+
Messaging
|
|
665
|
+
├── text()
|
|
666
|
+
├── send()
|
|
667
|
+
├── quoted()
|
|
668
|
+
├── reply()
|
|
669
|
+
├── wrapMessage()
|
|
670
|
+
├── parseMessage()
|
|
671
|
+
└── message actions
|
|
1445
672
|
|
|
1446
|
-
|
|
1447
|
-
|
|
673
|
+
Media
|
|
674
|
+
├── media()
|
|
675
|
+
├── image()
|
|
676
|
+
├── video()
|
|
677
|
+
├── audio()
|
|
678
|
+
├── voice()
|
|
679
|
+
├── document()
|
|
680
|
+
├── sticker()
|
|
681
|
+
├── ptv()
|
|
682
|
+
└── gif()
|
|
1448
683
|
|
|
1449
|
-
|
|
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()
|
|
1450
697
|
|
|
1451
|
-
|
|
1452
|
-
|
|
698
|
+
Interactive
|
|
699
|
+
├── button()
|
|
700
|
+
├── buttonV2()
|
|
701
|
+
└── carousel()
|
|
1453
702
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
const session2 = await useMultiFileAuthState("./sessions/bot2");
|
|
703
|
+
Advanced
|
|
704
|
+
├── ai()
|
|
705
|
+
├── foad()
|
|
706
|
+
└── foad2()
|
|
1459
707
|
```
|
|
1460
708
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
</details>
|
|
1464
|
-
|
|
1465
|
-
<details>
|
|
1466
|
-
<summary><strong>Interactive messages are not rendering. What's wrong?</strong></summary>
|
|
1467
|
-
|
|
1468
|
-
Interactive messages (flow buttons, carousels, list menus) require:
|
|
709
|
+
------------------------------------------------------------------------
|
|
1469
710
|
|
|
1470
|
-
|
|
1471
|
-
- A number that has been granted access to the interactive message API by WhatsApp.
|
|
711
|
+
## Design Goals
|
|
1472
712
|
|
|
1473
|
-
|
|
713
|
+
The API is built around a few principles:
|
|
1474
714
|
|
|
1475
|
-
|
|
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.
|
|
1476
724
|
|
|
1477
|
-
|
|
1478
|
-
<summary><strong>What is the difference from official Baileys?</strong></summary>
|
|
725
|
+
The main idea is:
|
|
1479
726
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
| AI Rich Response | Not available | ✅ Table, code block, rich text |
|
|
1485
|
-
| Table V2 | Not available | ✅ Unified response |
|
|
1486
|
-
| Code Block V2 | Not available | ✅ 6 languages |
|
|
1487
|
-
| Link Message | Not available | ✅ Inline embeds + citations |
|
|
1488
|
-
| Newsletter extras | Basic only | ✅ Bulk follow, URL resolve, admin |
|
|
1489
|
-
| Payment messages | Not supported | ✅ Full support |
|
|
1490
|
-
| Status mentions | Not available | ✅ `sendStatusMention()` |
|
|
1491
|
-
| LID support | Basic | ✅ Full LID↔PN mapping + migration |
|
|
1492
|
-
|
|
1493
|
-
</details>
|
|
727
|
+
``` text
|
|
728
|
+
Simple when you need it.
|
|
729
|
+
Advanced when you want it.
|
|
730
|
+
```
|
|
1494
731
|
|
|
1495
|
-
|
|
732
|
+
------------------------------------------------------------------------
|
|
1496
733
|
|
|
1497
|
-
|
|
1498
|
-
> 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
|
|
1499
735
|
|
|
1500
|
-
|
|
1501
|
-
> 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.
|
|
1502
737
|
|
|
1503
|
-
|
|
1504
|
-
|
|
738
|
+
``` ts
|
|
739
|
+
import { attachKyyinfinite } from '@kyyinfinite/baileys'
|
|
740
|
+
```
|
|
1505
741
|
|
|
1506
|
-
|
|
1507
|
-
|
|
742
|
+
The Simple API declarations cover the builder and convenience APIs
|
|
743
|
+
exposed by the package.
|
|
1508
744
|
|
|
1509
|
-
|
|
1510
|
-
> 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
|
+
------------------------------------------------------------------------
|
|
1511
746
|
|
|
1512
|
-
|
|
747
|
+
## Version
|
|
1513
748
|
|
|
1514
|
-
|
|
749
|
+
Current release:
|
|
1515
750
|
|
|
751
|
+
``` text
|
|
752
|
+
@kyyinfinite/baileys 2.1.0
|
|
1516
753
|
```
|
|
1517
|
-
MIT License
|
|
1518
|
-
|
|
1519
|
-
Copyright (c) 2026 kyyinfinite
|
|
1520
754
|
|
|
1521
|
-
|
|
1522
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
1523
|
-
in the Software without restriction, including without limitation the rights
|
|
1524
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1525
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
1526
|
-
furnished to do so, subject to the following conditions:
|
|
755
|
+
### What's new in 2.1.0
|
|
1527
756
|
|
|
1528
|
-
|
|
1529
|
-
|
|
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
|
|
1530
769
|
```
|
|
1531
770
|
|
|
1532
|
-
|
|
771
|
+
------------------------------------------------------------------------
|
|
1533
772
|
|
|
1534
|
-
|
|
773
|
+
## Roadmap
|
|
1535
774
|
|
|
1536
|
-
|
|
1537
|
-
[](https://github.com/kyyinfinite/baileys)
|
|
1538
|
-
[](https://github.com/kyyinfinite/baileys/stargazers)
|
|
775
|
+
Planned improvements:
|
|
1539
776
|
|
|
1540
|
-
|
|
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
|
|
1541
783
|
|
|
1542
|
-
|
|
784
|
+
------------------------------------------------------------------------
|
|
1543
785
|
|
|
1544
|
-
|
|
786
|
+
## Repository
|
|
1545
787
|
|
|
1546
|
-
|
|
788
|
+
urlGitHub Repositoryhttps://github.com/kyyinfinite/baileys
|
|
1547
789
|
|
|
1548
|
-
|
|
790
|
+
## License
|
|
1549
791
|
|
|
1550
|
-
|
|
792
|
+
MIT
|