@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.
Files changed (248) hide show
  1. package/README.md +582 -1340
  2. package/WAProto/WAProto.proto +360 -916
  3. package/WAProto/fix-imports.js +22 -18
  4. package/WAProto/index.d.ts +14015 -0
  5. package/WAProto/index.js +47122 -81757
  6. package/engine-requirements.js +10 -0
  7. package/lib/Defaults/index.d.ts +15 -14
  8. package/lib/Defaults/index.d.ts.map +1 -1
  9. package/lib/Defaults/index.js +99 -107
  10. package/lib/Defaults/index.js.map +1 -1
  11. package/lib/Kyyinfinite/AIRich.js +2041 -0
  12. package/lib/Kyyinfinite/BaseBuilder.js +64 -0
  13. package/lib/Kyyinfinite/Button.js +341 -0
  14. package/lib/Kyyinfinite/ButtonV2.js +175 -0
  15. package/lib/Kyyinfinite/Carousel.js +125 -0
  16. package/lib/Kyyinfinite/Foad.js +542 -0
  17. package/lib/Kyyinfinite/Foad2.js +466 -0
  18. package/lib/Kyyinfinite/Simple/AIBuilder.js +18 -0
  19. package/lib/Kyyinfinite/Simple/BuilderFactories.js +17 -0
  20. package/lib/Kyyinfinite/Simple/ButtonBuilder.js +107 -0
  21. package/lib/Kyyinfinite/Simple/CardBuilder.js +179 -0
  22. package/lib/Kyyinfinite/Simple/CarouselBuilder.js +97 -0
  23. package/lib/Kyyinfinite/Simple/FoadBuilder.js +18 -0
  24. package/lib/Kyyinfinite/Simple/KyyMessage.js +46 -0
  25. package/lib/Kyyinfinite/Simple/MediaBuilder.js +41 -0
  26. package/lib/Kyyinfinite/Simple/MessageBuilder.js +55 -0
  27. package/lib/Kyyinfinite/Simple/MessageTypesBuilder.js +3 -0
  28. package/lib/Kyyinfinite/Simple/SimpleBuilder.js +28 -0
  29. package/lib/Kyyinfinite/Simple/SimpleClient.js +120 -0
  30. package/lib/Kyyinfinite/Simple/TextBuilder.js +28 -0
  31. package/lib/Kyyinfinite/Simple/UniversalMediaBuilder.js +21 -0
  32. package/lib/Kyyinfinite/Simple/index.d.ts +232 -0
  33. package/lib/Kyyinfinite/Simple/index.js +38 -0
  34. package/lib/Kyyinfinite/Simple/jid.js +55 -0
  35. package/lib/Kyyinfinite/Simple/messageUtils.js +49 -0
  36. package/lib/Kyyinfinite/Simple/parseMessage.js +55 -0
  37. package/lib/Kyyinfinite/Toolkit.js +453 -0
  38. package/lib/Kyyinfinite/constants.js +1 -0
  39. package/lib/Kyyinfinite/errors.js +39 -0
  40. package/lib/Kyyinfinite/index.d.ts +2 -0
  41. package/lib/Kyyinfinite/index.js +2 -0
  42. package/lib/Kyyinfinite/wrapper.d.ts +2 -0
  43. package/lib/Kyyinfinite/wrapper.js +10 -0
  44. package/lib/Signal/Group/group_cipher.js.map +1 -1
  45. package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
  46. package/lib/Signal/Group/keyhelper.js.map +1 -1
  47. package/lib/Signal/Group/sender-chain-key.js.map +1 -1
  48. package/lib/Signal/Group/sender-key-message.js.map +1 -1
  49. package/lib/Signal/Group/sender-message-key.js.map +1 -1
  50. package/lib/Signal/libsignal.d.ts.map +1 -1
  51. package/lib/Signal/libsignal.js +45 -17
  52. package/lib/Signal/libsignal.js.map +1 -1
  53. package/lib/Signal/lid-mapping.d.ts +4 -0
  54. package/lib/Signal/lid-mapping.d.ts.map +1 -1
  55. package/lib/Signal/lid-mapping.js +6 -0
  56. package/lib/Signal/lid-mapping.js.map +1 -1
  57. package/lib/Socket/business.d.ts +213 -532
  58. package/lib/Socket/business.d.ts.map +1 -1
  59. package/lib/Socket/business.js +358 -401
  60. package/lib/Socket/chats.d.ts +16 -2
  61. package/lib/Socket/chats.d.ts.map +1 -1
  62. package/lib/Socket/chats.js +247 -40
  63. package/lib/Socket/chats.js.map +1 -1
  64. package/lib/Socket/communities.d.ts +269 -641
  65. package/lib/Socket/communities.d.ts.map +1 -1
  66. package/lib/Socket/groups.d.ts +13 -2
  67. package/lib/Socket/groups.d.ts.map +1 -1
  68. package/lib/Socket/groups.js +21 -1
  69. package/lib/Socket/groups.js.map +1 -1
  70. package/lib/Socket/index.d.ts +255 -631
  71. package/lib/Socket/index.d.ts.map +1 -1
  72. package/lib/Socket/index.js +9 -10
  73. package/lib/Socket/index.js.map +1 -1
  74. package/lib/Socket/messages-recv.d.ts +23 -58
  75. package/lib/Socket/messages-recv.d.ts.map +1 -1
  76. package/lib/Socket/messages-recv.js +645 -181
  77. package/lib/Socket/messages-recv.js.map +1 -1
  78. package/lib/Socket/messages-send.d.ts +195 -575
  79. package/lib/Socket/messages-send.d.ts.map +1 -1
  80. package/lib/Socket/messages-send.js +1099 -1549
  81. package/lib/Socket/messages-send.js.map +1 -1
  82. package/lib/Socket/mex.d.ts.map +1 -1
  83. package/lib/Socket/mex.js +2 -8
  84. package/lib/Socket/mex.js.map +1 -1
  85. package/lib/Socket/newsletter.d.ts +11 -18
  86. package/lib/Socket/newsletter.d.ts.map +1 -1
  87. package/lib/Socket/newsletter.js +167 -302
  88. package/lib/Socket/newsletter.js.map +1 -1
  89. package/lib/Socket/socket.d.ts +6 -2
  90. package/lib/Socket/socket.d.ts.map +1 -1
  91. package/lib/Socket/socket.js +59 -25
  92. package/lib/Socket/socket.js.map +1 -1
  93. package/lib/Types/Auth.d.ts +1 -0
  94. package/lib/Types/Auth.d.ts.map +1 -1
  95. package/lib/Types/Bussines.d.ts +22 -34
  96. package/lib/Types/Call.d.ts +1 -1
  97. package/lib/Types/Call.d.ts.map +1 -1
  98. package/lib/Types/Chat.d.ts +1 -0
  99. package/lib/Types/Chat.d.ts.map +1 -1
  100. package/lib/Types/Contact.d.ts +2 -0
  101. package/lib/Types/Contact.d.ts.map +1 -1
  102. package/lib/Types/Events.d.ts +20 -1
  103. package/lib/Types/Events.d.ts.map +1 -1
  104. package/lib/Types/GroupMetadata.d.ts +4 -1
  105. package/lib/Types/GroupMetadata.d.ts.map +1 -1
  106. package/lib/Types/Message.d.ts +239 -341
  107. package/lib/Types/Message.d.ts.map +1 -1
  108. package/lib/Types/Message.js.map +1 -1
  109. package/lib/Types/{Newsletter.d.ts → Mex.d.ts} +11 -5
  110. package/lib/Types/Mex.d.ts.map +1 -0
  111. package/lib/Types/{Newsletter.js → Mex.js} +9 -3
  112. package/lib/Types/Mex.js.map +1 -0
  113. package/lib/Types/Signal.d.ts +12 -1
  114. package/lib/Types/Signal.d.ts.map +1 -1
  115. package/lib/Types/Socket.d.ts +126 -148
  116. package/lib/Types/Socket.d.ts.map +1 -1
  117. package/lib/Types/State.d.ts +58 -0
  118. package/lib/Types/State.d.ts.map +1 -1
  119. package/lib/Types/State.js +43 -0
  120. package/lib/Types/State.js.map +1 -1
  121. package/lib/Types/index.d.ts +52 -52
  122. package/lib/Types/index.d.ts.map +1 -1
  123. package/lib/Types/index.js +23 -30
  124. package/lib/Types/index.js.map +1 -1
  125. package/lib/Utils/auth-utils.d.ts +5 -0
  126. package/lib/Utils/auth-utils.d.ts.map +1 -1
  127. package/lib/Utils/auth-utils.js +12 -0
  128. package/lib/Utils/auth-utils.js.map +1 -1
  129. package/lib/Utils/browser-utils.d.ts.map +1 -1
  130. package/lib/Utils/browser-utils.js +1 -0
  131. package/lib/Utils/browser-utils.js.map +1 -1
  132. package/lib/Utils/chat-utils.d.ts +34 -4
  133. package/lib/Utils/chat-utils.d.ts.map +1 -1
  134. package/lib/Utils/chat-utils.js +80 -20
  135. package/lib/Utils/chat-utils.js.map +1 -1
  136. package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
  137. package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
  138. package/lib/Utils/companion-reg-client-utils.js +35 -0
  139. package/lib/Utils/companion-reg-client-utils.js.map +1 -0
  140. package/lib/Utils/crypto.d.ts +12 -12
  141. package/lib/Utils/crypto.d.ts.map +1 -1
  142. package/lib/Utils/crypto.js.map +1 -1
  143. package/lib/Utils/decode-wa-message.d.ts +18 -0
  144. package/lib/Utils/decode-wa-message.d.ts.map +1 -1
  145. package/lib/Utils/decode-wa-message.js +34 -0
  146. package/lib/Utils/decode-wa-message.js.map +1 -1
  147. package/lib/Utils/event-buffer.d.ts +2 -0
  148. package/lib/Utils/event-buffer.d.ts.map +1 -1
  149. package/lib/Utils/event-buffer.js +49 -1
  150. package/lib/Utils/event-buffer.js.map +1 -1
  151. package/lib/Utils/generics.d.ts +3 -2
  152. package/lib/Utils/generics.d.ts.map +1 -1
  153. package/lib/Utils/generics.js +10 -1
  154. package/lib/Utils/generics.js.map +1 -1
  155. package/lib/Utils/history.d.ts +2 -0
  156. package/lib/Utils/history.d.ts.map +1 -1
  157. package/lib/Utils/history.js +12 -9
  158. package/lib/Utils/history.js.map +1 -1
  159. package/lib/Utils/identity-change-handler.d.ts +7 -0
  160. package/lib/Utils/identity-change-handler.d.ts.map +1 -1
  161. package/lib/Utils/identity-change-handler.js +1 -0
  162. package/lib/Utils/identity-change-handler.js.map +1 -1
  163. package/lib/Utils/index.d.ts +22 -25
  164. package/lib/Utils/index.d.ts.map +1 -1
  165. package/lib/Utils/index.js +2 -4
  166. package/lib/Utils/index.js.map +1 -1
  167. package/lib/Utils/link-preview.js +2 -2
  168. package/lib/Utils/link-preview.js.map +1 -1
  169. package/lib/Utils/logger.d.ts +1 -2
  170. package/lib/Utils/logger.d.ts.map +1 -1
  171. package/lib/Utils/message-retry-manager.d.ts +5 -0
  172. package/lib/Utils/message-retry-manager.d.ts.map +1 -1
  173. package/lib/Utils/message-retry-manager.js +40 -0
  174. package/lib/Utils/message-retry-manager.js.map +1 -1
  175. package/lib/Utils/messages-media.d.ts +16 -13
  176. package/lib/Utils/messages-media.d.ts.map +1 -1
  177. package/lib/Utils/messages-media.js +85 -79
  178. package/lib/Utils/messages-media.js.map +1 -1
  179. package/lib/Utils/messages.d.ts +1 -1
  180. package/lib/Utils/messages.d.ts.map +1 -1
  181. package/lib/Utils/messages.js +751 -1096
  182. package/lib/Utils/messages.js.map +1 -1
  183. package/lib/Utils/noise-handler.d.ts +1 -1
  184. package/lib/Utils/process-message.d.ts.map +1 -1
  185. package/lib/Utils/process-message.js +103 -1
  186. package/lib/Utils/process-message.js.map +1 -1
  187. package/lib/Utils/signal.d.ts +13 -0
  188. package/lib/Utils/signal.d.ts.map +1 -1
  189. package/lib/Utils/signal.js +42 -0
  190. package/lib/Utils/signal.js.map +1 -1
  191. package/lib/Utils/sync-action-utils.d.ts.map +1 -1
  192. package/lib/Utils/sync-action-utils.js +1 -0
  193. package/lib/Utils/sync-action-utils.js.map +1 -1
  194. package/lib/Utils/tc-token-utils.d.ts +26 -1
  195. package/lib/Utils/tc-token-utils.d.ts.map +1 -1
  196. package/lib/Utils/tc-token-utils.js +151 -5
  197. package/lib/Utils/tc-token-utils.js.map +1 -1
  198. package/lib/Utils/validate-connection.d.ts.map +1 -1
  199. package/lib/Utils/validate-connection.js +12 -2
  200. package/lib/Utils/validate-connection.js.map +1 -1
  201. package/lib/WABinary/decode.d.ts +1 -1
  202. package/lib/WABinary/decode.d.ts.map +1 -1
  203. package/lib/WABinary/generic-utils.d.ts +1 -3
  204. package/lib/WABinary/generic-utils.d.ts.map +1 -1
  205. package/lib/WABinary/generic-utils.js +0 -78
  206. package/lib/WABinary/generic-utils.js.map +1 -1
  207. package/lib/WAM/encode.d.ts +1 -1
  208. package/lib/WAM/encode.d.ts.map +1 -1
  209. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
  210. package/lib/WAUSync/Protocols/USyncContactProtocol.js +26 -3
  211. package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
  212. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  213. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
  214. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  215. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
  216. package/lib/WAUSync/Protocols/index.d.ts +1 -0
  217. package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
  218. package/lib/WAUSync/Protocols/index.js +1 -0
  219. package/lib/WAUSync/Protocols/index.js.map +1 -1
  220. package/lib/WAUSync/USyncQuery.d.ts +1 -0
  221. package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
  222. package/lib/WAUSync/USyncQuery.js +6 -2
  223. package/lib/WAUSync/USyncQuery.js.map +1 -1
  224. package/lib/WAUSync/USyncUser.d.ts +4 -0
  225. package/lib/WAUSync/USyncUser.d.ts.map +1 -1
  226. package/lib/WAUSync/USyncUser.js +8 -0
  227. package/lib/WAUSync/USyncUser.js.map +1 -1
  228. package/lib/index.d.ts +3 -2
  229. package/lib/index.d.ts.map +1 -1
  230. package/lib/index.js +13 -12
  231. package/lib/index.js.map +1 -1
  232. package/package.json +104 -23
  233. package/test/core.test.js +38 -0
  234. package/test/simple-api.test.js +183 -0
  235. package/lib/Socket/dugong.d.ts +0 -130
  236. package/lib/Socket/dugong.d.ts.map +0 -1
  237. package/lib/Socket/dugong.js +0 -768
  238. package/lib/Socket/dugong.js.map +0 -1
  239. package/lib/Types/Newsletter.d.ts.map +0 -1
  240. package/lib/Types/Newsletter.js.map +0 -1
  241. package/lib/Utils/kyy-features.d.ts +0 -158
  242. package/lib/Utils/kyy-features.js +0 -365
  243. package/lib/Utils/rich-messages.d.ts +0 -277
  244. package/lib/Utils/rich-messages.d.ts.map +0 -1
  245. package/lib/Utils/rich-messages.js +0 -1144
  246. package/lib/Utils/rich-messages.js.map +0 -1
  247. package/lib/Utils/sticker-pack.d.ts +0 -10
  248. package/lib/Utils/sticker-pack.js +0 -111
package/README.md CHANGED
@@ -1,1550 +1,792 @@
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+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
- [![npm version](https://img.shields.io/badge/npm-v0.1.0-CB3837?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@kyyinfinite/baileys)
8
- [![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)
9
- [![License](https://img.shields.io/badge/license-MIT-green?style=for-the-badge)](LICENSE)
10
- [![Node.js](https://img.shields.io/badge/node-%3E%3D20.0.0-339933?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org)
11
- [![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)
12
- [![TypeScript](https://img.shields.io/badge/TypeScript-ready-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
13
- [![GitHub](https://img.shields.io/badge/GitHub-kyyinfinite-181717?style=for-the-badge&logo=github&logoColor=white)](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
- **pnpm**
154
- ```bash
155
- pnpm add @kyyinfinite/baileys
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
- **yarn**
159
- ```bash
160
- yarn add @kyyinfinite/baileys
161
- ```
7
+ ## Installation
162
8
 
163
- **bun**
164
- ```bash
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
- > [!TIP]
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
- ## 🚀 Quick Start
18
+ const sock = makeWASocket(config)
179
19
 
180
- ### 1. Project Setup
20
+ attachKyyinfinite(sock)
181
21
 
182
- ```bash
183
- mkdir my-bot && cd my-bot
184
- npm init -y
22
+ await sock
23
+ .text('Hello')
24
+ .send(jid)
185
25
  ```
186
26
 
187
- Open `package.json` and add `"type": "module"`:
27
+ The API is designed to keep common operations short while still allowing
28
+ advanced message builders when needed.
188
29
 
189
- ```json
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
- > [!IMPORTANT]
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
- ### 2. Install Dependencies
208
-
209
- ```bash
210
- npm install @kyyinfinite/baileys pino qrcode-terminal
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
- startBot();
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
- ### 4. Run & QR Code Login
277
-
278
- ```bash
279
- node index.js
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
- Scan the QR code in your terminal using **WhatsApp → Linked Devices → Link a Device**.
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
- ```js
292
- import makeWASocket, {
293
- useMultiFileAuthState,
294
- Browsers,
295
- } from "@kyyinfinite/baileys";
296
- import pino from "pino";
68
+ # Media
297
69
 
298
- const logger = pino({ level: "silent" });
70
+ Shortcut builders:
299
71
 
300
- async function startBot() {
301
- const { state, saveCreds } = await useMultiFileAuthState("./session");
72
+ ``` js
73
+ await sock.image('./image.jpg')
74
+ .caption('Image')
75
+ .send(jid)
302
76
 
303
- const sock = makeWASocket({
304
- auth: state,
305
- logger,
306
- browser: Browsers.windows("Chrome"),
307
- });
77
+ await sock.video('./video.mp4')
78
+ .caption('Video')
79
+ .send(jid)
308
80
 
309
- sock.ev.on("creds.update", saveCreds);
81
+ await sock.audio('./audio.mp3')
82
+ .send(jid)
310
83
 
311
- sock.ev.on("connection.update", async ({ connection }) => {
312
- if (connection === "connecting") {
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
- if (connection === "open") {
319
- console.log("✅ Connected via pairing code!");
320
- }
321
- });
322
- }
87
+ await sock.document('./file.pdf')
88
+ .fileName('document.pdf')
89
+ .send(jid)
323
90
 
324
- startBot();
91
+ await sock.sticker('./sticker.webp')
92
+ .send(jid)
325
93
  ```
326
94
 
327
- **Custom pairing code (exactly 8 characters):**
95
+ Other media shortcuts:
328
96
 
329
- ```js
330
- const code = await sock.requestPairingCode("6281234567890", "A1B2C3D4");
331
- console.log("🔑 Custom pairing code:", code);
97
+ ``` text
98
+ ptv()
99
+ gif()
332
100
  ```
333
101
 
334
- > [!WARNING]
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
- console.log(`Connection closed (code: ${statusCode}). Reconnecting: ${shouldReconnect}`);
104
+ Use one builder when the media type needs to be selected dynamically:
352
105
 
353
- if (shouldReconnect) {
354
- startBot(); // call your startBot function again
355
- } else {
356
- console.log("Logged out. Delete ./session and restart.");
357
- }
358
- }
359
- });
106
+ ``` js
107
+ await sock
108
+ .media(buffer)
109
+ .asImage()
110
+ .caption('Photo')
111
+ .send(jid)
360
112
  ```
361
113
 
362
- > [!TIP]
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
- ```js
372
- await sock.sendMessage(jid, { text: "Hello, World! 👋" });
116
+ ``` text
117
+ asImage()
118
+ asVideo()
119
+ asAudio()
120
+ asDocument()
121
+ asSticker()
373
122
  ```
374
123
 
375
- ### Image
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
- ### Audio & PTT
409
-
410
- ```js
411
- // Audio file
412
- await sock.sendMessage(jid, {
413
- audio: { url: "./audio.mp3" },
414
- mimetype: "audio/mp4",
415
- });
416
-
417
- // Push-to-talk (voice note)
418
- await sock.sendMessage(jid, {
419
- audio: { url: "./voice.ogg" },
420
- mimetype: "audio/ogg; codecs=opus",
421
- ptt: true,
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
- ### Sticker
146
+ ------------------------------------------------------------------------
426
147
 
427
- ```js
428
- await sock.sendMessage(jid, {
429
- sticker: { url: "./sticker.webp" },
430
- });
431
- ```
148
+ ## Unified Send
432
149
 
433
- ### Document
150
+ For simple messages, use:
434
151
 
435
- ```js
436
- await sock.sendMessage(jid, {
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
- ### Location
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
- ### Contact
458
-
459
- ```js
460
- await sock.sendMessage(jid, {
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
- ### Poll
164
+ Media:
473
165
 
474
- ```js
475
- await sock.sendMessage(jid, {
476
- poll: {
477
- name: "What's your favorite language?",
478
- values: ["JavaScript", "TypeScript", "Python", "Go"],
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
- ### Reaction
173
+ The unified API is intended for cases where you do not need to manually
174
+ create a builder.
485
175
 
486
- ```js
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
- ### Delete & Edit
178
+ ## Quoted Messages
496
179
 
497
- ```js
498
- // Delete a message (for everyone)
499
- await sock.sendMessage(jid, { delete: msg.key });
180
+ Reply directly to an existing message:
500
181
 
501
- // Edit a sent message
502
- await sock.sendMessage(jid, {
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
- ### Forward & Quoted
509
-
510
- ```js
511
- // Forward a message
512
- await sock.sendMessage(jid, { forward: msg });
186
+ Or:
513
187
 
514
- // Reply (quoted message)
515
- await sock.sendMessage(
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
- ### Mention
192
+ Message wrapper:
523
193
 
524
- ```js
525
- await sock.sendMessage(jid, {
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
- ### Context Info
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
- ### CTA URL Button
579
-
580
- ```js
581
- await sock.sendMessage(jid, {
582
- interactiveMessage: {
583
- title: "Visit our website",
584
- footer: "Powered by @kyyinfinite/baileys",
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
- ### Copy Button
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
- ### List Menu (single_select)
622
-
623
- ```js
624
- await sock.sendMessage(jid, {
625
- interactiveMessage: {
626
- title: "Select a Category",
627
- footer: "Powered by @kyyinfinite/baileys",
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
- ### Carousel
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
- ### Native Interactive
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
- ## 🤖 AI Rich Response
226
+ Parse an incoming message into a simple object:
735
227
 
736
- > [!NOTE]
737
- > These message types are styled to match **Meta AI's** WhatsApp response format — tables, code blocks, and rich linked text.
738
- > They are exclusive to `@kyyinfinite/baileys` and not available in official Baileys.
228
+ ``` js
229
+ const parsed = sock.parseMessage(message, {
230
+ prefix: '.'
231
+ })
739
232
 
740
- ### sendTable()
741
-
742
- ```js
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
- ### sendList()
238
+ Returned data includes:
763
239
 
764
- ```js
765
- await sock.sendList(
766
- jid,
767
- "Bot Information",
768
- [
769
- ["Package", "@kyyinfinite/baileys"],
770
- ["Version", "0.1.0"],
771
- ["Developer", "kyyinfinite"],
772
- ["License", "MIT"],
773
- ["Node", ">= 20"],
774
- ],
775
- quoted,
776
- { footer: "© 2026 kyyinfinite" }
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
- ### sendCodeBlock()
781
-
782
- V1 supports: `javascript`, `typescript`, `python`
255
+ Example command:
783
256
 
784
- ```js
785
- await sock.sendCodeBlock(
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
- ### sendLink()
261
+ can be consumed as:
798
262
 
799
- ```js
800
- await sock.sendLink(
801
- jid,
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
- ### sendUnifiedResponse()
268
+ ------------------------------------------------------------------------
814
269
 
815
- ```js
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
- ### sendTableV2()
272
+ Text containing a WhatsApp-style number can be resolved automatically:
828
273
 
829
- ```js
830
- await sock.sendTableV2(
274
+ ``` js
275
+ await sock.send(
831
276
  jid,
832
- "Framework Comparison",
833
- ["Framework", "Language", "Use Case"],
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
- ### sendCodeBlockV2()
281
+ Disable automatic mention resolution when required:
850
282
 
851
- V2 supports: `javascript` / `js` / `typescript` / `ts`, `python` / `py`, `go` / `golang`, `lua`, `bash` / `sh` / `shell`
852
-
853
- ```js
854
- await sock.sendCodeBlockV2(
283
+ ``` js
284
+ await sock.send(
855
285
  jid,
856
- `func main() {\n fmt.Println("Hello, @kyyinfinite/baileys!")\n}`,
857
- quoted,
286
+ 'Hello @628123456789',
858
287
  {
859
- language: "go",
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
- **All supported V2 languages:**
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
- ## 🎞️ Album Messages
297
+ ## JID Utilities
907
298
 
908
- Send multiple images and/or videos as a grouped album in a single message:
299
+ Parse a JID:
909
300
 
910
- ```js
911
- await sock.sendMessage(jid, {
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
- > [!NOTE]
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
- > [!TIP]
926
- > You can mix images and videos freely inside an album. Albums support both local file paths and remote URLs.
927
-
928
- ---
929
-
930
- ## 📰 Newsletter
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
- // Fetch group metadata
980
- const meta = await sock.groupMetadata("groupid@g.us");
981
- console.log(meta.subject, meta.participants);
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
- ## 🏘️ Community
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
- // Update profile picture
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
- // Mark messages as read
1120
- await sock.readMessages([msg.key]);
1121
-
1122
- // Star / unstar messages
1123
- await sock.star(jid, [{ id: msgId, fromMe: true }], true); // star
1124
- await sock.star(jid, [{ id: msgId, fromMe: true }], false); // unstar
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
- // Mute / unmute chat
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
- // Pin / unpin chat
1138
- await sock.chatModify({ pin: true }, jid);
1139
- await sock.chatModify({ pin: false }, jid);
349
+ ## Buttons
1140
350
 
1141
- // Delete chat
1142
- await sock.chatModify({ delete: true, lastMessages: [msg] }, jid);
351
+ ## Basic Button
1143
352
 
1144
- // Block / unblock a user
1145
- await sock.updateBlockStatus(jid, "block");
1146
- await sock.updateBlockStatus(jid, "unblock");
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
- // Last seen visibility
1155
- await sock.updateLastSeenPrivacy("all"); // 'all' | 'contacts' | 'nobody'
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
- // Profile picture visibility
1161
- await sock.updateProfilePicturePrivacy("contacts"); // 'all' | 'contacts' | 'nobody'
370
+ Aliases:
1162
371
 
1163
- // Read receipts (blue ticks)
1164
- await sock.updateReadReceiptsPrivacy("all"); // 'all' | 'none'
372
+ ``` text
373
+ reply()
374
+ quickReply()
375
+ ```
1165
376
 
1166
- // Who can add you to groups
1167
- await sock.updateGroupsAddPrivacy("all"); // 'all' | 'contacts' | 'contact_blacklist'
377
+ ## URL
1168
378
 
1169
- // Default disappearing message timer
1170
- await sock.updateDefaultDisappearingMode(86400); // seconds; 0 to disable
379
+ ``` js
380
+ sock.button()
381
+ .url('Website', 'https://example.com')
1171
382
  ```
1172
383
 
1173
- ---
384
+ ## Copy
1174
385
 
1175
- ## 📡 Events
386
+ ``` js
387
+ sock.button()
388
+ .copy('Copy Code', 'KYY-001')
389
+ ```
1176
390
 
1177
- Listen to all socket events via `sock.ev.on(...)`:
391
+ Both aliases are supported:
1178
392
 
1179
- ```js
1180
- // Connection state changes (open, close, connecting)
1181
- sock.ev.on("connection.update", ({ connection, lastDisconnect, qr, isNewLogin }) => {});
393
+ ``` text
394
+ copy()
395
+ coppy()
396
+ ctaCopy()
397
+ ```
1182
398
 
1183
- // Credentials updated — always save
1184
- sock.ev.on("creds.update", (update) => {});
399
+ ## Call
1185
400
 
1186
- // New / updated messages
1187
- sock.ev.on("messages.upsert", ({ messages, type }) => {});
401
+ ``` js
402
+ sock.button()
403
+ .call('Call', '628123456789')
404
+ ```
1188
405
 
1189
- // Message edits / status updates
1190
- sock.ev.on("messages.update", (updates) => {});
406
+ Aliases:
1191
407
 
1192
- // Messages deleted
1193
- sock.ev.on("messages.delete", (keys) => {});
408
+ ``` text
409
+ call()
410
+ ctaCall()
411
+ ```
1194
412
 
1195
- // Reactions on messages
1196
- sock.ev.on("messages.reaction", (reactions) => {});
413
+ Other button helpers:
1197
414
 
1198
- // Group metadata updates (subject, description, settings)
1199
- sock.ev.on("groups.update", (updates) => {});
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
- // Participants added/removed/promoted/demoted
1202
- sock.ev.on("group-participants.update", ({ id, participants, action }) => {});
432
+ ------------------------------------------------------------------------
1203
433
 
1204
- // Join request received in a group
1205
- sock.ev.on("group.join-request", (update) => {});
434
+ ## ButtonV2
1206
435
 
1207
- // New or updated chats
1208
- sock.ev.on("chats.upsert", (chats) => {});
436
+ ``` js
437
+ await sock
438
+ .buttonV2()
439
+ .addButton(...)
440
+ .send(jid)
441
+ ```
1209
442
 
1210
- // Chat updates (archive, mute, pin, etc.)
1211
- sock.ev.on("chats.update", (updates) => {});
443
+ The builder also supports:
1212
444
 
1213
- // Chats deleted
1214
- sock.ev.on("chats.delete", (ids) => {});
445
+ ``` text
446
+ addButton()
447
+ addRawButton()
448
+ setRawThumbnail()
449
+ setThumbnail()
450
+ setMedia()
451
+ loadFrom()
452
+ build()
453
+ send()
454
+ ```
1215
455
 
1216
- // Contacts synced or updated
1217
- sock.ev.on("contacts.upsert", (contacts) => {});
1218
- sock.ev.on("contacts.update", (contacts) => {});
456
+ ------------------------------------------------------------------------
1219
457
 
1220
- // Incoming calls
1221
- sock.ev.on("call", (calls) => {});
458
+ ## Carousel
1222
459
 
1223
- // Newsletter events
1224
- sock.ev.on("newsletter.update", (updates) => {});
1225
- sock.ev.on("newsletter.follow", (jid) => {});
460
+ Create multiple cards:
1226
461
 
1227
- // Privacy/settings updates
1228
- sock.ev.on("settings.update", (settings) => {});
462
+ ``` js
463
+ await sock
464
+ .carousel()
465
+ .body('Choose a product')
466
+ .footer('Kyyinfinite')
1229
467
 
1230
- // Message history sync (on first connect)
1231
- sock.ev.on("messaging-history.set", ({ chats, contacts, messages, isLatest }) => {});
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
- // Blocklist updates
1234
- sock.ev.on("blocklist.update", ({ blocklist, type }) => {});
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
- ## 🔧 Utility Exports
1240
-
1241
- All named exports available from `@kyyinfinite/baileys`:
1242
-
1243
- ```js
1244
- import {
1245
- //auth
1246
- useMultiFileAuthState,
1247
- makeCacheableSignalKeyStore,
1248
- initAuthCreds,
1249
- BufferJSON,
1250
- fetchLatestBaileysVersion,
1251
-
1252
- //rich message
1253
- generateTableContent,
1254
- generateTableContentV2,
1255
- generateListContent,
1256
- generateCodeBlockContent,
1257
- generateCodeBlockContentV2,
1258
- generateLinkContent,
1259
- generateLinkContentV2,
1260
- generateRichMessageContent,
1261
- generateLatexContent,
1262
- generateUnifiedResponseContent,
1263
- captureUnifiedResponse,
1264
-
1265
- buildRichContextInfo,
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
- Or better — migrate your project to ESM by adding `"type": "module"` to `package.json`.
619
+ ### FOAD2
1393
620
 
1394
- </details>
621
+ ``` js
622
+ await sock
623
+ .foad2()
624
+ ...
625
+ ```
1395
626
 
1396
- <details>
1397
- <summary><strong>How do I reconnect automatically?</strong></summary>
627
+ FOAD2 is exposed as a separate builder for its own response/composition
628
+ workflow.
1398
629
 
1399
- Listen to `connection.update` and call your `startBot()` function again if the disconnect reason is not `loggedOut`:
630
+ ------------------------------------------------------------------------
1400
631
 
1401
- ```js
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
- For production, also use PM2 or Docker restart policies.
634
+ If you do not want to augment the socket directly:
1411
635
 
1412
- </details>
636
+ ``` js
637
+ const api = createKyyinfinite(sock)
1413
638
 
1414
- <details>
1415
- <summary><strong>How do I use pairing code instead of QR?</strong></summary>
639
+ await api.text('Hello').send(jid)
640
+ ```
1416
641
 
1417
- Call `sock.requestPairingCode(phoneNumber)` when the connection status is `"connecting"`.
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
- See the [Pairing Code Login](#5-pairing-code-login) section for a complete example.
644
+ ------------------------------------------------------------------------
1421
645
 
1422
- </details>
646
+ ## attachKyyinfinite
1423
647
 
1424
- <details>
1425
- <summary><strong>How do I persist authentication between restarts?</strong></summary>
648
+ For direct socket helpers:
1426
649
 
1427
- Use `useMultiFileAuthState("./session")` and save on every `creds.update` event:
650
+ ``` js
651
+ attachKyyinfinite(sock)
1428
652
 
1429
- ```js
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
- 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.
1435
658
 
1436
- </details>
659
+ ------------------------------------------------------------------------
1437
660
 
1438
- <details>
1439
- <summary><strong>How do I deploy to a VPS or cloud?</strong></summary>
661
+ ## API Overview
1440
662
 
1441
- 1. Upload your project files (without `node_modules`)
1442
- 2. Run `npm install` on the server
1443
- 3. Use PM2 to keep the bot alive: `npm install -g pm2 && pm2 start index.js --name my-bot`
1444
- 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
1445
672
 
1446
- > [!TIP]
1447
- > 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()
1448
683
 
1449
- </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()
1450
697
 
1451
- <details>
1452
- <summary><strong>How do I handle multiple sessions / multi-device?</strong></summary>
698
+ Interactive
699
+ ├── button()
700
+ ├── buttonV2()
701
+ └── carousel()
1453
702
 
1454
- Create a separate auth state directory for each session:
1455
-
1456
- ```js
1457
- const session1 = await useMultiFileAuthState("./sessions/bot1");
1458
- const session2 = await useMultiFileAuthState("./sessions/bot2");
703
+ Advanced
704
+ ├── ai()
705
+ ├── foad()
706
+ └── foad2()
1459
707
  ```
1460
708
 
1461
- Then instantiate a separate `makeWASocket` for each session.
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
- - A **WhatsApp Business API**-capable number, or
1471
- - A number that has been granted access to the interactive message API by WhatsApp.
711
+ ## Design Goals
1472
712
 
1473
- On regular personal numbers, interactive messages may silently fail or show as plain text.
713
+ The API is built around a few principles:
1474
714
 
1475
- </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.
1476
724
 
1477
- <details>
1478
- <summary><strong>What is the difference from official Baileys?</strong></summary>
725
+ The main idea is:
1479
726
 
1480
- | Area | Official Baileys | @kyyinfinite/baileys |
1481
- |---|---|---|
1482
- | Interactive messages | No native support | ✅ Full support via Dugong |
1483
- | Album messages | Not supported | ✅ Multi-media albums |
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
- > [!TIP]
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
- > [!IMPORTANT]
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
- > [!WARNING]
1504
- > 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
+ ```
1505
741
 
1506
- > [!NOTE]
1507
- > `@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.
1508
744
 
1509
- > [!CAUTION]
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
- ## 📄 License
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
- Permission is hereby granted, free of charge, to any person obtaining a copy
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
- The above copyright notice and this permission notice shall be included in all
1529
- 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
1530
769
  ```
1531
770
 
1532
- ---
771
+ ------------------------------------------------------------------------
1533
772
 
1534
- <div align="center">
773
+ ## Roadmap
1535
774
 
1536
- [![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)
1537
- [![GitHub](https://img.shields.io/badge/GitHub-kyyinfinite%2Fbaileys-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/kyyinfinite/baileys)
1538
- [![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:
1539
776
 
1540
- <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
1541
783
 
1542
- [🐛 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
+ ------------------------------------------------------------------------
1543
785
 
1544
- <br/>
786
+ ## Repository
1545
787
 
1546
- **© 2026 kyyinfinite — `@kyyinfinite/baileys` v0.1.0 • MIT License**
788
+ urlGitHub Repositoryhttps://github.com/kyyinfinite/baileys
1547
789
 
1548
- *Built on top of [WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys)*
790
+ ## License
1549
791
 
1550
- </div>
792
+ MIT