@x4r1s3/baileys 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1245 -2
- package/SECURITY.md +47 -0
- package/WAProto/V +1 -0
- package/WAProto/WAProto.proto +8892 -0
- package/WAProto/index.d.ts +104128 -0
- package/WAProto/index.js +334920 -0
- package/assets/rolling-circle.svg +133 -0
- package/assets/x4r1s3-banner.svg +32 -0
- package/engine-requirements.js +27 -0
- package/lib/Builders/A2UI.js +245 -0
- package/lib/Builders/AIRich.js +179 -0
- package/lib/Builders/Button.js +108 -0
- package/lib/Builders/CFC.js +284 -0
- package/lib/Builders/Carousel.js +81 -0
- package/lib/Call/THIRD_PARTY_LICENSE.txt +21 -0
- package/lib/Call/astralena-v3.mjs +96 -0
- package/lib/Call/audio-feeder.mjs +201 -0
- package/lib/Call/audio-recorder.mjs +250 -0
- package/lib/Call/fetch-wasm-resources.mjs +104 -0
- package/lib/Call/index.mjs +707 -0
- package/lib/Call/relay-transport.mjs +563 -0
- package/lib/Call/signaling.mjs +660 -0
- package/lib/Call/types.mjs +17 -0
- package/lib/Call/video-feeder.mjs +94 -0
- package/lib/Call/voip-resources.mjs +259 -0
- package/lib/Call/wasm-engine.mjs +1372 -0
- package/lib/Call/worker-bootstrap.mjs +1042 -0
- package/lib/Defaults/ban-checker.js +56 -0
- package/lib/Defaults/index.js +170 -0
- package/lib/Signal/Group/ciphertext-message.js +23 -0
- package/lib/Signal/Group/group-session-builder.js +41 -0
- package/lib/Signal/Group/group_cipher.js +93 -0
- package/lib/Signal/Group/index.js +23 -0
- package/lib/Signal/Group/keyhelper.js +29 -0
- package/lib/Signal/Group/sender-chain-key.js +37 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +74 -0
- package/lib/Signal/Group/sender-key-message.js +77 -0
- package/lib/Signal/Group/sender-key-name.js +59 -0
- package/lib/Signal/Group/sender-key-record.js +52 -0
- package/lib/Signal/Group/sender-key-state.js +95 -0
- package/lib/Signal/Group/sender-message-key.js +37 -0
- package/lib/Signal/libsignal.js +440 -0
- package/lib/Signal/lid-mapping.js +292 -0
- package/lib/Socket/Client/index.js +14 -0
- package/lib/Socket/Client/types.js +22 -0
- package/lib/Socket/Client/websocket.js +65 -0
- package/lib/Socket/aigroups.js +327 -0
- package/lib/Socket/ban-checker.js +165 -0
- package/lib/Socket/business.js +419 -0
- package/lib/Socket/chats.js +1921 -0
- package/lib/Socket/communities.js +443 -0
- package/lib/Socket/graphql.js +911 -0
- package/lib/Socket/groups.js +561 -0
- package/lib/Socket/index.js +49 -0
- package/lib/Socket/interactive-handler.js +612 -0
- package/lib/Socket/interop.js +575 -0
- package/lib/Socket/managed-account.js +220 -0
- package/lib/Socket/messages-recv.js +2193 -0
- package/lib/Socket/messages-send.js +4141 -0
- package/lib/Socket/mex.js +53 -0
- package/lib/Socket/newsletter.js +291 -0
- package/lib/Socket/privacy.js +458 -0
- package/lib/Socket/registration.js +440 -0
- package/lib/Socket/socket.js +1042 -0
- package/lib/Socket/status-actions.js +287 -0
- package/lib/Socket/username.js +241 -0
- package/lib/Store/index.js +16 -0
- package/lib/Store/make-cache-manager-store.js +101 -0
- package/lib/Store/make-in-memory-store.js +432 -0
- package/lib/Store/make-ordered-dictionary.js +90 -0
- package/lib/Store/object-repository.js +35 -0
- package/lib/Types/Auth.js +13 -0
- package/lib/Types/Bussines.js +13 -0
- package/lib/Types/Call.js +13 -0
- package/lib/Types/Chat.js +19 -0
- package/lib/Types/Contact.js +13 -0
- package/lib/Types/Events.js +13 -0
- package/lib/Types/GroupMetadata.js +13 -0
- package/lib/Types/Label.js +36 -0
- package/lib/Types/LabelAssociation.js +18 -0
- package/lib/Types/Message.js +30 -0
- package/lib/Types/Mex.js +53 -0
- package/lib/Types/Product.js +13 -0
- package/lib/Types/RichType.js +34 -0
- package/lib/Types/Signal.js +13 -0
- package/lib/Types/Socket.js +14 -0
- package/lib/Types/State.js +60 -0
- package/lib/Types/USync.js +13 -0
- package/lib/Types/index.js +37 -0
- package/lib/Utils/auth-utils.js +313 -0
- package/lib/Utils/ban-checker.js +48 -0
- package/lib/Utils/bot-capabilities.js +96 -0
- package/lib/Utils/bot-planning-replay.js +177 -0
- package/lib/Utils/browser-utils.js +40 -0
- package/lib/Utils/business.js +242 -0
- package/lib/Utils/c2582.js +147 -0
- package/lib/Utils/chat-utils.js +905 -0
- package/lib/Utils/companion-reg-client-utils.js +104 -0
- package/lib/Utils/consumer-application.js +114 -0
- package/lib/Utils/crypto.js +129 -0
- package/lib/Utils/decode-wa-message.js +496 -0
- package/lib/Utils/direct-chat-theme.js +164 -0
- package/lib/Utils/event-buffer.js +601 -0
- package/lib/Utils/experimental-proto.js +206 -0
- package/lib/Utils/games/miniapp.js +17 -0
- package/lib/Utils/games/slot-machine.js +270 -0
- package/lib/Utils/games/website-preview.js +306 -0
- package/lib/Utils/generics.js +402 -0
- package/lib/Utils/group-history.js +68 -0
- package/lib/Utils/group-wallpaper.js +168 -0
- package/lib/Utils/history.js +162 -0
- package/lib/Utils/identity-change-handler.js +60 -0
- package/lib/Utils/index.js +61 -0
- package/lib/Utils/jid-display-normalization.js +221 -0
- package/lib/Utils/link-preview.js +96 -0
- package/lib/Utils/logger.js +14 -0
- package/lib/Utils/lt-hash.js +19 -0
- package/lib/Utils/make-mutex.js +44 -0
- package/lib/Utils/message-composer.js +709 -0
- package/lib/Utils/message-inspect.js +79 -0
- package/lib/Utils/message-retry-manager.js +253 -0
- package/lib/Utils/message-security.js +167 -0
- package/lib/Utils/messages-media.js +1027 -0
- package/lib/Utils/messages.js +2467 -0
- package/lib/Utils/meta-ai-msmsg.js +215 -0
- package/lib/Utils/meta-compositing.js +239 -0
- package/lib/Utils/native-flow.js +158 -0
- package/lib/Utils/newsletter-live-update-utils.js +74 -0
- package/lib/Utils/newsletter-status-utils.js +152 -0
- package/lib/Utils/noise-handler.js +212 -0
- package/lib/Utils/offline-node-processor.js +51 -0
- package/lib/Utils/poll-manager.js +206 -0
- package/lib/Utils/portable-compat.js +12 -0
- package/lib/Utils/pre-key-manager.js +117 -0
- package/lib/Utils/process-message.js +610 -0
- package/lib/Utils/reporting-utils.js +269 -0
- package/lib/Utils/rich-message-utils.js +2841 -0
- package/lib/Utils/scheduled-message.js +107 -0
- package/lib/Utils/signal.js +212 -0
- package/lib/Utils/source-grep.js +57 -0
- package/lib/Utils/stanza-ack.js +49 -0
- package/lib/Utils/sticker-annotation.js +87 -0
- package/lib/Utils/sync-action-utils.js +59 -0
- package/lib/Utils/tc-token-utils.js +174 -0
- package/lib/Utils/use-multi-file-auth-state.js +132 -0
- package/lib/Utils/use-single-file-auth-state.js +108 -0
- package/lib/Utils/use-sqlite-auth-state.js +120 -0
- package/lib/Utils/validate-connection.js +221 -0
- package/lib/Utils/view-once-utils.js +218 -0
- package/lib/Utils/voip-rekey.js +32 -0
- package/lib/Utils/website-preview.js +27 -0
- package/lib/Utils/welcome-flow.js +228 -0
- package/lib/Utils/x4r1s3.js +144 -0
- package/lib/WABinary/constants.js +1475 -0
- package/lib/WABinary/decode.js +273 -0
- package/lib/WABinary/encode.js +231 -0
- package/lib/WABinary/generic-utils.js +242 -0
- package/lib/WABinary/index.js +17 -0
- package/lib/WABinary/jid-utils.js +107 -0
- package/lib/WABinary/types.js +13 -0
- package/lib/WAM/BinaryInfo.js +21 -0
- package/lib/WAM/constants.js +22864 -0
- package/lib/WAM/encode.js +161 -0
- package/lib/WAM/index.js +15 -0
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +108 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +68 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +65 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +82 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +40 -0
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +49 -0
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +46 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +36 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +62 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +40 -0
- package/lib/WAUSync/Protocols/index.js +24 -0
- package/lib/WAUSync/USyncQuery.js +213 -0
- package/lib/WAUSync/USyncUser.js +66 -0
- package/lib/WAUSync/index.js +15 -0
- package/lib/antiban.cjs +4726 -0
- package/lib/index.d.ts +1895 -0
- package/lib/index.js +41 -0
- package/package.json +125 -4
package/README.md
CHANGED
|
@@ -1,3 +1,1246 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# x4r1s3/baileys
|
|
4
|
+
|
|
5
|
+
The intelligent interactive and productivity layer for WhatsApp protocols.
|
|
6
|
+
|
|
7
|
+
<img src="https://readme-typing-svg.demolab.com?font=Space+Mono&size=22&pause=1200&color=00FFF0¢er=true&vCenter=true&width=900&height=70&repeat=true&lines=BAILEYS+PROTOCOL.;NODE.JS+%2B+TYPESCRIPT.;RICH+MESSAGES+%2B+MEDIA.;BUILD+RELIABLE+INTEGRATIONS." alt="X4R1S3 INNOVATIONS Baileys animated keywords" />
|
|
8
|
+
|
|
9
|
+
<a href="https://github.com/X4R1S3/baileys"><img src="./assets/x4r1s3-banner.svg" width="92%" alt="X4R1S3 INNOVATIONS Baileys banner" /></a>
|
|
10
|
+
|
|
11
|
+
<a href="https://github.com/X4R1S3/ASTRALENA/blob/main/assets/rolling-circle.svg"><img src="./assets/rolling-circle.svg" width="110" alt="ASTRALENA rolling circle by X4R1S3" /></a>
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/@x4r1s3/baileys)
|
|
14
|
+
[](https://nodejs.org/)
|
|
15
|
+
[](https://www.npmjs.com/package/@x4r1s3/baileys)
|
|
16
|
+
[](#license-and-maintenance)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
> A readable, carefully maintained Baileys distribution for building reliable WhatsApp integrations. built by X4R1S3 populary known as X4R1S3
|
|
21
|
+
|
|
22
|
+
`@x4r1s3/baileys` is a Node.js and TypeScript library for creating WhatsApp automations over the Baileys protocol. It provides a socket-oriented API for authentication, messaging, media, interactive content, rich responses, newsletters, groups, communities, business features, account utilities, and carefully documented extensions.
|
|
23
|
+
|
|
24
|
+
The package is maintained by **X4R1S3** under the **X4R1S3 INNOVATIONS** organization. It is intended for developers who want a practical Baileys foundation with familiar interfaces, public TypeScript declarations, readable source code, explicit behavior, and room for carefully tested improvements.
|
|
25
|
+
|
|
26
|
+
## Table of contents
|
|
27
|
+
|
|
28
|
+
- [At a glance](#at-a-glance)
|
|
29
|
+
- [Installation](#installation)
|
|
30
|
+
- [Quick start](#quick-start)
|
|
31
|
+
- [CommonJS usage](#commonjs-usage)
|
|
32
|
+
- [Core capabilities](#core-capabilities)
|
|
33
|
+
- [Everyday message usage](#everyday-message-usage)
|
|
34
|
+
- [Rich menu example](#rich-menu-example)
|
|
35
|
+
- [Status, grids, tables, and flows](#status-grids-tables-and-flows)
|
|
36
|
+
- [Authentication and deployment guidance](#authentication-and-deployment-guidance)
|
|
37
|
+
- [Development workflow](#development-workflow)
|
|
38
|
+
- [Recent compatibility updates](#recent-compatibility-updates)
|
|
39
|
+
- [About X4R1S3](#about-X4R1S3)
|
|
40
|
+
- [Community and contact](#community-and-contact)
|
|
41
|
+
- [Package layout](#package-layout)
|
|
42
|
+
- [Security and responsible use](#security-and-responsible-use)
|
|
43
|
+
- [Disclaimer](#disclaimer)
|
|
44
|
+
- [Privacy policy](#privacy-policy)
|
|
45
|
+
- [License and maintenance](#license-and-maintenance)
|
|
46
|
+
- [Acknowledgement](#acknowledgement)
|
|
47
|
+
- [Compatibility additions](#compatibility-additions)
|
|
48
|
+
- [Comparison references](#comparison-references)
|
|
49
|
+
- [Additional functional compatibility helpers](#additional-functional-compatibility-helpers)
|
|
50
|
+
- [AI generation primitive](#ai-generation-primitive)
|
|
51
|
+
- [New AIRich metadata helpers](#new-airich-metadata-helpers)
|
|
52
|
+
|
|
53
|
+
## At a glance
|
|
54
|
+
|
|
55
|
+
| Property | Value |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| Package | `@x4r1s3/baileys` |
|
|
58
|
+
| Version | `1.0.1` |
|
|
59
|
+
| Runtime | Node.js 20 or newer |
|
|
60
|
+
| Module format | ESM, with CommonJS compatibility where supported |
|
|
61
|
+
| Type declarations | Included at `lib/index.d.ts` |
|
|
62
|
+
| License | MIT, as declared by the package metadata |
|
|
63
|
+
| Author | X4R1S3 |
|
|
64
|
+
| Maintainer | X4R1S3 |
|
|
65
|
+
| Entry point | `lib/index.js` |
|
|
66
|
+
| Repository | `https://github.com/X4R1S3/baileys` |
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
| Method | Command | Notes |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| From npm | `npm install @x4r1s3/baileys` | Standard install when published under your organization |
|
|
73
|
+
| From local archive | `npm install ./X4R1S3-baileys-1.0.1.tgz` | Place the `.tgz` beside your application |
|
|
74
|
+
| Source audit (no scripts) | `npm install --ignore-scripts` | Skips install hooks for local review |
|
|
75
|
+
|
|
76
|
+
Both npm and archive installs use the same import name:
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
import { makeWASocket } from '@x4r1s3/baileys'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Quick start
|
|
83
|
+
|
|
84
|
+
The following example creates a socket, stores multi-file authentication credentials, reconnects after an unexpected disconnect, and replies to incoming messages. Keep the session directory private and never commit it to a public repository.
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
import {
|
|
88
|
+
DisconnectReason,
|
|
89
|
+
makeWASocket,
|
|
90
|
+
useMultiFileAuthState
|
|
91
|
+
} from '@x4r1s3/baileys'
|
|
92
|
+
import P from 'pino'
|
|
93
|
+
|
|
94
|
+
async function start() {
|
|
95
|
+
const { state, saveCreds } = await useMultiFileAuthState('./session')
|
|
96
|
+
|
|
97
|
+
const sock = makeWASocket({
|
|
98
|
+
auth: state,
|
|
99
|
+
logger: P({ level: 'silent' })
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
sock.ev.on('creds.update', saveCreds)
|
|
103
|
+
|
|
104
|
+
sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
|
|
105
|
+
if (connection === 'open') {
|
|
106
|
+
console.log('Connected with @x4r1s3/baileys')
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (connection === 'close') {
|
|
110
|
+
const statusCode = lastDisconnect?.error?.output?.statusCode
|
|
111
|
+
if (statusCode !== DisconnectReason.loggedOut) {
|
|
112
|
+
start().catch(console.error)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
118
|
+
for (const message of messages) {
|
|
119
|
+
if (!message.message || message.key.fromMe) continue
|
|
120
|
+
|
|
121
|
+
await sock.sendMessage(message.key.remoteJid, {
|
|
122
|
+
text: 'Hello from @x4r1s3/baileys'
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
start().catch(console.error)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## Usage setup for the examples
|
|
133
|
+
|
|
134
|
+
The feature examples below must run after the socket has connected. They assume they are inside the `messages.upsert` handler shown above. Define the target JID before calling any helper. A JID is the WhatsApp address of the chat receiving the message.
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
138
|
+
for (const message of messages) {
|
|
139
|
+
if (!message.message || message.key.fromMe) continue
|
|
140
|
+
|
|
141
|
+
// The chat that sent the incoming message.
|
|
142
|
+
const jid = message.key.remoteJid
|
|
143
|
+
if (!jid) continue
|
|
144
|
+
|
|
145
|
+
// Use real authorized JIDs for your own test account.
|
|
146
|
+
const userJid = '15551234567@s.whatsapp.net'
|
|
147
|
+
const groupJid = '120363000000000000@g.us'
|
|
148
|
+
const voterJid = userJid
|
|
149
|
+
const commandName = 'menu'
|
|
150
|
+
const commandOutput = 'X4R1S3 command completed'
|
|
151
|
+
const messageId = message.key.id
|
|
152
|
+
|
|
153
|
+
// Sticker annotation expects a sticker media payload, not an undefined variable.
|
|
154
|
+
const stickerMessage = {
|
|
155
|
+
url: './sticker.webp',
|
|
156
|
+
isAnimated: false
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Examples below can now use jid, userJid, groupJid, message, messageId,
|
|
160
|
+
// stickerMessage, voterJid, commandName, and commandOutput.
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
For a standalone command that is not handling an incoming message, define `jid` explicitly instead:
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
169
|
+
await sock.sendMessage(jid, { text: 'Hello from X4R1S3' })
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Do not call a helper with an undeclared variable such as `sock.sendMessage(jid, ...)` before defining `jid`. Replace the example JIDs with real authorized user or group JIDs.
|
|
173
|
+
|
|
174
|
+
## CommonJS usage
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
const {
|
|
178
|
+
makeWASocket,
|
|
179
|
+
useMultiFileAuthState
|
|
180
|
+
} = require('@x4r1s3/baileys')
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
If your runtime or bundler does not support this interop path, use the ESM import form instead.
|
|
184
|
+
|
|
185
|
+
## Core capabilities
|
|
186
|
+
|
|
187
|
+
| Area | What it covers |
|
|
188
|
+
| --- | --- |
|
|
189
|
+
| Connections & authentication | WebSocket connection events, reconnect handling, browser identity configuration, pairing-code flows, connection state transitions |
|
|
190
|
+
| Auth persistence | Multi-file credentials, single-file state, SQLite-backed persistence (optional driver), cache-manager integrations |
|
|
191
|
+
| Messages & conversations | Text, mentions, replies, reactions, edits, deletions, forwards, polls, contacts, locations, events, group invitations, quoted messages, disappearing messages, view-once envelopes |
|
|
192
|
+
| Media & albums | Images, video, audio, documents, stickers, thumbnails, albums; sourced from URLs, local files, or buffers; optional `sharp` / `@napi-rs/image` / `jimp` image processing; GIF-style video playback |
|
|
193
|
+
| Interactive content | Buttons, lists, native flows, hydrated templates, carousel layouts, button grids |
|
|
194
|
+
| Rich content & previews | Code blocks, tables, inline entities, LaTeX-oriented content, link previews, structured response arrays |
|
|
195
|
+
| Rich menus (experimental) | Header image, row/carousel cards, stable button IDs, toast metadata, disclaimers, footer action |
|
|
196
|
+
| Groups & communities | Group creation, participant management, settings, metadata, invites, labels, community/subgroup relationships |
|
|
197
|
+
| Newsletters & channels | Channel metadata, follow/unfollow, posts, reactions, media, polls |
|
|
198
|
+
| Account, business & privacy | Profile/business helpers, product & catalog operations, privacy controls, username utilities, status publishing, favorites management |
|
|
199
|
+
| Storage & protocol utilities | In-memory and ordered-dictionary stores, cache-manager support, LID/phone-number resolution, event utilities, message normalization, media retry handling, TypeScript declarations |
|
|
200
|
+
|
|
201
|
+
## Everyday message usage
|
|
202
|
+
|
|
203
|
+
| Message type | Key options | Example |
|
|
204
|
+
| --- | --- | --- |
|
|
205
|
+
| Text | `text` | `sock.sendMessage(jid, { text: '...' })` |
|
|
206
|
+
| Media with caption | `image` / `video` / `audio` / `document`, `caption` | `sock.sendMessage(jid, { image: { url } , caption: '...' })` |
|
|
207
|
+
| GIF-style video | `video`, `gifPlayback: true` | `sock.sendMessage(jid, { video: { url }, gifPlayback: true })` |
|
|
208
|
+
| View-once media | `viewOnce: true` (also `viewOnceV2`, `viewOnceV2Extension`, `spoiler`) | `sock.sendMessage(jid, { image: { url }, viewOnce: true })` |
|
|
209
|
+
| Spoiler / view-once (new) | `mediaSpoilerMode: 'viewOnce' \| 'native'` | see below |
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
213
|
+
await sock.sendMessage(jid, {
|
|
214
|
+
text: 'A message from X4R1S3'
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
await sock.sendMessage(jid, {
|
|
218
|
+
image: { url: './media/photo.jpg' },
|
|
219
|
+
caption: 'A photo message'
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
await sock.sendMessage(jid, {
|
|
223
|
+
video: { url: './media/animation.mp4' },
|
|
224
|
+
gifPlayback: true,
|
|
225
|
+
caption: 'Animated media'
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
await sock.sendMessage(jid, {
|
|
229
|
+
image: { url: './media/private-image.jpg' },
|
|
230
|
+
caption: 'Open once',
|
|
231
|
+
viewOnce: true
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
await sock.sendMessage(jid, {
|
|
235
|
+
video: { url: './media/clip.mp4' },
|
|
236
|
+
caption: 'View-once video',
|
|
237
|
+
mediaSpoilerMode: 'viewOnce'
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
await sock.sendMessage(jid, {
|
|
241
|
+
image: { url: './media/hidden-preview.jpg' },
|
|
242
|
+
mediaSpoilerMode: 'native'
|
|
243
|
+
})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
`mediaSpoilerMode` is an additional, opt-in path for supported image, video, document, or sticker media:
|
|
247
|
+
|
|
248
|
+
| Value | Effect |
|
|
249
|
+
| --- | --- |
|
|
250
|
+
| `viewOnce` | Wraps supported media in a view-once envelope |
|
|
251
|
+
| `native` | Applies the native spoiler context flag |
|
|
252
|
+
|
|
253
|
+
The existing `viewOnce`, `viewOnceV2`, `viewOnceV2Extension`, and `spoiler` options remain supported and take precedence over `mediaSpoilerMode` when explicitly set.
|
|
254
|
+
|
|
255
|
+
## Rich menu example
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
259
|
+
await sock.richMenu(jid, {
|
|
260
|
+
header: {
|
|
261
|
+
title: 'X4R1S3 Menu',
|
|
262
|
+
image: {
|
|
263
|
+
url: 'https://example.com/menu.jpg',
|
|
264
|
+
mime_type: 'image/jpeg'
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
body: {
|
|
268
|
+
row: true,
|
|
269
|
+
carousel: false,
|
|
270
|
+
cards: [
|
|
271
|
+
{
|
|
272
|
+
title: 'Account',
|
|
273
|
+
buttons: [
|
|
274
|
+
{ id: 'profile', text: 'Profile' },
|
|
275
|
+
{ id: 'settings', text: 'Settings' }
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
title: 'Support',
|
|
280
|
+
buttons: ['help', 'contact']
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
footer: {
|
|
285
|
+
text: 'X4R1S3 INNOVATIONS',
|
|
286
|
+
url: 'https://example.com'
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
| Rich menu field | Purpose |
|
|
292
|
+
| --- | --- |
|
|
293
|
+
| `header` | Optional title and image shown above the menu |
|
|
294
|
+
| `body.row` / `body.carousel` | Layout mode for the cards |
|
|
295
|
+
| `body.cards` | Rows of stable button IDs and labels |
|
|
296
|
+
| `footer` | Text plus an optional action URL |
|
|
297
|
+
|
|
298
|
+
## Status, grids, tables, and flows
|
|
299
|
+
|
|
300
|
+
| Helper | Purpose |
|
|
301
|
+
| --- | --- |
|
|
302
|
+
| `sendStatus` | Post a status update, optionally with mentions via `statusJidList` |
|
|
303
|
+
| `sendRichButtonGrid` | Send a card grid of stable-ID buttons |
|
|
304
|
+
| `sendInteractiveTable` | Send tabular content with headers, rows, and action buttons |
|
|
305
|
+
| `sendWhatsAppFlow` | Launch a published WhatsApp Flow |
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
309
|
+
await sock.sendStatus({ text: 'New X4R1S3 status' }, {
|
|
310
|
+
statusJidList: ['1234567890@s.whatsapp.net']
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
await sock.sendRichButtonGrid(jid, {
|
|
314
|
+
text: 'Choose an option',
|
|
315
|
+
cards: [{
|
|
316
|
+
title: 'Actions',
|
|
317
|
+
buttons: [
|
|
318
|
+
{ id: 'first_action', text: 'First action' },
|
|
319
|
+
{ id: 'second_action', text: 'Second action' }
|
|
320
|
+
]
|
|
321
|
+
}]
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
await sock.sendInteractiveTable(jid, {
|
|
325
|
+
title: 'Plans',
|
|
326
|
+
headers: ['Name', 'Price'],
|
|
327
|
+
rows: [['Basic', '$5'], ['Pro', '$10']],
|
|
328
|
+
buttons: [{ id: 'choose_pro', text: 'Choose Pro' }],
|
|
329
|
+
footer: 'Select a plan'
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
await sock.sendWhatsAppFlow(jid, {
|
|
333
|
+
text: 'Open the form',
|
|
334
|
+
flowId: 'your-flow-id',
|
|
335
|
+
flowToken: 'your-flow-token',
|
|
336
|
+
flowName: 'your-flow-name',
|
|
337
|
+
flowAction: 'navigate',
|
|
338
|
+
flowActionPayload: { screen: 'WELCOME' }
|
|
339
|
+
})
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
These helpers are protocol- and client-dependent. Use graceful fallbacks when an application serves a wide range of WhatsApp client versions.
|
|
343
|
+
|
|
344
|
+
## Authentication and deployment guidance
|
|
345
|
+
|
|
346
|
+
| Practice | Detail |
|
|
347
|
+
| --- | --- |
|
|
348
|
+
| Session privacy | Keep the session directory private and excluded from version control |
|
|
349
|
+
| Access control | Use a dedicated service account or restricted filesystem permissions where possible |
|
|
350
|
+
| Secrets handling | Do not place access tokens, private keys, phone numbers, or personal account data in the README, package archive, or a public repository |
|
|
351
|
+
| Dependency pinning | Pin dependencies with a lockfile for production deployments |
|
|
352
|
+
| Runtime | Use a supported Node.js runtime |
|
|
353
|
+
| Connection handling | Monitor connection events; handle logout separately from recoverable disconnects; avoid uncontrolled parallel sockets on reconnect |
|
|
354
|
+
|
|
355
|
+
## Development workflow
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
npm test
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Before submitting changes, validate ESM syntax, CommonJS compatibility where applicable, generated protocol files, and the declarations in `lib/index.d.ts`. Keep package metadata, exports, runtime requirements, and documentation synchronized. When a protocol behavior is experimental, document the fallback behavior and the client versions used during testing.
|
|
362
|
+
|
|
363
|
+
## Recent compatibility updates
|
|
364
|
+
|
|
365
|
+
| Update | Detail |
|
|
366
|
+
| --- | --- |
|
|
367
|
+
| Album association fix | Album child messages use association type `1`, the compatible child-association wire value, rather than treating the `MEDIA_ALBUM` message category as the association value |
|
|
368
|
+
| View-once preserved | Explicit view-once implementations remain unchanged |
|
|
369
|
+
| `mediaSpoilerMode` | New opt-in path for a view-once envelope or native spoiler flag, without altering existing defaults |
|
|
370
|
+
|
|
371
|
+
## About X4R1S3
|
|
372
|
+
|
|
373
|
+
This package is built and maintained by **X4R1S3**. X4R1S3 is a developer populary known as X4R1S3 that is focused on practical, accessible, and reliable software projects across the JavaScript and TypeScript ecosystem, with a focus on cyber security and responsible full stack and software engineering.
|
|
374
|
+
|
|
375
|
+
| | |
|
|
376
|
+
| --- | --- |
|
|
377
|
+
| Tech stack | JavaScript, HTML, TypeScript, Node.js, GitHub, Baileys, APIs, key-value stores |
|
|
378
|
+
| Project types | Application development, websites, WhatsApp bots, Telegram bots, API endpoints, games |
|
|
379
|
+
[](mailto:x4r1s3@gmail.com)
|
|
380
|
+
|
|
381
|
+
The developer's work is driven by a commitment to learning, experimentation, clear documentation, and useful software that developers can understand and extend. This package reflects that commitment through its readable source, public declarations, practical examples, and emphasis on responsible automation.
|
|
382
|
+
|
|
383
|
+
## Package layout
|
|
384
|
+
|
|
385
|
+
| Path | Contents |
|
|
386
|
+
| --- | --- |
|
|
387
|
+
| `lib/` | JavaScript implementation, supporting utilities, public TypeScript declarations |
|
|
388
|
+
| `WAProto/` | Generated WhatsApp protocol definitions |
|
|
389
|
+
| `engine-requirements.js` | Installation-time runtime checks |
|
|
390
|
+
| `package.json` | Package metadata, scripts, dependencies, exports |
|
|
391
|
+
| `README.md` | User-facing installation and usage guide |
|
|
392
|
+
|
|
393
|
+
## Security and responsible use
|
|
394
|
+
|
|
395
|
+
This library can access WhatsApp accounts, authentication state, contacts, messages, media, groups, communities, newsletters, and business features. Treat every socket, credential store, message body, phone number, media file, and generated protocol payload as sensitive information.
|
|
396
|
+
|
|
397
|
+
| Control | Required practice |
|
|
398
|
+
| --- | --- |
|
|
399
|
+
| Authorization | Use the package only with accounts, devices, data, and recipients you are authorized to control. Obtain meaningful consent before sending automated messages or processing personal data. |
|
|
400
|
+
| Credential protection | Keep authentication/session directories, private keys, tokens, cookies, phone numbers, and exported databases out of source control and public logs. Use least-privilege filesystem and hosting permissions. |
|
|
401
|
+
| Data minimization | Collect, retain, and expose only the data your application genuinely needs. Encrypt sensitive data at rest and in transit, and establish a deletion and incident-response process. |
|
|
402
|
+
| Rate and recipient safety | Use conservative rate limits, opt-in recipient lists, quiet hours, unsubscribe handling, duplicate suppression, and human review for high-impact workflows. |
|
|
403
|
+
| Input and output safety | Validate untrusted webhooks, media, URLs, native-flow fields, and user-supplied commands. Do not execute downloaded content or treat message text as trusted code. |
|
|
404
|
+
| Deployment review | Pin and review dependencies, audit install scripts, restrict outbound network access where practical, and test with a non-production account before release. |
|
|
405
|
+
| Transparency | Tell users when automation is being used, identify the responsible operator, and provide a clear support or opt-out path. |
|
|
406
|
+
|
|
407
|
+
Do not use this package to send spam, harass or threaten people, scrape or enumerate accounts without authorization, impersonate WhatsApp or Meta, phish, harvest credentials, distribute malware, exfiltrate private data, evade platform enforcement, or bypass rate limits and access controls. Do not build tools intended to facilitate violence, fraud, stalking, discrimination, or other unlawful or harmful activity.
|
|
408
|
+
|
|
409
|
+
### Security disclosure
|
|
410
|
+
|
|
411
|
+
Please do not publish credentials, session files, personal data, exploit details, or a working attack path in a public issue. Report suspected security vulnerabilities privately using the developer contact banner in the [Community and contact](#community-and-contact) section, with the affected version, a concise impact description, reproducible steps, and a safe way to follow up. Remove secrets and personal data from all reports. Security reports are reviewed in good faith, but no response time, fix, or continued support is guaranteed.
|
|
412
|
+
|
|
413
|
+
## Disclaimer
|
|
414
|
+
|
|
415
|
+
`@x4r1s3/baileys` is an independent, source-available Node.js and TypeScript library. It is not affiliated with, sponsored by, endorsed by, or officially connected to WhatsApp LLC, Meta Platforms, Inc., or any of their subsidiaries. “WhatsApp” and “Meta” are trademarks of their respective owners and are used only to describe interoperability and protocol targets.
|
|
416
|
+
|
|
417
|
+
This project provides general-purpose developer tooling. A feature being available in the library does not mean that every possible use of that feature is lawful, safe, authorized, or permitted by WhatsApp. Developers must review WhatsApp’s current terms, business policies, developer requirements, applicable privacy and communications laws, and the rules of every service they connect to before deploying an application.
|
|
418
|
+
|
|
419
|
+
X4R1S3, X4R1S3 INNOVATIONS, its contributors, and maintainers do not operate or control third-party applications, accounts, deployments, recipient lists, message content, credentials, or infrastructure built with this package. Each developer and operator is solely responsible for authorization, consent, security, content, compliance, rate limiting, user notices, data protection, and all consequences of their deployment. This includes account restrictions, suspensions, bans, message delivery failures, data loss, privacy incidents, legal claims, financial loss, and harm caused by misuse or by changes to WhatsApp’s systems.
|
|
420
|
+
|
|
421
|
+
To the fullest extent permitted by applicable law, the project and its maintainers are not liable for any direct, indirect, incidental, special, consequential, exemplary, or punitive loss arising from use of, inability to use, or reliance on this package or on an application built with it. The software is provided **“as is” and “as available,” without warranties**, including warranties of merchantability, fitness for a particular purpose, non-infringement, security, availability, compatibility, or uninterrupted operation. No statement in this README guarantees account standing, access to WhatsApp, message delivery, protocol stability, or compliance for a particular deployment.
|
|
422
|
+
|
|
423
|
+
This disclaimer does not authorize harmful use. The project supports useful, consent-based, transparent automation and interoperable tooling only. Anyone who violates WhatsApp’s rules or applicable law does so independently and may not represent that X4R1S3 or X4R1S3 INNOVATIONS directed, approved, or accepted that conduct.
|
|
424
|
+
|
|
425
|
+
## Privacy policy
|
|
426
|
+
|
|
427
|
+
This section describes what the package itself does and does not do with data. It does not describe how any particular application built on top of this package handles data — that is determined by the developer of that application.
|
|
428
|
+
|
|
429
|
+
**Data the package handles locally, on your own infrastructure:**
|
|
430
|
+
|
|
431
|
+
| Data type | How it's handled |
|
|
432
|
+
| --- | --- |
|
|
433
|
+
| Authentication/session state | Generated and stored wherever your application configures it (e.g. `useMultiFileAuthState('./session')`). The package does not upload this elsewhere. Keep it private, as noted in [Security and responsible use](#security-and-responsible-use). |
|
|
434
|
+
| Messages and media | Sent to and received from WhatsApp's own servers as part of normal protocol operation. The package does not copy, log, or relay this content to X4R1S3, X4R1S3 INNOVATIONS, or any other third party. |
|
|
435
|
+
| Phone numbers passed to optional network helpers | Any phone number is sent only to the endpoint configured by your application when you explicitly call the relevant helper; review that destination and its own privacy practices before use. |
|
|
436
|
+
|
|
437
|
+
**What the package does not do:**
|
|
438
|
+
- It does not phone home, run analytics/telemetry, or transmit usage data to X4R1S3, X4R1S3 INNOVATIONS, or any other party.
|
|
439
|
+
- It does not embed hidden credentials, tracking identifiers, or remote "kill switches."
|
|
440
|
+
- It does not access data outside of what your application explicitly wires it up to.
|
|
441
|
+
|
|
442
|
+
**Your responsibilities as a developer.** If you build an application on top of this package that collects personal data (e.g. contacts, message content, phone numbers), you are the data controller for that application and are responsible for complying with applicable privacy laws (such as GDPR, CCPA, or Nigeria's NDPA) and with WhatsApp's own terms and business policies. This package is a communication toolkit, not a compliance framework.
|
|
443
|
+
|
|
444
|
+
**Contact.** Questions about this policy or the project should use the developer contact banner in the [Community and contact](#community-and-contact) section.
|
|
445
|
+
|
|
446
|
+
## License and maintenance
|
|
447
|
+
|
|
448
|
+
This distribution is provided under the license declared in `package.json` and the accompanying license file. Review those terms before redistributing or combining this package with third-party code.
|
|
449
|
+
|
|
450
|
+
**@x4r1s3/baileys is developed and maintained by X4R1S3 under the X4R1S3 INNOVATIONS organization.** Contributions, bug reports, and carefully documented improvements are welcome through the project repository.
|
|
451
|
+
|
|
452
|
+
### Acknowledgement
|
|
453
|
+
|
|
454
|
+
This X4R1S3 distribution is a downstream fork and enhancement built within the [plogme](https://www.npmjs.com/package/plogme) source, authored by **crysnovax**. The plogme/CODY lineage supplies the underlying Baileys protocol structure and foundational APIs used here. X4R1S3 remains the developer and maintainer of this fork, with its own branding, documentation, and distribution under X4R1S3 INNOVATIONS.
|
|
455
|
+
|
|
456
|
+
**Reference keywords:** X4R1S3, X4R1S3 INNOVATIONS, X4R1S3 TECHNOLOGY, Baileys, WhatsApp, WhatsApp Web, WhatsApp chat, WhatsApp API, WhatsApp automation, WhatsApp protocol, rich messages, AIRich, A2UI, Gen4 menus, albums, video grids, Node.js, and TypeScript.
|
|
457
|
+
|
|
458
|
+
## Compatibility additions
|
|
459
|
+
|
|
460
|
+
The current source includes several independently implemented compatibility helpers identified during comparison with the published upstream package. These additions preserve the X4R1S3 package identity and do not copy package-specific attribution enforcement or remote licensing checks.
|
|
461
|
+
|
|
462
|
+
### Copy-to-clipboard rich response
|
|
463
|
+
|
|
464
|
+
`sendCopyButton` creates a forwarded GenAI-style rich response with a copy-to-clipboard addon action.
|
|
465
|
+
|
|
466
|
+
| Option | Purpose |
|
|
467
|
+
| --- | --- |
|
|
468
|
+
| `text` | The content that gets copied |
|
|
469
|
+
| `label` | Optional visible button text |
|
|
470
|
+
| `alignment` | `END`, `START`, or `CENTER` |
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
474
|
+
await sock.sendCopyButton(jid, {
|
|
475
|
+
text: 'npm install @x4r1s3/baileys',
|
|
476
|
+
label: 'Copy install command',
|
|
477
|
+
alignment: 'END'
|
|
478
|
+
})
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
As with other private or experimental WhatsApp rich-response layouts, clients may fall back to plain rendering or ignore the addon action.
|
|
482
|
+
|
|
483
|
+
### Slot-machine HTML generator
|
|
484
|
+
|
|
485
|
+
`generateSlotMachineHtml` produces a self-contained five-reel Fruit Bonanza game with adjustable starting credits. It is a standalone HTML payload and performs no network requests.
|
|
486
|
+
|
|
487
|
+
| Option | Purpose |
|
|
488
|
+
| --- | --- |
|
|
489
|
+
| `title` | Display title for the generated page |
|
|
490
|
+
| `startingCredits` | Initial credit balance |
|
|
491
|
+
|
|
492
|
+
```javascript
|
|
493
|
+
import { generateSlotMachineHtml } from '@x4r1s3/baileys'
|
|
494
|
+
|
|
495
|
+
const html = generateSlotMachineHtml({
|
|
496
|
+
title: 'X4R1S3 Fruit Bonanza',
|
|
497
|
+
startingCredits: 500
|
|
498
|
+
})
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
The generator does not by itself send HTML through WhatsApp. Applications should only use an HTML-capable message primitive when that primitive is available and authorized for their deployment.
|
|
502
|
+
|
|
503
|
+
## Comparison references
|
|
504
|
+
|
|
505
|
+
The feature comparison was based on the published package metadata and documentation available from [npm][1] and the independent package analysis page at [Socket][2]. The X4R1S3 implementation adds compatible behavior through readable, package-owned code rather than copying upstream-specific integrity, attribution, or remote-verification mechanisms.
|
|
506
|
+
|
|
507
|
+
[1]: https://www.npmjs.com/
|
|
508
|
+
[2]: https://socket.dev/
|
|
509
|
+
|
|
510
|
+
## Additional functional compatibility helpers
|
|
511
|
+
|
|
512
|
+
The source also exposes portable helpers for native-flow responses, view-once inspection, rich content preparation, HTML payload construction, and website previews. These are functional compatibility APIs only; package-specific identity checks, attribution enforcement, remote license gates, trusted-channel auto-follow behavior, and other ownership structures are not included.
|
|
513
|
+
|
|
514
|
+
| Helper | Purpose |
|
|
515
|
+
| --- | --- |
|
|
516
|
+
| `parseNativeFlowResponse` | Normalize quick-reply, single-select, and Flow response envelopes |
|
|
517
|
+
| `parseWhatsAppFlowResponse` | Return only responses identified as WhatsApp Flow responses |
|
|
518
|
+
| `buildWhatsAppFlowButton` / `makeWhatsAppFlowButton` | Build published Flow button parameters for a caller-owned Flow ID and token |
|
|
519
|
+
| `prepareRichTextMessage` | Build a forwarded rich text response |
|
|
520
|
+
| `prepareRichImageMessage` | Build a forwarded rich image response |
|
|
521
|
+
| `prepareRichLinkMessage` | Build a forwarded response with inline link entities |
|
|
522
|
+
| `prepareRichGenerationMessage` | Build a rich response from caller-provided rich content |
|
|
523
|
+
| `prepareHtmlMessage` | Build an HTML primitive payload for clients that support the experimental structure |
|
|
524
|
+
| `prepareSlotMachineMessage` | Wrap the local slot-machine generator as an HTML message payload |
|
|
525
|
+
| `generateLinkPreviewHtml` / `generateWebsitePreviewHtml` | Create escaped link cards or an explicitly requested metadata preview |
|
|
526
|
+
| `parseViewOnceInfo` and related helpers | Inspect, download, reconstruct, and apply explicit view-once policies |
|
|
527
|
+
|
|
528
|
+
All networked helpers are opt-in. Website previews fetch only when explicitly called, and Flow helpers require credentials and identifiers owned by the application. Experimental WhatsApp layouts remain client-dependent and should always have a plain-text fallback.
|
|
529
|
+
|
|
530
|
+
## AI generation primitive
|
|
531
|
+
|
|
532
|
+
`buildImaginePrimitive` creates the Meta-style AI image or animation generation-state payload used by rich responses. It is a pure payload builder — it does not call a generation service itself, generate media, or send anything on its own; callers wire it up to whatever AI generation backend they use, then pass the resulting primitive into a rich-response message.
|
|
533
|
+
|
|
534
|
+
| Field | Purpose |
|
|
535
|
+
| --- | --- |
|
|
536
|
+
| `state` | Generation status: `GENERATING`, `COMPLETE`, or `ERROR` |
|
|
537
|
+
| `mediaUrl` | URL of the generated media
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
## X4R1S3-compatible rich messaging additions
|
|
541
|
+
|
|
542
|
+
The X4R1S3 socket now includes the compatible rich-message helpers documented by [`X4R1S3`](https://github.com/X4R1S3/baileys), while retaining X4R1S3-specific APIs and package identity. These helpers are opt-in convenience methods over the existing WhatsApp message relay layer.
|
|
543
|
+
|
|
544
|
+
| Helper | Purpose |
|
|
545
|
+
| --- | --- |
|
|
546
|
+
| `sendRichMedia` | Sends a complete GenAI-style rich response envelope. |
|
|
547
|
+
| `sendRichGeneration` | Sends an AI image/video generation card with a generation state. |
|
|
548
|
+
| `updateRichGeneration` | Replaces an existing generation card using the message-edit protocol. |
|
|
549
|
+
| `sendRichText` | Sends text inside a forwarded rich-response envelope. |
|
|
550
|
+
| `sendRichImage` | Sends an image inside a forwarded rich-response envelope. |
|
|
551
|
+
| `sendRichLink` | Sends inline links inside a forwarded rich-response envelope. |
|
|
552
|
+
| `sendReels` | Sends rich response content containing reel metadata. |
|
|
553
|
+
| `sendRichSources` | Sends rich response content with source metadata. |
|
|
554
|
+
| `sendLink` / `sendLinkV2` | Convenience aliases for rich inline-link responses. |
|
|
555
|
+
| `sendRichWebview` | Sends a native-flow URL CTA for a hosted WebView or Mini App. |
|
|
556
|
+
|
|
557
|
+
### Rich text, images, and links
|
|
558
|
+
|
|
559
|
+
```javascript
|
|
560
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
561
|
+
await sock.sendRichText(jid, {
|
|
562
|
+
text: 'A rich response from X4R1S3'
|
|
563
|
+
})
|
|
564
|
+
|
|
565
|
+
await sock.sendRichImage(jid, {
|
|
566
|
+
url: 'https://example.com/image.png',
|
|
567
|
+
mimeType: 'image/png'
|
|
568
|
+
})
|
|
569
|
+
|
|
570
|
+
await sock.sendRichLink(jid, {
|
|
571
|
+
text: 'Read the documentation',
|
|
572
|
+
links: [{ text: 'Documentation', url: 'https://example.com/docs' }]
|
|
573
|
+
})
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### AI generation cards
|
|
577
|
+
|
|
578
|
+
```javascript
|
|
579
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
580
|
+
const messageId = 'MESSAGE_ID_FROM_WHATSAPP'
|
|
581
|
+
const pending = await sock.sendRichGeneration(jid, {
|
|
582
|
+
text: 'Generating an image…',
|
|
583
|
+
mediaType: 'image',
|
|
584
|
+
status: 'GENERATING',
|
|
585
|
+
estimatedMs: 5000,
|
|
586
|
+
itemId: 'image-001'
|
|
587
|
+
})
|
|
588
|
+
|
|
589
|
+
await sock.updateRichGeneration(jid, pending.messageId, {
|
|
590
|
+
text: 'Generation complete',
|
|
591
|
+
mediaType: 'image',
|
|
592
|
+
status: 'READY',
|
|
593
|
+
url: 'https://example.com/generated.png',
|
|
594
|
+
itemId: 'image-001'
|
|
595
|
+
})
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
`updateRichGeneration` requires the original message identifier returned by `sendRichGeneration`. Generation and rich-response payloads are protocol-sensitive and should be tested against the WhatsApp clients your application supports.
|
|
599
|
+
|
|
600
|
+
### WebView or Mini App CTA
|
|
601
|
+
|
|
602
|
+
```javascript
|
|
603
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
604
|
+
await sock.sendRichWebview(jid, {
|
|
605
|
+
title: 'Open the dashboard',
|
|
606
|
+
text: 'Tap below to continue',
|
|
607
|
+
buttonText: 'Open dashboard',
|
|
608
|
+
url: 'https://example.com/dashboard',
|
|
609
|
+
useWebview: true,
|
|
610
|
+
toast: 'Opening dashboard'
|
|
611
|
+
})
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
The URL is validated before serialization. Treat button replies and URL destinations as untrusted input, and perform authorization on the server rather than relying on a button identifier.
|
|
615
|
+
|
|
616
|
+
### Reels and source metadata
|
|
617
|
+
|
|
618
|
+
```javascript
|
|
619
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
620
|
+
const quotedMessage = undefined
|
|
621
|
+
await sock.sendReels(jid, [{
|
|
622
|
+
url: 'https://example.com/reel.mp4',
|
|
623
|
+
title: 'Featured reel'
|
|
624
|
+
}], quotedMessage, { text: 'Featured today' })
|
|
625
|
+
|
|
626
|
+
await sock.sendRichSources(
|
|
627
|
+
jid,
|
|
628
|
+
'Useful references',
|
|
629
|
+
[{ title: 'Project site', url: 'https://example.com' }],
|
|
630
|
+
quotedMessage
|
|
631
|
+
)
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
These helpers preserve the existing `quoted` and send-option arguments where supported. The package does not enable background automation or contact discovery as a side effect of using them.
|
|
635
|
+
|
|
636
|
+
### References
|
|
637
|
+
|
|
638
|
+
[1]: https://github.com/X4R1S3/baileys "X4R1S3/baileys repository"
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
### Prepared-message relay targeting
|
|
642
|
+
|
|
643
|
+
`relayMessage` now accepts optional delivery-scoping controls compatible with X4R1S3’s relay API. These controls are intended for prepared messages and retry handling; use them only when the application understands the device-level delivery consequences.
|
|
644
|
+
|
|
645
|
+
```javascript
|
|
646
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
647
|
+
const messageId = 'MESSAGE_ID_FROM_WHATSAPP'
|
|
648
|
+
const preparedMessage = { conversation: 'Prepared message' }
|
|
649
|
+
await sock.relayMessage(jid, preparedMessage, {
|
|
650
|
+
messageId: 'message-id',
|
|
651
|
+
participant: { jid: '15551234567@s.whatsapp.net' },
|
|
652
|
+
protected: true
|
|
653
|
+
})
|
|
654
|
+
|
|
655
|
+
await sock.relayMessage(jid, preparedMessage, {
|
|
656
|
+
messageId: 'message-id',
|
|
657
|
+
retryParticipants: {
|
|
658
|
+
jid: '15551234567:2@s.whatsapp.net',
|
|
659
|
+
count: 1
|
|
660
|
+
}
|
|
661
|
+
})
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
The `participant` option targets recipient-only delivery in a one-to-one chat. `retryParticipants` or `participants` identifies a device for retry resend, while `isSecret`, `protected`, and `me` restrict delivery to the corresponding device classes. These options do not bypass WhatsApp permissions or authorization checks.
|
|
665
|
+
|
|
666
|
+
| Added helper | Purpose |
|
|
667
|
+
| --- | --- |
|
|
668
|
+
| `sendAlbumMessage` | Sends two or more image/video items as an album. |
|
|
669
|
+
| `sendRichTextCopy`, `sendMarkdownQuote`, `sendQuoteCopy` | Rich Markdown responses with optional copy-to-clipboard actions. |
|
|
670
|
+
| `sendBotDiagnostics`, `sendBotCommand`, `sendBotToolResult` | Experimental bot metadata envelopes for diagnostics, commands, and resolved tool calls. |
|
|
671
|
+
|
|
672
|
+
### Usage
|
|
673
|
+
|
|
674
|
+
```ts
|
|
675
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
676
|
+
await sock.sendAlbumMessage(jid, [
|
|
677
|
+
{ type: 'image', data: { url: './one.jpg' } },
|
|
678
|
+
{ type: 'image', data: { url: './two.jpg' } }
|
|
679
|
+
], { caption: 'Album caption' })
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
```ts
|
|
683
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
684
|
+
await sock.sendRichTextCopy(jid, {
|
|
685
|
+
text: '**Install command**\n\nnpm install @x4r1s3/baileys',
|
|
686
|
+
copyText: 'npm install @x4r1s3/baileys',
|
|
687
|
+
copyLabel: 'Copy command'
|
|
688
|
+
})
|
|
689
|
+
|
|
690
|
+
await sock.sendMarkdownQuote(jid, {
|
|
691
|
+
text: 'Instruction:\n\n> Use this exact configuration.'
|
|
692
|
+
})
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
Bot metadata helpers are experimental and should not be used as authorization or security controls.
|
|
696
|
+
|
|
697
|
+
```ts
|
|
698
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
699
|
+
const commandName = 'menu'
|
|
700
|
+
await sock.sendBotCommand(jid, {
|
|
701
|
+
text: 'Run deployment',
|
|
702
|
+
commandName: 'deploy',
|
|
703
|
+
commandDescription: 'Deploy the current build',
|
|
704
|
+
commandPrompt: 'Deploy the current build'
|
|
705
|
+
})
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
### Full-width stacked albums
|
|
712
|
+
|
|
713
|
+
`sendAlbumMessage` sends a rich vertical album rather than the legacy parent/child album collection. Each image or video is rendered as one large media item on its own row. Provide at least two publicly fetchable media URLs. Both `{ image: { url } }` and the typed `{ type: 'image', data: { url } }` forms are accepted.
|
|
714
|
+
|
|
715
|
+
```js
|
|
716
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
717
|
+
await sock.sendAlbumMessage(jid, [
|
|
718
|
+
{ image: { url: 'https://example.com/one.jpg' } },
|
|
719
|
+
{ image: { url: 'https://example.com/two.jpg' } },
|
|
720
|
+
{ image: { url: 'https://example.com/three.jpg' } }
|
|
721
|
+
], { caption: 'X4R1S3 album' })
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
The rich album path is URL-based and does not upload local buffers. Remove accidental whitespace from URLs before sending; the implementation trims URL values, but clean URLs are recommended.
|
|
725
|
+
|
|
726
|
+
### A2UI command menu
|
|
727
|
+
|
|
728
|
+
`sendA2UICommandMenu` sends the large command/function menu UI: an optional image header, title, command rows, URL buttons, and a native-flow fallback. The `rows` entries use `[command, description]` tuples, matching the menu layout shown in the WhatsApp client.
|
|
729
|
+
|
|
730
|
+
```js
|
|
731
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
732
|
+
await sock.sendA2UICommandMenu(jid, {
|
|
733
|
+
image: { url: 'https://example.com/menu.jpg' },
|
|
734
|
+
title: 'Speed menu',
|
|
735
|
+
rows: [
|
|
736
|
+
['.menu', 'Main menu'],
|
|
737
|
+
['.ping', 'Speed check']
|
|
738
|
+
],
|
|
739
|
+
buttons: [
|
|
740
|
+
{ text: 'Website', url: 'https://example.com' },
|
|
741
|
+
{ text: 'Support', url: 'https://example.com/support' }
|
|
742
|
+
]
|
|
743
|
+
})
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
### AIRich command menu and video grid
|
|
748
|
+
|
|
749
|
+
The compatibility update also exposes the two AIRich layouts that were not already present in X4R1S3. `sendAIRichCommandMenu` sends the manually serialized command card with an image, Markdown command table, optional widget CTAs, and footer URL actions. The image must be a publicly fetchable URL.
|
|
750
|
+
|
|
751
|
+
```ts
|
|
752
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
753
|
+
await sock.sendAIRichCommandMenu(jid, {
|
|
754
|
+
image: 'https://example.com/menu.png',
|
|
755
|
+
title: 'X4R1S3',
|
|
756
|
+
subtitle: 'Choose a command',
|
|
757
|
+
rows: [
|
|
758
|
+
['.menu', 'Show the main menu'],
|
|
759
|
+
['.ping', 'Check service latency']
|
|
760
|
+
],
|
|
761
|
+
buttons: [
|
|
762
|
+
{ id: 'docs', text: 'Documentation', url: 'https://example.com/docs' }
|
|
763
|
+
],
|
|
764
|
+
footer: 'Developed by - X4R1S3 INNOVATIONS'
|
|
765
|
+
})
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
`sendVideoGridMessage` sends at least two video URL items as a `GenAIGridLayoutViewModel` containing `GenAIVideoPrimitive` entries. It is separate from `sendAlbumMessage`, which uses the vertical album layout.
|
|
769
|
+
|
|
770
|
+
```ts
|
|
771
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
772
|
+
await sock.sendVideoGridMessage(jid, [
|
|
773
|
+
{
|
|
774
|
+
url: 'https://cdn.example.com/first.mp4',
|
|
775
|
+
title: 'First clip',
|
|
776
|
+
thumbnailUrl: 'https://cdn.example.com/first.jpg',
|
|
777
|
+
progressiveUrls: ['https://cdn.example.com/first-720p.mp4']
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
url: 'https://cdn.example.com/second.mp4',
|
|
781
|
+
title: 'Second clip',
|
|
782
|
+
thumbnailUrl: 'https://cdn.example.com/second.jpg'
|
|
783
|
+
}
|
|
784
|
+
])
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
Both layouts are experimental WhatsApp protocol structures. Client rendering can change, and callers should provide a plain-message fallback where reliability matters.
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
### Bot planning responses
|
|
791
|
+
|
|
792
|
+
`sendBotPlanning` sends a bot-planning rich response with a summary, ordered step text, and optional planning/query-plan capabilities.
|
|
793
|
+
|
|
794
|
+
```ts
|
|
795
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
796
|
+
await sock.sendBotPlanning(jid, {
|
|
797
|
+
text: 'Preparing the deployment',
|
|
798
|
+
steps: [
|
|
799
|
+
{ title: 'Build', body: 'Compile the application' },
|
|
800
|
+
{ title: 'Verify', body: 'Run the checks' },
|
|
801
|
+
'Publish the release'
|
|
802
|
+
],
|
|
803
|
+
queryPlan: true
|
|
804
|
+
})
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
### Newsletter invite metadata
|
|
808
|
+
|
|
809
|
+
`newsletterGetInviteInfo` accepts either a channel invite code or a WhatsApp channel invite URL and returns the resolved newsletter metadata, or `null` when WhatsApp does not return a matching record.
|
|
810
|
+
|
|
811
|
+
```ts
|
|
812
|
+
const info = await sock.newsletterGetInviteInfo('https://whatsapp.com/channel/INVITE_CODE')
|
|
813
|
+
console.log(info?.id, info?.name, info?.invite)
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
The lookup is an explicit network request and does not follow, join, or subscribe to the channel.
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
### Carousel, compatibility aliases, and source search
|
|
820
|
+
|
|
821
|
+
`sendCarousel` normalizes card media, captions, footers, and buttons before sending a carousel message.
|
|
822
|
+
|
|
823
|
+
```ts
|
|
824
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
825
|
+
await sock.sendCarousel(jid, [
|
|
826
|
+
{
|
|
827
|
+
title: 'Documentation',
|
|
828
|
+
body: { text: 'Read the API guide' },
|
|
829
|
+
media: { image: { url: 'https://example.com/docs.jpg' } },
|
|
830
|
+
buttons: [{ text: 'Open', id: 'docs' }]
|
|
831
|
+
}
|
|
832
|
+
])
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
`HoldOn` is retained as a compatibility alias for `sendRichButtonGrid`. New applications should prefer the descriptive X4R1S3-named method.
|
|
836
|
+
|
|
837
|
+
`grepCode(pattern, options)` searches installed package source files and returns matching file, line, column, and source-line information. It is an explicit diagnostic helper and performs no network access.
|
|
838
|
+
|
|
839
|
+
```ts
|
|
840
|
+
const matches = sock.grepCode('prepareVideoGridMessage', { includeReadme: true })
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
### Interactive rich HTML
|
|
844
|
+
|
|
845
|
+
The compatibility update also exposes `sendRichHtmlMessage`, which uses the interactive GenAI HTML primitive and supports embedded tabs. Only pass trusted, sanitized HTML; this is not a general-purpose HTML sanitizer.
|
|
846
|
+
|
|
847
|
+
```ts
|
|
848
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
849
|
+
await sock.sendRichHtmlMessage(jid, {
|
|
850
|
+
title: 'X4R1S3 INNOVATIONS',
|
|
851
|
+
html: '<h1>Hello</hi>',
|
|
852
|
+
url: 'https://X4R1S3-ai.site',
|
|
853
|
+
trustedSources: ['X4R1S3-ai.site']
|
|
854
|
+
})
|
|
855
|
+
```
|
|
856
|
+
|
|
857
|
+
Multiple tabs can be supplied with `tabs`; each tab may provide its own `html`, `url`, and `trustedSources`. The structure is experimental and depends on WhatsApp client support.
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
## X4R1S3 unified responses and the built-in mini-app
|
|
861
|
+
|
|
862
|
+
`sendX4R1S3Message` accepts one object containing any supported combination of text, links, media, products, reels, tables, code, LaTeX, or suggestions. Unsupported optional sections are ignored by the rich-response serializer, so callers can use one stable entry point for heterogeneous response data.
|
|
863
|
+
|
|
864
|
+
```js
|
|
865
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
866
|
+
await sock.sendX4R1S3Message(jid, {
|
|
867
|
+
text: 'Here is your result',
|
|
868
|
+
links: [{ text: 'Open the docs', url: 'https://example.com/docs' }],
|
|
869
|
+
table: {
|
|
870
|
+
title: 'Summary',
|
|
871
|
+
headers: ['Name', 'Status'],
|
|
872
|
+
rows: [['X4R1S3', 'Ready']]
|
|
873
|
+
}
|
|
874
|
+
})
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
`sendMiniApp` sends the bundled interactive mini-app as a trusted rich HTML screen. The helper does not fetch or execute caller-provided remote code; pass only presentation options such as `title` and keep authentication or business actions on your own server.
|
|
878
|
+
|
|
879
|
+
```js
|
|
880
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
881
|
+
await sock.sendMiniApp(jid, {
|
|
882
|
+
title: 'X4R1S3 mini-app'
|
|
883
|
+
}, {
|
|
884
|
+
quoted: message
|
|
885
|
+
})
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
The package also exports `BotCapabilityType`, `normalizeBotCapabilities`, `buildBotCapabilityMetadata`, and `buildBotRichResponse` for applications that need to construct compatible bot metadata.
|
|
889
|
+
|
|
890
|
+
### Combined RichAI and AIRich responses
|
|
891
|
+
|
|
892
|
+
`sendX4R1S3Message` can combine ordered RichAI sections with the package's other unified-response fields. This keeps text, tables, media, maps, and structured AIRich content in one message while preserving the order of the RichAI sections.
|
|
893
|
+
|
|
894
|
+
```js
|
|
895
|
+
await sock.sendX4R1S3Message(jid, {
|
|
896
|
+
sections: [
|
|
897
|
+
{ type: 'text', value: 'Mission summary' },
|
|
898
|
+
{ type: 'table', value: {
|
|
899
|
+
title: 'Telemetry',
|
|
900
|
+
headers: ['System', 'State'],
|
|
901
|
+
rows: [['Navigation', 'Nominal']]
|
|
902
|
+
} },
|
|
903
|
+
{ type: 'codeBlock', value: { language: 'js', code: 'return status' } }
|
|
904
|
+
],
|
|
905
|
+
richLabel: { text: 'X4R1S3 STATUS', variant: 'POSITIVE' }
|
|
906
|
+
})
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
Embedded-screen tabs can also carry one or more native media items. Multiple media items are rendered as a horizontal strip inside the tab.
|
|
910
|
+
|
|
911
|
+
```js
|
|
912
|
+
await sock.sendX4R1S3Message(jid, {
|
|
913
|
+
embeddedScreen: {
|
|
914
|
+
title: 'Mission gallery',
|
|
915
|
+
tabs: [{
|
|
916
|
+
id: 'gallery',
|
|
917
|
+
tab_header: 'Images',
|
|
918
|
+
sections: [{
|
|
919
|
+
__typename: 'GenAIUnifiedResponseSection',
|
|
920
|
+
view_model: { __typename: 'GenAISingleLayoutViewModel', primitive: {
|
|
921
|
+
__typename: 'GenAITextPrimitive', text: 'Orbital systems'
|
|
922
|
+
}}
|
|
923
|
+
}],
|
|
924
|
+
media: [
|
|
925
|
+
{ type: 'image', url: 'https://example.com/orbit-a.jpg' },
|
|
926
|
+
{ type: 'image', url: 'https://example.com/orbit-b.jpg' }
|
|
927
|
+
]
|
|
928
|
+
}]
|
|
929
|
+
}
|
|
930
|
+
})
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
Newsletter statuses support push-to-talk voice notes in addition to text, images, and video. The account must have Channel Status publishing capability.
|
|
934
|
+
|
|
935
|
+
```js
|
|
936
|
+
await sock.sendNewsletterStatus('123456789@newsletter', {
|
|
937
|
+
audio: { url: './mission-update.ogg' },
|
|
938
|
+
ptt: true,
|
|
939
|
+
backgroundArgb: 0xff1e88e5
|
|
940
|
+
})
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
## New AIRich metadata helpers
|
|
945
|
+
|
|
946
|
+
The package includes experimental helpers for protocol-backed rich clients. Rendering depends on the recipient's WhatsApp client version; these helpers do not call Meta AI or any private backend.
|
|
947
|
+
|
|
948
|
+
```js
|
|
949
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
950
|
+
await sock.sendA2UIMessage(jid, {
|
|
951
|
+
type: 'im_a2ui',
|
|
952
|
+
data: {
|
|
953
|
+
version: 'v0.9',
|
|
954
|
+
createSurface: {
|
|
955
|
+
surfaceId: 'custom-card',
|
|
956
|
+
catalogId: 'https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json',
|
|
957
|
+
components: [{ id: 'root', component: 'Column', children: ['title'] }]
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
})
|
|
961
|
+
|
|
962
|
+
await sock.sendRichMap(jid, {
|
|
963
|
+
centerLatitude: 6.5244,
|
|
964
|
+
centerLongitude: 3.3792,
|
|
965
|
+
annotations: [{ latitude: 6.53, longitude: 3.38, title: 'Lagos', body: 'Nigeria' }],
|
|
966
|
+
showInfoList: true
|
|
967
|
+
})
|
|
968
|
+
|
|
969
|
+
await sock.sendBotPromptSuggestions(jid, {
|
|
970
|
+
text: 'Choose a follow-up',
|
|
971
|
+
suggestions: ['Summarize this', 'Translate this', 'Explain further'],
|
|
972
|
+
selectedPromptId: 'translate'
|
|
973
|
+
})
|
|
974
|
+
|
|
975
|
+
await sock.sendBotSources(jid, {
|
|
976
|
+
text: 'Relevant sources:',
|
|
977
|
+
sources: [{
|
|
978
|
+
provider: 2,
|
|
979
|
+
url: 'https://example.com/docs',
|
|
980
|
+
query: 'baileys proto',
|
|
981
|
+
title: 'Documentation',
|
|
982
|
+
citationNumber: 1
|
|
983
|
+
}]
|
|
984
|
+
})
|
|
985
|
+
|
|
986
|
+
await sock.sendRichDynamicMedia(jid, {
|
|
987
|
+
type: 'IMAGE',
|
|
988
|
+
url: 'https://example.com/image.jpg',
|
|
989
|
+
version: 1
|
|
990
|
+
})
|
|
991
|
+
|
|
992
|
+
await sock.sendBotPttTranscript(jid, {
|
|
993
|
+
text: 'Voice transcript',
|
|
994
|
+
transcript: 'Hello, this text came from a voice message.'
|
|
995
|
+
})
|
|
996
|
+
|
|
997
|
+
await sock.sendSocialEntity(jid, {
|
|
998
|
+
platform: 'YOUTUBE',
|
|
999
|
+
username: 'example',
|
|
1000
|
+
title: 'Example creator',
|
|
1001
|
+
imageUrl: 'https://example.com/avatar.png',
|
|
1002
|
+
entityUrl: 'https://www.youtube.com/@example',
|
|
1003
|
+
isVerified: true,
|
|
1004
|
+
resultText: 'See results'
|
|
1005
|
+
})
|
|
1006
|
+
|
|
1007
|
+
await sock.sendInstagramProfile(jid, {
|
|
1008
|
+
username: 'example',
|
|
1009
|
+
title: 'Example profile',
|
|
1010
|
+
imageUrl: 'https://example.com/avatar.png',
|
|
1011
|
+
entityUrl: 'https://www.instagram.com/example',
|
|
1012
|
+
isVerified: true,
|
|
1013
|
+
resultText: 'See results'
|
|
1014
|
+
})
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
The map, prompt, source, dynamic-media, transcript, A2UI, and social/entity payloads are serialized from the generated `WAProto` structures. Validate URLs, button identifiers, and any user-supplied metadata in your own application before sending.
|
|
1018
|
+
|
|
1019
|
+
### Additional media, interaction, and scheduling helpers
|
|
1020
|
+
|
|
1021
|
+
The package also includes `replyButton`, `sendFile`, `sendPhotoLive`, `sendProgress`, `sendMessageModify`, `sendMessageModifyV2`, `sendNewRichMedia`, `sendUnifiedTable`, `scheduleMessage`, and `sendGroupStatus` compatibility helpers.
|
|
1022
|
+
|
|
1023
|
+
```js
|
|
1024
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1025
|
+
await sock.sendProgress(jid, 'Uploading', { progress: 65 })
|
|
1026
|
+
await sock.sendFile(jid, 'https://example.com/report.pdf', 'report.pdf', 'Latest report')
|
|
1027
|
+
await sock.sendPhotoLive(jid, {
|
|
1028
|
+
video: { url: 'https://example.com/motion.mp4' },
|
|
1029
|
+
image: { url: 'https://example.com/still.jpg' },
|
|
1030
|
+
caption: 'Motion photo'
|
|
1031
|
+
})
|
|
1032
|
+
await sock.scheduleMessage(jid, { text: 'Reminder' }, new Date(Date.now() + 60_000))
|
|
1033
|
+
```
|
|
1034
|
+
|
|
1035
|
+
### Polls with attached images
|
|
1036
|
+
|
|
1037
|
+
Image polls are a multi-message feature. Use `sendImagePoll` directly, or pass the same `poll` object to `sendMessage`. Each image option contains a `name` and an `image` source. The sender uploads each image, creates the poll option hashes, and relays the associated media-poll messages.
|
|
1038
|
+
|
|
1039
|
+
```js
|
|
1040
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1041
|
+
await sock.sendImagePoll(jid, {
|
|
1042
|
+
name: 'Choose a cover',
|
|
1043
|
+
selectableCount: 1,
|
|
1044
|
+
values: [
|
|
1045
|
+
{ name: 'Blue', image: { url: 'https://example.com/blue.jpg' } },
|
|
1046
|
+
{ name: 'Green', image: { url: 'https://example.com/green.jpg' } }
|
|
1047
|
+
]
|
|
1048
|
+
})
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
At least two options are required, and image polls require the configured Baileys media uploader. This is separate from ordinary text polls and does not add channel annotations or subscribe to any channel.
|
|
1052
|
+
|
|
1053
|
+
### Complete compatibility feature inventory
|
|
1054
|
+
|
|
1055
|
+
This build includes the complete published `X4R1S3` compatibility surface: authentication and pairing; text, mentions, reactions, edits, deletes, forwards, polls, events, view-once messages, stickers, sticker packs, sticker annotations, albums, live photos, video grids, GIF playback, buttons, reminder actions, lists, native flows, carousels, hydrated templates, interactive contacts, map/location cards, rich text, Markdown quotes, copy actions, rich images, link previews, unified responses, tables, code blocks, LaTeX, AIRich, A2UI, rich menus, reels, HTML screens, mini-apps, status updates, status actions, status mentions, custom status audiences, group status, newsletter/channel management, group and community management, labels, business and catalog helpers, favorites, privacy controls, usernames, password and passkey utilities, AI groups, Meta AI prompts, planning metadata, social/profile cards, bot diagnostics, media processing, app-state utilities, interop helpers, and the `X4R1S3` target-message helper.
|
|
1056
|
+
|
|
1057
|
+
Representative usage is documented below for sticker annotations, unified responses, A2UI command menus, image polls, live photos, social cards, reactions, stickers, scheduled messages, and profile-picture lookup.
|
|
1058
|
+
|
|
1059
|
+
## X4R1S3-compatible additions
|
|
1060
|
+
|
|
1061
|
+
The complete build also includes the compatible A2UI, AIRich, carousel, poll, live-photo, unified-response, newsletter-status, and sticker-annotation helpers. These are opt-in APIs over the existing socket and do not change ordinary `sendMessage()` behavior.
|
|
1062
|
+
|
|
1063
|
+
### Reminder buttons and metadata
|
|
1064
|
+
|
|
1065
|
+
The `Button` builder now supports native reminder actions. The display text and reminder ID are written into the native-flow payload, while additional provider-specific fields can be supplied through the options object.
|
|
1066
|
+
|
|
1067
|
+
```js
|
|
1068
|
+
import { Button } from '@x4r1s3/baileys'
|
|
1069
|
+
|
|
1070
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1071
|
+
const reminderCard = new Button(sock)
|
|
1072
|
+
.setTitle('Daily routine')
|
|
1073
|
+
.setBody('Would you like a reminder?')
|
|
1074
|
+
.addReminder('Set reminder', 'daily-routine', {
|
|
1075
|
+
frequency: 'DAILY'
|
|
1076
|
+
})
|
|
1077
|
+
.addCancelReminder('Cancel reminder', 'daily-routine')
|
|
1078
|
+
|
|
1079
|
+
await reminderCard.send(jid)
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
An AIRich response can also carry validated `BotReminderMetadata`:
|
|
1083
|
+
|
|
1084
|
+
```js
|
|
1085
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1086
|
+
const requestMessageKey = {
|
|
1087
|
+
remoteJid: jid,
|
|
1088
|
+
fromMe: false,
|
|
1089
|
+
id: 'REQUEST_MESSAGE_ID'
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
await sock.sendX4R1S3Message(jid, {
|
|
1093
|
+
contentText: 'Reminder created.',
|
|
1094
|
+
reminderMetadata: {
|
|
1095
|
+
requestMessageKey,
|
|
1096
|
+
action: 'CREATE',
|
|
1097
|
+
name: 'Water the plants',
|
|
1098
|
+
frequency: 'DAILY',
|
|
1099
|
+
nextTriggerTimestamp: String(Math.floor(Date.now() / 1000) + 86400)
|
|
1100
|
+
}
|
|
1101
|
+
})
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
`action` accepts `NOTIFY`, `CREATE`, `DELETE`, or `UPDATE`. `frequency` accepts `ONCE`, `DAILY`, `WEEKLY`, `BIWEEKLY`, or `MONTHLY`. Reminder scheduling and rendering remain client-dependent.
|
|
1105
|
+
|
|
1106
|
+
### Status actions
|
|
1107
|
+
|
|
1108
|
+
Status actions are available through the existing `messages.upsert` stream. Reactions and protocol messages are excluded from status detection, so a status listener does not treat a status reaction as a new story.
|
|
1109
|
+
|
|
1110
|
+
```js
|
|
1111
|
+
const stopStatusListener = sock.onStatusMessage(async ({ message, authorJid, kind }) => {
|
|
1112
|
+
if (kind === 'status') {
|
|
1113
|
+
await sock.viewStatus(message)
|
|
1114
|
+
await sock.likeStatus(message, '✅')
|
|
1115
|
+
// For media statuses only:
|
|
1116
|
+
// const media = await sock.downloadStatus(message, 'buffer')
|
|
1117
|
+
// await sock.commentStatus(message, 'Nice update!')
|
|
1118
|
+
} else {
|
|
1119
|
+
await sock.viewGroupStatus(message)
|
|
1120
|
+
await sock.likeGroupStatus(message, '🔥')
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
console.log('Status author:', authorJid)
|
|
1124
|
+
}, {
|
|
1125
|
+
from: 'all',
|
|
1126
|
+
includeGroupStatus: true
|
|
1127
|
+
})
|
|
1128
|
+
|
|
1129
|
+
// Later, detach it with: stopStatusListener()
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
### Sticker annotation
|
|
1133
|
+
|
|
1134
|
+
```js
|
|
1135
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1136
|
+
const messageKey = { remoteJid: jid, fromMe: false, id: messageId, participant: userJid }
|
|
1137
|
+
const stickerMessage = { url: './sticker.webp', isAnimated: false }
|
|
1138
|
+
await sock.sendStickerAnnotation(jid, {
|
|
1139
|
+
parentMessageKey: messageKey,
|
|
1140
|
+
stickerMessage: stickerMessage,
|
|
1141
|
+
count: 3,
|
|
1142
|
+
intervalMs: 1000
|
|
1143
|
+
})
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
### Unified response and A2UI
|
|
1147
|
+
|
|
1148
|
+
```js
|
|
1149
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1150
|
+
await sock.sendUnifiedResponse(jid, {
|
|
1151
|
+
sections: [{
|
|
1152
|
+
view_model: {
|
|
1153
|
+
primitives: [{ __typename: 'GenAIQueryPlanPrimitive', title: 'Plan' }]
|
|
1154
|
+
}
|
|
1155
|
+
}]
|
|
1156
|
+
})
|
|
1157
|
+
|
|
1158
|
+
await sock.sendA2UICommandMenu(jid, {
|
|
1159
|
+
title: 'Commands',
|
|
1160
|
+
commands: [{ id: 'help', label: 'Help' }]
|
|
1161
|
+
})
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
### Polls, live photos, and social cards
|
|
1165
|
+
|
|
1166
|
+
```js
|
|
1167
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1168
|
+
await sock.sendImagePoll(jid, {
|
|
1169
|
+
name: 'Choose a cover',
|
|
1170
|
+
selectableCount: 1,
|
|
1171
|
+
values: [
|
|
1172
|
+
{ name: 'Blue', image: { url: 'https://example.com/blue.jpg' } },
|
|
1173
|
+
{ name: 'Green', image: { url: 'https://example.com/green.jpg' } }
|
|
1174
|
+
]
|
|
1175
|
+
})
|
|
1176
|
+
|
|
1177
|
+
await sock.sendPhotoLive(jid, {
|
|
1178
|
+
video: { url: './motion.mp4' },
|
|
1179
|
+
image: { url: './still.jpg' },
|
|
1180
|
+
caption: 'Motion photo'
|
|
1181
|
+
})
|
|
1182
|
+
|
|
1183
|
+
await sock.sendSocialProfile(jid, {
|
|
1184
|
+
platform: 'linkedin',
|
|
1185
|
+
entityType: 'LINKEDIN_PROFILE',
|
|
1186
|
+
username: 'example',
|
|
1187
|
+
entityUrl: 'https://www.linkedin.com/in/example'
|
|
1188
|
+
})
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
### Profile-picture behavior
|
|
1192
|
+
|
|
1193
|
+
The package supports authorized profile-picture lookup with `profilePictureUrl(jid, 'image')` and legitimate social/profile cards. It does **not** spoof a sender or force viewers to see another person's profile picture when a command runs. Any profile-picture sharing must be explicitly initiated by the application and must respect the target user's privacy and consent.
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
## Interactive contact card
|
|
1197
|
+
|
|
1198
|
+
```js
|
|
1199
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1200
|
+
const commandName = 'menu'
|
|
1201
|
+
const commandOutput = 'X4R1S3 command completed'
|
|
1202
|
+
|
|
1203
|
+
await sock.sendInteractiveContactCard(jid, {
|
|
1204
|
+
title: 'X4R1S3',
|
|
1205
|
+
body: commandOutput,
|
|
1206
|
+
footer: 'X4R1S3 INNOVATIONS',
|
|
1207
|
+
buttonParams: {
|
|
1208
|
+
command: commandName,
|
|
1209
|
+
status: 'completed'
|
|
1210
|
+
}
|
|
1211
|
+
})
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1214
|
+
## X4R1S3 target-message protocol helper
|
|
1215
|
+
|
|
1216
|
+
`X4R1S3(jid, target)` runs the experimental target-message protocol sequence, then cleans up its temporary messages. The target may be a message ID string or an object containing `id` or `stanzaId`.
|
|
1217
|
+
|
|
1218
|
+
```js
|
|
1219
|
+
const jid = '15551234567@s.whatsapp.net'
|
|
1220
|
+
const messageId = 'MESSAGE_ID_FROM_WHATSAPP'
|
|
1221
|
+
await sock.X4R1S3(jid, { id: messageId })
|
|
1222
|
+
```
|
|
1223
|
+
|
|
1224
|
+
## Community and contact
|
|
1225
|
+
|
|
1226
|
+
<div align="center">
|
|
1227
|
+
|
|
1228
|
+
[](https://whatsapp.com/channel/0029Vb78BHmL2AU7fsANSH2y)
|
|
1229
|
+
[](https://whatsapp.com/channel/0029Vb6sMEy96H4VI2w3I50F)
|
|
1230
|
+
[](https://chat.whatsapp.com/L5gckU4nNCq3bTH45tLB37?s=cl&p=a&iam=2)
|
|
1231
|
+
[](https://t.me/X4R1S3_INNOVATIONS)
|
|
1232
|
+
[](https://t.me/X4R1S3V3)
|
|
1233
|
+
[](https://codex-ai.site)
|
|
1234
|
+
[](https://t.me/X4R1S3)
|
|
1235
|
+
|
|
1236
|
+
[](mailto:x4r1s3@gmail.com)
|
|
1237
|
+
|
|
1238
|
+
</div>
|
|
1239
|
+
|
|
1240
|
+
<div align="center">
|
|
1241
|
+
|
|
1242
|
+
<sub>Thanks for reading my README.</sub>
|
|
1243
|
+
|
|
1244
|
+
[](https://github.com/X4R1S3/baileys)
|
|
1245
|
+
|
|
1246
|
+
</div>
|