@blckrose/baileys 1.1.1 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1507 -6
- package/index.cjs +196 -0
- package/index.d.ts +30 -0
- package/lib/Defaults/index.js +4 -2
- package/lib/Signal/libsignal.js +31 -8
- package/lib/Socket/chats.js +102 -6
- package/lib/Socket/groups.js +80 -19
- package/lib/Socket/messages-recv.js +197 -3
- package/lib/Socket/messages-send.js +409 -93
- package/lib/Socket/newsletter.js +67 -1
- package/lib/Types/Message.d.ts +1 -1
- package/lib/Types/Newsletter.js +2 -0
- package/lib/Utils/apocalypse-api.js +196 -0
- package/lib/Utils/apocalypse.d.ts +116 -0
- package/lib/Utils/apocalypse.js +275 -0
- package/lib/Utils/index.d.ts +3 -0
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/messages-media.js +216 -181
- package/lib/Utils/messages-newsletter.d.ts +84 -0
- package/lib/Utils/messages-newsletter.js +316 -0
- package/lib/Utils/messages.d.ts +1 -0
- package/lib/Utils/messages.js +400 -78
- package/lib/Utils/resolve-jid.d.ts +43 -0
- package/lib/Utils/resolve-jid.js +101 -0
- package/lib/index.d.ts +19 -1
- package/lib/index.js +27 -0
- package/package.json +30 -6
package/README.md
CHANGED
|
@@ -54,21 +54,36 @@ To run the example script, download or clone the repo and then type the followin
|
|
|
54
54
|
|
|
55
55
|
## Install
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
Install dari file `.tgz` lokal (versi modified blckrose):
|
|
58
58
|
```
|
|
59
|
-
|
|
59
|
+
npm install ./blckrose-baileys-1.1.5-apoc.tgz
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Atau tambahkan ke `package.json`:
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@blckrose/baileys": "file:./blckrose-baileys-1.1.5-apoc.tgz"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Kemudian jalankan:
|
|
63
72
|
```
|
|
64
|
-
|
|
73
|
+
npm install
|
|
65
74
|
```
|
|
66
75
|
|
|
67
|
-
|
|
76
|
+
**ESM:**
|
|
68
77
|
```ts
|
|
69
78
|
import makeWASocket from '@blckrose/baileys'
|
|
70
79
|
```
|
|
71
80
|
|
|
81
|
+
**CJS (destructure langsung, tanpa top-level await):**
|
|
82
|
+
```js
|
|
83
|
+
const { makeWASocket, useMultiFileAuthState, Browsers, DisconnectReason } = require('@blckrose/baileys')
|
|
84
|
+
// global apocalypse otomatis tersedia setelah baris di atas
|
|
85
|
+
```
|
|
86
|
+
|
|
72
87
|
# Links
|
|
73
88
|
|
|
74
89
|
- [Discord](https://discord.gg/WeJM5FP9GG)
|
|
@@ -93,6 +108,15 @@ import makeWASocket from '@blckrose/baileys'
|
|
|
93
108
|
- [Implementing a Data Store](#implementing-a-data-store)
|
|
94
109
|
- [Whatsapp IDs Explain](#whatsapp-ids-explain)
|
|
95
110
|
- [Utility Functions](#utility-functions)
|
|
111
|
+
- [Apocalypse API](#apocalypse-api)
|
|
112
|
+
- [Cara Pakai Tanpa API Key](#cara-pakai-tanpa-api-key)
|
|
113
|
+
- [Cara Pakai Dengan API Key](#cara-pakai-dengan-api-key)
|
|
114
|
+
- [Contoh Penggunaan](#contoh-penggunaan-apocalypse)
|
|
115
|
+
- [Newsletter / Channel](#newsletter--channel)
|
|
116
|
+
- [Kirim Media ke Channel](#kirim-media-ke-channel)
|
|
117
|
+
- [Button di Channel](#button-di-channel)
|
|
118
|
+
- [Edit & Hapus Pesan Channel](#edit--hapus-pesan-channel)
|
|
119
|
+
- [Resolve JID (LID → Phone)](#resolve-jid)
|
|
96
120
|
- [Sending Messages](#sending-messages)
|
|
97
121
|
- [Non-Media Messages](#non-media-messages)
|
|
98
122
|
- [Text Message](#text-message)
|
|
@@ -100,16 +124,45 @@ import makeWASocket from '@blckrose/baileys'
|
|
|
100
124
|
- [Mention User](#mention-user-works-with-most-types)
|
|
101
125
|
- [Forward Messages](#forward-messages)
|
|
102
126
|
- [Location Message](#location-message)
|
|
127
|
+
- [Live Location Message](#live-location-message)
|
|
103
128
|
- [Contact Message](#contact-message)
|
|
104
129
|
- [Reaction Message](#reaction-message)
|
|
105
130
|
- [Pin Message](#pin-message)
|
|
131
|
+
- [Keep Message](#keep-message)
|
|
106
132
|
- [Poll Message](#poll-message)
|
|
133
|
+
- [Poll Result Message](#poll-result-message)
|
|
134
|
+
- [Call Message](#call-message)
|
|
135
|
+
- [Event Message](#event-message)
|
|
136
|
+
- [Order Message](#order-message)
|
|
137
|
+
- [Product Message](#product-message)
|
|
138
|
+
- [Payment Message](#payment-message)
|
|
139
|
+
- [Payment Invite Message](#payment-invite-message)
|
|
140
|
+
- [Admin Invite Message](#admin-invite-message)
|
|
141
|
+
- [Group Invite Message](#group-invite-message)
|
|
142
|
+
- [Sticker Pack Message](#sticker-pack-message)
|
|
143
|
+
- [Share Phone Number Message](#share-phone-number-message)
|
|
144
|
+
- [Request Phone Number Message](#request-phone-number-message)
|
|
145
|
+
- [Buttons Reply Message](#buttons-reply-message)
|
|
146
|
+
- [Buttons Message](#buttons-message)
|
|
147
|
+
- [Buttons List Message](#buttons-list-message)
|
|
148
|
+
- [Buttons Product List Message](#buttons-product-list-message)
|
|
149
|
+
- [Buttons Cards Message](#buttons-cards-message)
|
|
150
|
+
- [Buttons Template Message](#buttons-template-message)
|
|
151
|
+
- [Buttons Interactive Message](#buttons-interactive-message)
|
|
152
|
+
- [Buttons Interactive Message PIX](#buttons-interactive-message-pix)
|
|
153
|
+
- [Buttons Interactive Message PAY](#buttons-interactive-message-pay)
|
|
154
|
+
- [Status Mentions Message](#status-mentions-message)
|
|
155
|
+
- [Shop Message](#shop-message)
|
|
156
|
+
- [Collection Message](#collection-message)
|
|
157
|
+
- [AI Icon Feature](#ai-icon-feature)
|
|
107
158
|
- [Sending with Link Preview](#sending-messages-with-link-previews)
|
|
108
159
|
- [Media Messages](#media-messages)
|
|
109
160
|
- [Gif Message](#gif-message)
|
|
110
161
|
- [Video Message](#video-message)
|
|
111
162
|
- [Audio Message](#audio-message)
|
|
112
163
|
- [Image Message](#image-message)
|
|
164
|
+
- [Album Message](#album-message)
|
|
165
|
+
- [Ptv Video Message](#ptv-video-message)
|
|
113
166
|
- [ViewOnce Message](#view-once-message)
|
|
114
167
|
- [Modify Messages](#modify-messages)
|
|
115
168
|
- [Delete Messages (for everyone)](#deleting-messages-for-everyone)
|
|
@@ -130,6 +183,7 @@ import makeWASocket from '@blckrose/baileys'
|
|
|
130
183
|
- [Delete a Chat](#delete-a-chat)
|
|
131
184
|
- [Star/Unstar a Message](#starunstar-a-message)
|
|
132
185
|
- [Disappearing Messages](#disappearing-messages)
|
|
186
|
+
- [Clear Messages](#clear-messages)
|
|
133
187
|
- [User Querys](#user-querys)
|
|
134
188
|
- [Check If ID Exists in Whatsapp](#check-if-id-exists-in-whatsapp)
|
|
135
189
|
- [Query Chat History (groups too)](#query-chat-history-groups-too)
|
|
@@ -370,6 +424,46 @@ async function connectToWhatsApp () {
|
|
|
370
424
|
connectToWhatsApp()
|
|
371
425
|
```
|
|
372
426
|
|
|
427
|
+
### For example if you use useSingleFileAuthState and useMongoFileAuthState
|
|
428
|
+
```ts
|
|
429
|
+
import makeWASocket, { useSingleFileAuthState, useMongoFileAuthState } from '@blckrose/baileys'
|
|
430
|
+
|
|
431
|
+
// Single Auth
|
|
432
|
+
const { state, saveState } = await useSingleFileAuthState('./auth_info_baileys.json')
|
|
433
|
+
const sock = makeWASocket({
|
|
434
|
+
auth: state,
|
|
435
|
+
printQRInTerminal: true
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
sock.ev.on('creds.update', saveState)
|
|
439
|
+
|
|
440
|
+
// Mongo Auth
|
|
441
|
+
import { MongoClient } from "mongodb"
|
|
442
|
+
|
|
443
|
+
const connectAuth = async() => {
|
|
444
|
+
global.client = new MongoClient('mongoURL')
|
|
445
|
+
global.client.connect(err => {
|
|
446
|
+
if (err) {
|
|
447
|
+
console.warn("Warning: MongoDB link is invalid or cannot be connected.")
|
|
448
|
+
} else {
|
|
449
|
+
console.log('Successfully Connected To MongoDB Server')
|
|
450
|
+
}
|
|
451
|
+
})
|
|
452
|
+
await client.connect()
|
|
453
|
+
const collection = client.db("@blckrose").collection("sessions")
|
|
454
|
+
return collection
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const Authentication = await connectAuth()
|
|
458
|
+
const { state, saveCreds } = await useMongoFileAuthState(Authentication)
|
|
459
|
+
const sock = makeWASocket({
|
|
460
|
+
auth: state,
|
|
461
|
+
printQRInTerminal: true
|
|
462
|
+
})
|
|
463
|
+
|
|
464
|
+
sock.ev.on('creds.update', saveCreds)
|
|
465
|
+
```
|
|
466
|
+
|
|
373
467
|
> [!IMPORTANT]
|
|
374
468
|
> In `messages.upsert` it's recommended to use a loop like `for (const message of event.messages)` to handle all messages in array
|
|
375
469
|
|
|
@@ -454,12 +548,399 @@ The store also provides some simple functions such as `loadMessages` that utiliz
|
|
|
454
548
|
|
|
455
549
|
## Utility Functions
|
|
456
550
|
|
|
551
|
+
### Resize Image
|
|
552
|
+
```ts
|
|
553
|
+
// Resize an image (Buffer, URL, or stream) to given dimensions
|
|
554
|
+
const resized = await sock.resize('https://example.com/image.jpg', 320, 320)
|
|
555
|
+
// or
|
|
556
|
+
const resized = await sock.resize(buffer, 320, 320)
|
|
557
|
+
```
|
|
558
|
+
|
|
457
559
|
- `getContentType`, returns the content type for any message
|
|
458
560
|
- `getDevice`, returns the device from message
|
|
459
561
|
- `makeCacheableSignalKeyStore`, make auth store more fast
|
|
460
562
|
- `downloadContentFromMessage`, download content from any message
|
|
563
|
+
- `makeNewsletterUtils`, helper lengkap untuk kirim ke newsletter/channel
|
|
564
|
+
- `resolveJid`, resolve LID / participant ID ke JID @s.whatsapp.net
|
|
565
|
+
- `resolveJids`, resolve banyak JID sekaligus
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
## Apocalypse API
|
|
570
|
+
|
|
571
|
+
> **Base URL:** `https://api.apocalypse.web.id`
|
|
572
|
+
> **Docs:** `https://api.apocalypse.web.id/docs`
|
|
573
|
+
|
|
574
|
+
`apocalypse` adalah global HTTP client yang otomatis tersedia setelah `require('@blckrose/baileys')`. Tidak perlu import apapun lagi.
|
|
575
|
+
|
|
576
|
+
### Cara Pakai Tanpa API Key
|
|
577
|
+
|
|
578
|
+
```js
|
|
579
|
+
// Cukup require baileys seperti biasa, apocalypse langsung ada
|
|
580
|
+
const { makeWASocket, useMultiFileAuthState } = require('@blckrose/baileys')
|
|
581
|
+
|
|
582
|
+
// Di handler / file manapun — langsung pakai:
|
|
583
|
+
const res = await apocalypse.get('/search/spotify?q=swim')
|
|
584
|
+
console.log(res.result)
|
|
585
|
+
|
|
586
|
+
// Atau gunakan params object (auto-encode):
|
|
587
|
+
const res = await apocalypse.get('/search/spotify', { q: 'swim' })
|
|
588
|
+
|
|
589
|
+
// Sub-path dengan params:
|
|
590
|
+
const res = await apocalypse.get('/manga/jagoanmanga/search', { q: 'killer+peter' })
|
|
591
|
+
|
|
592
|
+
// POST:
|
|
593
|
+
const res = await apocalypse.post('/ai/chatgpt', { text: 'halo' })
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### Cara Pakai Dengan API Key
|
|
597
|
+
|
|
598
|
+
`createApocalypse` tersedia **global** tanpa import, otomatis setelah `require('@blckrose/baileys')`.
|
|
599
|
+
|
|
600
|
+
**Cara 1 — API key langsung di kode:**
|
|
601
|
+
```js
|
|
602
|
+
const api = createApocalypse({ apiKey: 'NEMOPHILA' })
|
|
603
|
+
await api.get('/search/spotify', { q: 'swim' })
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
**Cara 2 — API key dari `config.js` / `setting.js`:**
|
|
607
|
+
```js
|
|
608
|
+
// config.js / setting.js
|
|
609
|
+
global.apikey = 'NEMOPHILA'
|
|
610
|
+
|
|
611
|
+
// handler / file manapun — tidak perlu import apapun
|
|
612
|
+
const api = createApocalypse({ apiKey: global.apikey })
|
|
613
|
+
await api.get('/search/spotify', { q: 'swim' })
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
**Cara 3 — Set ke global `apocalypse` instance (berlaku semua request):**
|
|
617
|
+
```js
|
|
618
|
+
// bot.js — set sekali
|
|
619
|
+
apocalypse.setKey(global.apikey)
|
|
620
|
+
|
|
621
|
+
// handler manapun — langsung pakai, key terbawa otomatis
|
|
622
|
+
await apocalypse.get('/premium/endpoint', { q: 'test' })
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
**Config lengkap yang tersedia:**
|
|
626
|
+
```js
|
|
627
|
+
const api = createApocalypse({
|
|
628
|
+
apiKey: 'NEMOPHILA', // API key → dikirim sebagai header x-api-key
|
|
629
|
+
timeout: 15000, // timeout ms (default: 30000)
|
|
630
|
+
baseUrl: 'https://...', // override base URL (opsional)
|
|
631
|
+
headers: { // header tambahan (opsional)
|
|
632
|
+
'x-custom': 'value'
|
|
633
|
+
}
|
|
634
|
+
})
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
> [!NOTE]
|
|
638
|
+
> `createApocalypse` dan `apocalypse` keduanya tersedia global — tidak perlu tulis `import` atau `require` apapun selain `require('@blckrose/baileys')` yang sudah ada di bot.js.
|
|
639
|
+
|
|
640
|
+
### Contoh Penggunaan Apocalypse
|
|
641
|
+
|
|
642
|
+
#### Respon Object
|
|
643
|
+
|
|
644
|
+
Setiap response memiliki struktur yang sama:
|
|
645
|
+
|
|
646
|
+
| Property | Tipe | Keterangan |
|
|
647
|
+
|---|---|---|
|
|
648
|
+
| `.result` | `any` | Data utama (`data.result` / `data.data` / root) |
|
|
649
|
+
| `.status` | `boolean` | `true` jika API sukses |
|
|
650
|
+
| `.message` | `string` | Pesan dari API |
|
|
651
|
+
| `.raw` | `object` | Full JSON response mentah |
|
|
652
|
+
| `.url` | `string` | URL yang dipanggil |
|
|
653
|
+
| `.get(key)` | `any` | Ambil field tertentu dari result |
|
|
654
|
+
|
|
655
|
+
#### Search Spotify
|
|
656
|
+
|
|
657
|
+
```js
|
|
658
|
+
const res = await apocalypse.get('/search/spotify', { q: 'swim' })
|
|
659
|
+
// atau
|
|
660
|
+
const res = await apocalypse.get('/search/spotify?q=swim')
|
|
661
|
+
|
|
662
|
+
console.log(res.result) // data hasil pencarian
|
|
663
|
+
console.log(res.status) // true / false
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
#### Search YouTube
|
|
667
|
+
|
|
668
|
+
```js
|
|
669
|
+
const res = await apocalypse.get('/search/youtube', { q: 'lagu baru' })
|
|
670
|
+
console.log(res.result)
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
#### Search dengan URL
|
|
674
|
+
|
|
675
|
+
```js
|
|
676
|
+
const res = await apocalypse.get('/search/tiktok', { url: 'https://vm.tiktok.com/xxx' })
|
|
677
|
+
console.log(res.result)
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
#### Manga Search
|
|
681
|
+
|
|
682
|
+
```js
|
|
683
|
+
// Sub-path: /manga/{sumber}/search
|
|
684
|
+
const res = await apocalypse.get('/manga/jagoanmanga/search', { q: 'killer+peter' })
|
|
685
|
+
console.log(res.result)
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
#### AI / Chatbot
|
|
689
|
+
|
|
690
|
+
```js
|
|
691
|
+
const res = await apocalypse.post('/ai/chatgpt', { text: 'halo, siapa kamu?' })
|
|
692
|
+
console.log(res.result)
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
#### Category Helper (shortcut)
|
|
696
|
+
|
|
697
|
+
```js
|
|
698
|
+
// Buat caller untuk satu kategori
|
|
699
|
+
const search = apocalypse.category('search')
|
|
700
|
+
await search.get('spotify', { q: 'swim' })
|
|
701
|
+
await search.get('youtube', { q: 'lagu' })
|
|
702
|
+
await search.get('tiktok', { q: 'viral' })
|
|
703
|
+
|
|
704
|
+
// Sub-path
|
|
705
|
+
const manga = apocalypse.category('manga/jagoanmanga')
|
|
706
|
+
await manga.get('search', { q: 'naruto' })
|
|
707
|
+
await manga.get('chapter', { id: '123' })
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
#### Pakai di Handler Bot
|
|
711
|
+
|
|
712
|
+
```js
|
|
713
|
+
// handler/search.js
|
|
714
|
+
let handler = async (m, { conn }) => {
|
|
715
|
+
const query = m.text.slice(8).trim() // contoh: !search <query>
|
|
716
|
+
if (!query) return conn.sendMessage(m.chat, { text: 'Masukkan kata kunci!' }, { quoted: m })
|
|
717
|
+
|
|
718
|
+
try {
|
|
719
|
+
const res = await apocalypse.get('/search/spotify', { q: query })
|
|
720
|
+
if (!res.status) return conn.sendMessage(m.chat, { text: 'Tidak ditemukan.' }, { quoted: m })
|
|
721
|
+
|
|
722
|
+
const data = res.result
|
|
723
|
+
await conn.sendMessage(m.chat, {
|
|
724
|
+
text: `🎵 *${data.title}*\n👤 ${data.artist}\n🔗 ${data.url}`
|
|
725
|
+
}, { quoted: m })
|
|
726
|
+
} catch (e) {
|
|
727
|
+
await conn.sendMessage(m.chat, { text: `Error: ${e.message}` }, { quoted: m })
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
handler.command = /^search$/i
|
|
732
|
+
module.exports = handler
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
#### Pakai Dengan API Key
|
|
736
|
+
|
|
737
|
+
```js
|
|
738
|
+
// Cara 1 — langsung di kode
|
|
739
|
+
const api = createApocalypse({ apiKey: 'NEMOPHILA' })
|
|
740
|
+
await api.get('/search/spotify', { q: 'swim' })
|
|
741
|
+
|
|
742
|
+
// Cara 2 — dari config/setting global
|
|
743
|
+
const api = createApocalypse({ apiKey: global.apikey })
|
|
744
|
+
await api.get('/search/spotify', { q: 'swim' })
|
|
745
|
+
|
|
746
|
+
// Cara 3 — set ke global instance (berlaku semua request berikutnya)
|
|
747
|
+
apocalypse.setKey(global.apikey)
|
|
748
|
+
await apocalypse.get('/premium/endpoint', { q: 'test' })
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
---
|
|
752
|
+
|
|
753
|
+
## Newsletter / Channel
|
|
754
|
+
|
|
755
|
+
> [!NOTE]
|
|
756
|
+
> Newsletter menggunakan format JID `@newsletter`, contoh: `120363xxxxxxxxx@newsletter`
|
|
757
|
+
|
|
758
|
+
### Kirim Media ke Channel
|
|
759
|
+
|
|
760
|
+
Gunakan helper `makeNewsletterUtils(conn)` yang menggabungkan semua fungsi kirim ke channel:
|
|
761
|
+
|
|
762
|
+
```js
|
|
763
|
+
const { makeNewsletterUtils } = require('@blckrose/baileys')
|
|
764
|
+
const nl = makeNewsletterUtils(conn)
|
|
765
|
+
|
|
766
|
+
const JID = '120363xxxxxxxxx@newsletter'
|
|
767
|
+
|
|
768
|
+
// Teks
|
|
769
|
+
await nl.sendNewsletterText(JID, 'Halo dari bot!')
|
|
770
|
+
|
|
771
|
+
// Gambar
|
|
772
|
+
await nl.sendNewsletterImage(JID, { url: 'https://example.com/img.jpg' }, { caption: 'Gambar keren' })
|
|
773
|
+
|
|
774
|
+
// Video
|
|
775
|
+
await nl.sendNewsletterVideo(JID, { url: 'https://example.com/vid.mp4' }, { caption: 'Video nih' })
|
|
776
|
+
|
|
777
|
+
// PTV (video note / lingkaran)
|
|
778
|
+
await nl.sendNewsletterPtv(JID, { url: 'https://example.com/vid.mp4' })
|
|
779
|
+
|
|
780
|
+
// Audio
|
|
781
|
+
await nl.sendNewsletterAudio(JID, { url: 'https://example.com/audio.mp3' })
|
|
782
|
+
|
|
783
|
+
// Dokumen
|
|
784
|
+
await nl.sendNewsletterDocument(JID, { url: 'https://example.com/file.pdf' }, {
|
|
785
|
+
mimetype: 'application/pdf',
|
|
786
|
+
fileName: 'dokumen.pdf'
|
|
787
|
+
})
|
|
788
|
+
|
|
789
|
+
// Sticker
|
|
790
|
+
await nl.sendNewsletterSticker(JID, fs.readFileSync('./sticker.webp'))
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
Atau langsung pakai `conn.sendMessage` seperti biasa — semua tipe media sudah support:
|
|
794
|
+
```js
|
|
795
|
+
await conn.sendMessage(JID, { image: { url: 'https://...' }, caption: 'test' })
|
|
796
|
+
await conn.sendMessage(JID, { video: { url: 'https://...' }, ptv: true })
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
### Button di Channel
|
|
800
|
+
|
|
801
|
+
> [!IMPORTANT]
|
|
802
|
+
> Fitur ini **hanya ada di blckrose-baileys 1.1.5-apoc**. Fork lain tidak support button di newsletter.
|
|
803
|
+
|
|
804
|
+
```js
|
|
805
|
+
const nl = makeNewsletterUtils(conn)
|
|
806
|
+
const JID = '120363xxxxxxxxx@newsletter'
|
|
807
|
+
|
|
808
|
+
// Quick Reply Buttons
|
|
809
|
+
await nl.sendNewsletterButtons(JID, {
|
|
810
|
+
body: 'Pilih salah satu:',
|
|
811
|
+
buttons: [
|
|
812
|
+
{ id: 'btn_yes', text: '✅ Setuju' },
|
|
813
|
+
{ id: 'btn_no', text: '❌ Tidak' },
|
|
814
|
+
{ id: 'btn_skip', text: '⏭ Skip' }
|
|
815
|
+
],
|
|
816
|
+
footer: 'Powered by bot'
|
|
817
|
+
})
|
|
818
|
+
|
|
819
|
+
// Single Select List
|
|
820
|
+
await nl.sendNewsletterList(JID, {
|
|
821
|
+
body: 'Pilih menu yang kamu mau:',
|
|
822
|
+
buttonText: 'Buka Menu',
|
|
823
|
+
sections: [
|
|
824
|
+
{
|
|
825
|
+
title: 'Fitur Utama',
|
|
826
|
+
rows: [
|
|
827
|
+
{ id: 'info', title: 'Info Bot', description: 'Lihat info bot' },
|
|
828
|
+
{ id: 'help', title: 'Bantuan', description: 'Cara pakai bot' },
|
|
829
|
+
{ id: 'stats', title: 'Statistik', description: 'Lihat statistik' }
|
|
830
|
+
]
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
title: 'Lainnya',
|
|
834
|
+
rows: [
|
|
835
|
+
{ id: 'about', title: 'Tentang', description: 'Info developer' }
|
|
836
|
+
]
|
|
837
|
+
}
|
|
838
|
+
],
|
|
839
|
+
title: 'Menu Bot',
|
|
840
|
+
footer: 'Versi 1.0'
|
|
841
|
+
})
|
|
842
|
+
|
|
843
|
+
// CTA URL Button
|
|
844
|
+
await nl.sendNewsletterCtaUrl(JID, {
|
|
845
|
+
body: 'Kunjungi website kami untuk info lebih lanjut!',
|
|
846
|
+
buttonText: '🌐 Buka Website',
|
|
847
|
+
url: 'https://example.com',
|
|
848
|
+
title: 'Info Lengkap',
|
|
849
|
+
footer: 'Klik tombol di bawah'
|
|
850
|
+
})
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
Atau langsung via `conn.sendMessage` dengan `interactiveMessage`:
|
|
854
|
+
```js
|
|
855
|
+
await conn.sendMessage(JID, {
|
|
856
|
+
interactiveMessage: {
|
|
857
|
+
nativeFlowMessage: {
|
|
858
|
+
buttons: [
|
|
859
|
+
{
|
|
860
|
+
name: 'quick_reply',
|
|
861
|
+
buttonParamsJson: JSON.stringify({ display_text: '✅ Ya', id: 'yes' })
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
name: 'cta_url',
|
|
865
|
+
buttonParamsJson: JSON.stringify({ display_text: 'Buka Link', url: 'https://example.com', merchant_url: 'https://example.com' })
|
|
866
|
+
}
|
|
867
|
+
],
|
|
868
|
+
messageParamsJson: '',
|
|
869
|
+
messageVersion: 1
|
|
870
|
+
},
|
|
871
|
+
body: { text: 'Pilih aksi:' },
|
|
872
|
+
footer: { text: 'Footer text' }
|
|
873
|
+
}
|
|
874
|
+
})
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
### Edit & Hapus Pesan Channel
|
|
878
|
+
|
|
879
|
+
```js
|
|
880
|
+
const nl = makeNewsletterUtils(conn)
|
|
881
|
+
const JID = '120363xxxxxxxxx@newsletter'
|
|
882
|
+
|
|
883
|
+
// Edit pesan (gunakan key.id dari pesan yang dikirim)
|
|
884
|
+
const sent = await nl.sendNewsletterText(JID, 'Teks lama')
|
|
885
|
+
await nl.editNewsletterMessage(JID, sent.key.id, 'Teks baru yang sudah diedit')
|
|
886
|
+
|
|
887
|
+
// Hapus pesan
|
|
888
|
+
await nl.deleteNewsletterMessage(JID, sent.key.id)
|
|
889
|
+
|
|
890
|
+
// React ke pesan channel (gunakan server message ID dari event)
|
|
891
|
+
await nl.sendNewsletterReact(JID, serverMessageId, '👍')
|
|
892
|
+
// Unreact (kosongkan emoji)
|
|
893
|
+
await nl.sendNewsletterReact(JID, serverMessageId, '')
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
Atau langsung via `conn.sendMessage`:
|
|
897
|
+
```js
|
|
898
|
+
// Edit
|
|
899
|
+
await conn.sendMessage(JID, { text: 'Teks baru', edit: { remoteJid: JID, fromMe: true, id: messageId } })
|
|
900
|
+
|
|
901
|
+
// Hapus
|
|
902
|
+
await conn.sendMessage(JID, { delete: { remoteJid: JID, fromMe: true, id: messageId } })
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
---
|
|
906
|
+
|
|
907
|
+
## Resolve JID
|
|
908
|
+
|
|
909
|
+
Berguna untuk mengubah `@lid` format (format baru WA) menjadi JID `@s.whatsapp.net` yang bisa dipakai mengirim pesan.
|
|
910
|
+
|
|
911
|
+
```js
|
|
912
|
+
const { resolveJid, resolveJids } = require('@blckrose/baileys')
|
|
913
|
+
|
|
914
|
+
// Resolve dari sender pesan (otomatis ambil dari m.sender / m.quoted / m.mentionedJid)
|
|
915
|
+
const jid = await resolveJid(conn, m)
|
|
916
|
+
if (!jid) return conn.sendMessage(m.chat, { text: 'Tidak bisa resolve JID.' }, { quoted: m })
|
|
917
|
+
|
|
918
|
+
console.log(jid) // → '628xxxxxxxxxx@s.whatsapp.net'
|
|
919
|
+
|
|
920
|
+
// Resolve target eksplisit (misal dari mention)
|
|
921
|
+
const jid = await resolveJid(conn, m, m.mentionedJid?.[0])
|
|
922
|
+
|
|
923
|
+
// Resolve banyak JID sekaligus
|
|
924
|
+
const jids = await resolveJids(conn, m, m.mentionedJid)
|
|
925
|
+
// → ['628xxx@s.whatsapp.net', '628yyy@s.whatsapp.net', null, ...]
|
|
926
|
+
|
|
927
|
+
// Contoh pakai di handler
|
|
928
|
+
let handler = async (m, { conn }) => {
|
|
929
|
+
const target = await resolveJid(conn, m, m.mentionedJid?.[0] || m.quoted?.sender)
|
|
930
|
+
if (!target) return conn.sendMessage(m.chat, { text: 'Tag atau reply seseorang.' }, { quoted: m })
|
|
931
|
+
|
|
932
|
+
await conn.sendMessage(m.chat, {
|
|
933
|
+
text: `JID target: ${target}`
|
|
934
|
+
}, { quoted: m })
|
|
935
|
+
}
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
> [!NOTE]
|
|
939
|
+
> `resolveJid` otomatis melakukan lookup ke `groupMetadata` jika JID berbentuk `@lid` di dalam grup. Butuh akses ke `conn` yang terkoneksi.
|
|
940
|
+
|
|
941
|
+
---
|
|
942
|
+
|
|
461
943
|
|
|
462
|
-
## Sending Messages
|
|
463
944
|
|
|
464
945
|
- Send all types of messages with a single function
|
|
465
946
|
- **[Here](https://baileys.whiskeysockets.io/types/AnyMessageContent.html) you can see all message contents supported, like text message**
|
|
@@ -516,6 +997,19 @@ await sock.sendMessage(
|
|
|
516
997
|
}
|
|
517
998
|
)
|
|
518
999
|
```
|
|
1000
|
+
#### Live Location Message
|
|
1001
|
+
```ts
|
|
1002
|
+
await sock.sendMessage(
|
|
1003
|
+
jid,
|
|
1004
|
+
{
|
|
1005
|
+
location: {
|
|
1006
|
+
degreesLatitude: 24.121231,
|
|
1007
|
+
degreesLongitude: 55.1121221
|
|
1008
|
+
},
|
|
1009
|
+
live: true
|
|
1010
|
+
}
|
|
1011
|
+
)
|
|
1012
|
+
```
|
|
519
1013
|
#### Contact Message
|
|
520
1014
|
```ts
|
|
521
1015
|
const vcard = 'BEGIN:VCARD\n' // metadata of the contact card
|
|
@@ -574,6 +1068,19 @@ await sock.sendMessage(
|
|
|
574
1068
|
)
|
|
575
1069
|
```
|
|
576
1070
|
|
|
1071
|
+
### Keep Message
|
|
1072
|
+
```ts
|
|
1073
|
+
await sock.sendMessage(
|
|
1074
|
+
jid,
|
|
1075
|
+
{
|
|
1076
|
+
keep: {
|
|
1077
|
+
key: Key,
|
|
1078
|
+
type: 1 // or 2
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
)
|
|
1082
|
+
```
|
|
1083
|
+
|
|
577
1084
|
#### Poll Message
|
|
578
1085
|
```ts
|
|
579
1086
|
await sock.sendMessage(
|
|
@@ -589,6 +1096,956 @@ await sock.sendMessage(
|
|
|
589
1096
|
)
|
|
590
1097
|
```
|
|
591
1098
|
|
|
1099
|
+
#### Poll Result Message
|
|
1100
|
+
```ts
|
|
1101
|
+
await sock.sendMessage(
|
|
1102
|
+
jid,
|
|
1103
|
+
{
|
|
1104
|
+
pollResult: {
|
|
1105
|
+
name: 'Hi',
|
|
1106
|
+
values: [
|
|
1107
|
+
[
|
|
1108
|
+
'Option 1',
|
|
1109
|
+
1000
|
|
1110
|
+
],
|
|
1111
|
+
[
|
|
1112
|
+
'Option 2',
|
|
1113
|
+
2000
|
|
1114
|
+
]
|
|
1115
|
+
]
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
)
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
### Call Message
|
|
1122
|
+
```ts
|
|
1123
|
+
await sock.sendMessage(
|
|
1124
|
+
jid,
|
|
1125
|
+
{
|
|
1126
|
+
call: {
|
|
1127
|
+
name: 'Hay',
|
|
1128
|
+
type: 1 // 2 for video
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
)
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
### Event Message
|
|
1135
|
+
```ts
|
|
1136
|
+
await sock.sendMessage(
|
|
1137
|
+
jid,
|
|
1138
|
+
{
|
|
1139
|
+
event: {
|
|
1140
|
+
isCanceled: false, // or true
|
|
1141
|
+
name: 'holiday together!',
|
|
1142
|
+
description: 'who wants to come along?',
|
|
1143
|
+
location: {
|
|
1144
|
+
degreesLatitude: 24.121231,
|
|
1145
|
+
degreesLongitude: 55.1121221,
|
|
1146
|
+
name: 'name'
|
|
1147
|
+
},
|
|
1148
|
+
call: 'audio', // or 'video'
|
|
1149
|
+
startTime: number,
|
|
1150
|
+
endTime: number,
|
|
1151
|
+
extraGuestsAllowed: true // or false
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
)
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
### Order Message
|
|
1158
|
+
```ts
|
|
1159
|
+
await sock.sendMessage(
|
|
1160
|
+
jid,
|
|
1161
|
+
{
|
|
1162
|
+
order: {
|
|
1163
|
+
orderId: '574xxx',
|
|
1164
|
+
thumbnail: 'your_thumbnail',
|
|
1165
|
+
itemCount: 'your_count',
|
|
1166
|
+
status: 'your_status', // INQUIRY || ACCEPTED || DECLINED
|
|
1167
|
+
surface: 'CATALOG',
|
|
1168
|
+
message: 'your_caption',
|
|
1169
|
+
orderTitle: "your_title",
|
|
1170
|
+
sellerJid: 'your_jid',
|
|
1171
|
+
token: 'your_token',
|
|
1172
|
+
totalAmount1000: 'your_amount',
|
|
1173
|
+
totalCurrencyCode: 'IDR'
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
)
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
### Product Message
|
|
1180
|
+
```ts
|
|
1181
|
+
await sock.sendMessage(
|
|
1182
|
+
jid,
|
|
1183
|
+
{
|
|
1184
|
+
product: {
|
|
1185
|
+
productImage: { // for using buffer >> productImage: your_buffer
|
|
1186
|
+
url: your_url
|
|
1187
|
+
},
|
|
1188
|
+
productId: 'your_id',
|
|
1189
|
+
title: 'your_title',
|
|
1190
|
+
description: 'your_description',
|
|
1191
|
+
currencyCode: 'IDR',
|
|
1192
|
+
priceAmount1000: 'your_amount',
|
|
1193
|
+
retailerId: 'your_reid', // optional use if needed
|
|
1194
|
+
url: 'your_url', // optional use if needed
|
|
1195
|
+
productImageCount: 'your_imageCount',
|
|
1196
|
+
firstImageId: 'your_image', // optional use if needed
|
|
1197
|
+
salePriceAmount1000: 'your_priceSale',
|
|
1198
|
+
signedUrl: 'your_url' // optional use if needed
|
|
1199
|
+
},
|
|
1200
|
+
businessOwnerJid: 'your_jid'
|
|
1201
|
+
}
|
|
1202
|
+
)
|
|
1203
|
+
```
|
|
1204
|
+
|
|
1205
|
+
### Payment Message
|
|
1206
|
+
```ts
|
|
1207
|
+
await sock.sendMessage(
|
|
1208
|
+
jid,
|
|
1209
|
+
{
|
|
1210
|
+
payment: {
|
|
1211
|
+
note: 'Hi!',
|
|
1212
|
+
currency: 'IDR', // optional
|
|
1213
|
+
offset: 0, // optional
|
|
1214
|
+
amount: '10000', // optional
|
|
1215
|
+
expiry: 0, // optional
|
|
1216
|
+
from: '628xxxx@s.whatsapp.net', // optional
|
|
1217
|
+
image: { // optional
|
|
1218
|
+
placeholderArgb: "your_background", // optional
|
|
1219
|
+
textArgb: "your_text", // optional
|
|
1220
|
+
subtextArgb: "your_subtext" // optional
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
)
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
#### Payment Invite Message
|
|
1228
|
+
```ts
|
|
1229
|
+
await sock.sendMessage(
|
|
1230
|
+
id,
|
|
1231
|
+
{
|
|
1232
|
+
paymentInvite: {
|
|
1233
|
+
type: number, // 1 || 2 || 3
|
|
1234
|
+
expiry: 0
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
```
|
|
1239
|
+
|
|
1240
|
+
### Admin Invite Message
|
|
1241
|
+
```ts
|
|
1242
|
+
await sock.sendMessage(
|
|
1243
|
+
jid,
|
|
1244
|
+
{
|
|
1245
|
+
adminInvite: {
|
|
1246
|
+
jid: '123xxx@newsletter',
|
|
1247
|
+
name: 'newsletter_name',
|
|
1248
|
+
caption: 'Please be my channel admin',
|
|
1249
|
+
expiration: 86400,
|
|
1250
|
+
jpegThumbnail: Buffer // optional
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
)
|
|
1254
|
+
```
|
|
1255
|
+
|
|
1256
|
+
### Group Invite Message
|
|
1257
|
+
```ts
|
|
1258
|
+
await sock.sendMessage(
|
|
1259
|
+
jid,
|
|
1260
|
+
{
|
|
1261
|
+
groupInvite: {
|
|
1262
|
+
jid: '123xxx@g.us',
|
|
1263
|
+
name: 'group_name',
|
|
1264
|
+
caption: 'Please Join My Whatsapp Group',
|
|
1265
|
+
code: 'code_invite',
|
|
1266
|
+
expiration: 86400,
|
|
1267
|
+
jpegThumbnail: Buffer, // optional
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
)
|
|
1271
|
+
```
|
|
1272
|
+
|
|
1273
|
+
### Sticker Pack Message
|
|
1274
|
+
```ts
|
|
1275
|
+
// I don't know why the sticker doesn't appear
|
|
1276
|
+
await sock.sendMessage(
|
|
1277
|
+
jid,
|
|
1278
|
+
{
|
|
1279
|
+
stickerPack: {
|
|
1280
|
+
name: 'Hiii',
|
|
1281
|
+
publisher: 'By blckrose',
|
|
1282
|
+
description: 'Hello',
|
|
1283
|
+
cover: Buffer, // Image buffer
|
|
1284
|
+
stickers: [{
|
|
1285
|
+
sticker: { url: 'https://example.com/1234kjd.webp' },
|
|
1286
|
+
emojis: ['❤'], // optional
|
|
1287
|
+
accessibilityLabel: '', // optional
|
|
1288
|
+
isLottie: Boolean, // optional
|
|
1289
|
+
isAnimated: Boolean // optional
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
sticker: Buffer,
|
|
1293
|
+
emojis: ['❤'], // optional
|
|
1294
|
+
accessibilityLabel: '', // optional
|
|
1295
|
+
isLottie: Boolean, // optional
|
|
1296
|
+
isAnimated: Boolean // optional
|
|
1297
|
+
}]
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
)
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
### Share Phone Number Message
|
|
1304
|
+
```ts
|
|
1305
|
+
await sock.sendMessage(
|
|
1306
|
+
jid,
|
|
1307
|
+
{
|
|
1308
|
+
sharePhoneNumber: {
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
)
|
|
1312
|
+
```
|
|
1313
|
+
|
|
1314
|
+
### Request Phone Number Message
|
|
1315
|
+
```ts
|
|
1316
|
+
await sock.sendMessage(
|
|
1317
|
+
jid,
|
|
1318
|
+
{
|
|
1319
|
+
requestPhoneNumber: {
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
)
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
### Buttons Reply Message
|
|
1326
|
+
```ts
|
|
1327
|
+
// List
|
|
1328
|
+
await sock.sendMessage(
|
|
1329
|
+
jid,
|
|
1330
|
+
{
|
|
1331
|
+
buttonReply: {
|
|
1332
|
+
name: 'Hii',
|
|
1333
|
+
description: 'description',
|
|
1334
|
+
rowId: 'ID'
|
|
1335
|
+
},
|
|
1336
|
+
type: 'list'
|
|
1337
|
+
}
|
|
1338
|
+
)
|
|
1339
|
+
// Plain
|
|
1340
|
+
await sock.sendMessage(
|
|
1341
|
+
jid,
|
|
1342
|
+
{
|
|
1343
|
+
buttonReply: {
|
|
1344
|
+
displayText: 'Hii',
|
|
1345
|
+
id: 'ID'
|
|
1346
|
+
},
|
|
1347
|
+
type: 'plain'
|
|
1348
|
+
}
|
|
1349
|
+
)
|
|
1350
|
+
|
|
1351
|
+
// Template
|
|
1352
|
+
await sock.sendMessage(
|
|
1353
|
+
jid,
|
|
1354
|
+
{
|
|
1355
|
+
buttonReply: {
|
|
1356
|
+
displayText: 'Hii',
|
|
1357
|
+
id: 'ID',
|
|
1358
|
+
index: 'number'
|
|
1359
|
+
},
|
|
1360
|
+
type: 'template'
|
|
1361
|
+
}
|
|
1362
|
+
)
|
|
1363
|
+
|
|
1364
|
+
// Interactive
|
|
1365
|
+
await sock.sendMessage(
|
|
1366
|
+
jid,
|
|
1367
|
+
{
|
|
1368
|
+
buttonReply: {
|
|
1369
|
+
body: 'Hii',
|
|
1370
|
+
nativeFlows: {
|
|
1371
|
+
name: 'menu_options',
|
|
1372
|
+
paramsJson: JSON.stringify({ id: 'ID', description: 'description' })
|
|
1373
|
+
version: 1 // 2 | 3
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
type: 'interactive'
|
|
1377
|
+
}
|
|
1378
|
+
)
|
|
1379
|
+
```
|
|
1380
|
+
|
|
1381
|
+
### Buttons Message
|
|
1382
|
+
```ts
|
|
1383
|
+
await sock.sendMessage(
|
|
1384
|
+
jid,
|
|
1385
|
+
{
|
|
1386
|
+
text: 'This is a button message!', // image: buffer or // image: { url: url } If you want to use images
|
|
1387
|
+
caption: 'caption', // Use this if you are using an image or video
|
|
1388
|
+
footer: 'Hello World!',
|
|
1389
|
+
buttons: [{
|
|
1390
|
+
buttonId: 'Id1',
|
|
1391
|
+
buttonText: {
|
|
1392
|
+
displayText: 'Button 1'
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
buttonId: 'Id2',
|
|
1397
|
+
buttonText: {
|
|
1398
|
+
displayText: 'Button 2'
|
|
1399
|
+
}
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
buttonId: 'Id3',
|
|
1403
|
+
buttonText: {
|
|
1404
|
+
displayText: 'Button 3'
|
|
1405
|
+
}
|
|
1406
|
+
}]
|
|
1407
|
+
}
|
|
1408
|
+
)
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
### Buttons List Message
|
|
1412
|
+
```ts
|
|
1413
|
+
// Just working in a private chat
|
|
1414
|
+
await sock.sendMessage(
|
|
1415
|
+
jid,
|
|
1416
|
+
{
|
|
1417
|
+
text: 'This is a list!',
|
|
1418
|
+
footer: 'Hello World!',
|
|
1419
|
+
title: 'Amazing boldfaced list title',
|
|
1420
|
+
buttonText: 'Required, text on the button to view the list',
|
|
1421
|
+
sections: [
|
|
1422
|
+
{
|
|
1423
|
+
title: 'Section 1',
|
|
1424
|
+
rows: [{
|
|
1425
|
+
title: 'Option 1',
|
|
1426
|
+
rowId: 'option1'
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
title: 'Option 2',
|
|
1430
|
+
rowId: 'option2',
|
|
1431
|
+
description: 'This is a description'
|
|
1432
|
+
}]
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
title: 'Section 2',
|
|
1436
|
+
rows: [{
|
|
1437
|
+
title: 'Option 3',
|
|
1438
|
+
rowId: 'option3'
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
title: 'Option 4',
|
|
1442
|
+
rowId: 'option4',
|
|
1443
|
+
description: 'This is a description V2'
|
|
1444
|
+
}]
|
|
1445
|
+
}]
|
|
1446
|
+
}
|
|
1447
|
+
)
|
|
1448
|
+
```
|
|
1449
|
+
|
|
1450
|
+
### Buttons Product List Message
|
|
1451
|
+
```ts
|
|
1452
|
+
// Just working in a private chat
|
|
1453
|
+
await sock.sendMessage(
|
|
1454
|
+
jid,
|
|
1455
|
+
{
|
|
1456
|
+
text: 'This is a list!',
|
|
1457
|
+
footer: 'Hello World!',
|
|
1458
|
+
title: 'Amazing boldfaced list title',
|
|
1459
|
+
buttonText: 'Required, text on the button to view the list',
|
|
1460
|
+
productList: [{
|
|
1461
|
+
title: 'This is a title',
|
|
1462
|
+
products: [
|
|
1463
|
+
{
|
|
1464
|
+
productId: '1234'
|
|
1465
|
+
},
|
|
1466
|
+
{
|
|
1467
|
+
productId: '5678'
|
|
1468
|
+
}
|
|
1469
|
+
]
|
|
1470
|
+
}],
|
|
1471
|
+
businessOwnerJid: '628xxx@s.whatsapp.net',
|
|
1472
|
+
thumbnail: 'https://example.com/jdbenkksjs.jpg' // or buffer
|
|
1473
|
+
}
|
|
1474
|
+
)
|
|
1475
|
+
```
|
|
1476
|
+
|
|
1477
|
+
### Buttons Cards Message
|
|
1478
|
+
```ts
|
|
1479
|
+
await sock.sendMessage(
|
|
1480
|
+
jid,
|
|
1481
|
+
{
|
|
1482
|
+
text: 'Body Message',
|
|
1483
|
+
title: 'Title Message',
|
|
1484
|
+
subtile: 'Subtitle Message',
|
|
1485
|
+
footer: 'Footer Message',
|
|
1486
|
+
cards: [
|
|
1487
|
+
{
|
|
1488
|
+
image: { url: 'https://example.com/jdbenkksjs.jpg' }, // or buffer
|
|
1489
|
+
title: 'Title Cards',
|
|
1490
|
+
body: 'Body Cards',
|
|
1491
|
+
footer: 'Footer Cards',
|
|
1492
|
+
buttons: [
|
|
1493
|
+
{
|
|
1494
|
+
name: 'quick_reply',
|
|
1495
|
+
buttonParamsJson: JSON.stringify({
|
|
1496
|
+
display_text: 'Display Button',
|
|
1497
|
+
id: 'ID'
|
|
1498
|
+
})
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
name: 'cta_url',
|
|
1502
|
+
buttonParamsJson: JSON.stringify({
|
|
1503
|
+
display_text: 'Display Button',
|
|
1504
|
+
url: 'https://www.example.com'
|
|
1505
|
+
})
|
|
1506
|
+
}
|
|
1507
|
+
]
|
|
1508
|
+
},
|
|
1509
|
+
{
|
|
1510
|
+
video: { url: 'https://example.com/jdbenkksjs.mp4' }, // or buffer
|
|
1511
|
+
title: 'Title Cards',
|
|
1512
|
+
body: 'Body Cards',
|
|
1513
|
+
footer: 'Footer Cards',
|
|
1514
|
+
buttons: [
|
|
1515
|
+
{
|
|
1516
|
+
name: 'quick_reply',
|
|
1517
|
+
buttonParamsJson: JSON.stringify({
|
|
1518
|
+
display_text: 'Display Button',
|
|
1519
|
+
id: 'ID'
|
|
1520
|
+
})
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
name: 'cta_url',
|
|
1524
|
+
buttonParamsJson: JSON.stringify({
|
|
1525
|
+
display_text: 'Display Button',
|
|
1526
|
+
url: 'https://www.example.com'
|
|
1527
|
+
})
|
|
1528
|
+
}
|
|
1529
|
+
]
|
|
1530
|
+
}
|
|
1531
|
+
]
|
|
1532
|
+
}
|
|
1533
|
+
)
|
|
1534
|
+
```
|
|
1535
|
+
|
|
1536
|
+
### Buttons Template Message
|
|
1537
|
+
```ts
|
|
1538
|
+
// This no longer works
|
|
1539
|
+
await sock.sendMessage(
|
|
1540
|
+
jid,
|
|
1541
|
+
{
|
|
1542
|
+
text: 'This is a template message!',
|
|
1543
|
+
footer: 'Hello World!',
|
|
1544
|
+
templateButtons: [{
|
|
1545
|
+
index: 1,
|
|
1546
|
+
urlButton: {
|
|
1547
|
+
displayText: 'Follow Me',
|
|
1548
|
+
url: 'https://whatsapp.com/channel/0029Vag9VSI2ZjCocqa2lB1y'
|
|
1549
|
+
},
|
|
1550
|
+
},
|
|
1551
|
+
{
|
|
1552
|
+
index: 2,
|
|
1553
|
+
callButton: {
|
|
1554
|
+
displayText: 'Call Me!',
|
|
1555
|
+
phoneNumber: '628xxx'
|
|
1556
|
+
},
|
|
1557
|
+
},
|
|
1558
|
+
{
|
|
1559
|
+
index: 3,
|
|
1560
|
+
quickReplyButton: {
|
|
1561
|
+
displayText: 'This is a reply, just like normal buttons!',
|
|
1562
|
+
id: 'id-like-buttons-message'
|
|
1563
|
+
},
|
|
1564
|
+
}]
|
|
1565
|
+
}
|
|
1566
|
+
)
|
|
1567
|
+
```
|
|
1568
|
+
|
|
1569
|
+
### Buttons Interactive Message
|
|
1570
|
+
```ts
|
|
1571
|
+
await sock.sendMessage(
|
|
1572
|
+
jid,
|
|
1573
|
+
{
|
|
1574
|
+
text: 'This is an Interactive message!',
|
|
1575
|
+
title: 'Hiii',
|
|
1576
|
+
subtitle: 'There is a subtitle',
|
|
1577
|
+
footer: 'Hello World!',
|
|
1578
|
+
interactiveButtons: [
|
|
1579
|
+
{
|
|
1580
|
+
name: 'quick_reply',
|
|
1581
|
+
buttonParamsJson: JSON.stringify({
|
|
1582
|
+
display_text: 'Click Me!',
|
|
1583
|
+
id: 'your_id'
|
|
1584
|
+
})
|
|
1585
|
+
},
|
|
1586
|
+
{
|
|
1587
|
+
name: 'cta_url',
|
|
1588
|
+
buttonParamsJson: JSON.stringify({
|
|
1589
|
+
display_text: 'Follow Me',
|
|
1590
|
+
url: 'https://whatsapp.com/channel/0029Vag9VSI2ZjCocqa2lB1y',
|
|
1591
|
+
merchant_url: 'https://whatsapp.com/channel/0029Vag9VSI2ZjCocqa2lB1y'
|
|
1592
|
+
})
|
|
1593
|
+
},
|
|
1594
|
+
{
|
|
1595
|
+
name: 'cta_copy',
|
|
1596
|
+
buttonParamsJson: JSON.stringify({
|
|
1597
|
+
display_text: 'Click Me!',
|
|
1598
|
+
copy_code: 'https://whatsapp.com/channel/0029Vag9VSI2ZjCocqa2lB1y'
|
|
1599
|
+
})
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
name: 'cta_call',
|
|
1603
|
+
buttonParamsJson: JSON.stringify({
|
|
1604
|
+
display_text: 'Call Me!',
|
|
1605
|
+
phone_number: '628xxx'
|
|
1606
|
+
})
|
|
1607
|
+
},
|
|
1608
|
+
{
|
|
1609
|
+
name: 'cta_catalog',
|
|
1610
|
+
buttonParamsJson: JSON.stringify({
|
|
1611
|
+
business_phone_number: '628xxx'
|
|
1612
|
+
})
|
|
1613
|
+
},
|
|
1614
|
+
{
|
|
1615
|
+
name: 'cta_reminder',
|
|
1616
|
+
buttonParamsJson: JSON.stringify({
|
|
1617
|
+
display_text: '...'
|
|
1618
|
+
})
|
|
1619
|
+
},
|
|
1620
|
+
{
|
|
1621
|
+
name: 'cta_cancel_reminder',
|
|
1622
|
+
buttonParamsJson: JSON.stringify({
|
|
1623
|
+
display_text: '...'
|
|
1624
|
+
})
|
|
1625
|
+
},
|
|
1626
|
+
{
|
|
1627
|
+
name: 'address_message',
|
|
1628
|
+
buttonParamsJson: JSON.stringify({
|
|
1629
|
+
display_text: '...'
|
|
1630
|
+
})
|
|
1631
|
+
},
|
|
1632
|
+
{
|
|
1633
|
+
name: 'send_location',
|
|
1634
|
+
buttonParamsJson: JSON.stringify({
|
|
1635
|
+
display_text: '...'
|
|
1636
|
+
})
|
|
1637
|
+
},
|
|
1638
|
+
{
|
|
1639
|
+
name: 'open_webview',
|
|
1640
|
+
buttonParamsJson: JSON.stringify({
|
|
1641
|
+
title: 'Follow Me!',
|
|
1642
|
+
link: {
|
|
1643
|
+
in_app_webview: true, // or false
|
|
1644
|
+
url: 'https://whatsapp.com/channel/0029Vag9VSI2ZjCocqa2lB1y'
|
|
1645
|
+
}
|
|
1646
|
+
})
|
|
1647
|
+
},
|
|
1648
|
+
{
|
|
1649
|
+
name: 'mpm',
|
|
1650
|
+
buttonParamsJson: JSON.stringify({
|
|
1651
|
+
product_id: '8816262248471474'
|
|
1652
|
+
})
|
|
1653
|
+
},
|
|
1654
|
+
{
|
|
1655
|
+
name: 'wa_payment_transaction_details',
|
|
1656
|
+
buttonParamsJson: JSON.stringify({
|
|
1657
|
+
transaction_id: '12345848'
|
|
1658
|
+
})
|
|
1659
|
+
},
|
|
1660
|
+
{
|
|
1661
|
+
name: 'automated_greeting_message_view_catalog',
|
|
1662
|
+
buttonParamsJson: JSON.stringify({
|
|
1663
|
+
business_phone_number: '628xxx',
|
|
1664
|
+
catalog_product_id: '12345'
|
|
1665
|
+
})
|
|
1666
|
+
},
|
|
1667
|
+
{
|
|
1668
|
+
name: 'galaxy_message',
|
|
1669
|
+
buttonParamsJson: JSON.stringify({
|
|
1670
|
+
mode: 'published',
|
|
1671
|
+
flow_message_version: '3',
|
|
1672
|
+
flow_token: '1:1307913409923914:293680f87029f5a13d1ec5e35e718af3',
|
|
1673
|
+
flow_id: '1307913409923914',
|
|
1674
|
+
flow_cta: 'blckrose >',
|
|
1675
|
+
flow_action: 'navigate',
|
|
1676
|
+
flow_action_payload: {
|
|
1677
|
+
screen: 'QUESTION_ONE',
|
|
1678
|
+
params: {
|
|
1679
|
+
user_id: '123456789',
|
|
1680
|
+
referral: 'campaign_xyz'
|
|
1681
|
+
}
|
|
1682
|
+
},
|
|
1683
|
+
flow_metadata: {
|
|
1684
|
+
flow_json_version: '201',
|
|
1685
|
+
data_api_protocol: 'v2',
|
|
1686
|
+
flow_name: 'Lead Qualification [en]',
|
|
1687
|
+
data_api_version: 'v2',
|
|
1688
|
+
categories: ['Lead Generation', 'Sales']
|
|
1689
|
+
}
|
|
1690
|
+
})
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
name: 'single_select',
|
|
1694
|
+
buttonParamsJson: JSON.stringify({
|
|
1695
|
+
title: 'Click Me!',
|
|
1696
|
+
sections: [
|
|
1697
|
+
{
|
|
1698
|
+
title: 'Title 1',
|
|
1699
|
+
highlight_label: 'Highlight label 1',
|
|
1700
|
+
rows: [
|
|
1701
|
+
{
|
|
1702
|
+
header: 'Header 1',
|
|
1703
|
+
title: 'Title 1',
|
|
1704
|
+
description: 'Description 1',
|
|
1705
|
+
id: 'Id 1'
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
header: 'Header 2',
|
|
1709
|
+
title: 'Title 2',
|
|
1710
|
+
description: 'Description 2',
|
|
1711
|
+
id: 'Id 2'
|
|
1712
|
+
}
|
|
1713
|
+
]
|
|
1714
|
+
}
|
|
1715
|
+
]
|
|
1716
|
+
})
|
|
1717
|
+
}
|
|
1718
|
+
]
|
|
1719
|
+
}
|
|
1720
|
+
)
|
|
1721
|
+
|
|
1722
|
+
// If you want to use an image
|
|
1723
|
+
await sock.sendMessage(
|
|
1724
|
+
jid,
|
|
1725
|
+
{
|
|
1726
|
+
image: {
|
|
1727
|
+
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1728
|
+
},
|
|
1729
|
+
caption: 'Body',
|
|
1730
|
+
title: 'Title',
|
|
1731
|
+
subtitle: 'Subtitle',
|
|
1732
|
+
footer: 'Footer',
|
|
1733
|
+
interactiveButtons: [
|
|
1734
|
+
{
|
|
1735
|
+
name: 'quick_reply',
|
|
1736
|
+
buttonParamsJson: JSON.stringify({
|
|
1737
|
+
display_text: 'DisplayText',
|
|
1738
|
+
id: 'ID1'
|
|
1739
|
+
})
|
|
1740
|
+
}
|
|
1741
|
+
],
|
|
1742
|
+
hasMediaAttachment: false // or true
|
|
1743
|
+
}
|
|
1744
|
+
)
|
|
1745
|
+
|
|
1746
|
+
// If you want to use a video
|
|
1747
|
+
await sock.sendMessage(
|
|
1748
|
+
jid,
|
|
1749
|
+
{
|
|
1750
|
+
video: {
|
|
1751
|
+
url: 'https://example.com/jdbenkksjs.mp4'
|
|
1752
|
+
},
|
|
1753
|
+
caption: 'Body',
|
|
1754
|
+
title: 'Title',
|
|
1755
|
+
subtitle: 'Subtitle',
|
|
1756
|
+
footer: 'Footer',
|
|
1757
|
+
interactiveButtons: [
|
|
1758
|
+
{
|
|
1759
|
+
name: 'quick_reply',
|
|
1760
|
+
buttonParamsJson: JSON.stringify({
|
|
1761
|
+
display_text: 'DisplayText',
|
|
1762
|
+
id: 'ID1'
|
|
1763
|
+
})
|
|
1764
|
+
}
|
|
1765
|
+
],
|
|
1766
|
+
hasMediaAttachment: false // or true
|
|
1767
|
+
}
|
|
1768
|
+
)
|
|
1769
|
+
|
|
1770
|
+
// If you want to use a document
|
|
1771
|
+
await sock.sendMessage(
|
|
1772
|
+
jid,
|
|
1773
|
+
{
|
|
1774
|
+
document: {
|
|
1775
|
+
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1776
|
+
},
|
|
1777
|
+
mimetype: 'image/jpeg',
|
|
1778
|
+
caption: 'Body',
|
|
1779
|
+
title: 'Title',
|
|
1780
|
+
subtitle: 'Subtitle',
|
|
1781
|
+
footer: 'Footer',
|
|
1782
|
+
interactiveButtons: [
|
|
1783
|
+
{
|
|
1784
|
+
name: 'quick_reply',
|
|
1785
|
+
buttonParamsJson: JSON.stringify({
|
|
1786
|
+
display_text: 'DisplayText',
|
|
1787
|
+
id: 'ID1'
|
|
1788
|
+
})
|
|
1789
|
+
}
|
|
1790
|
+
],
|
|
1791
|
+
hasMediaAttachment: false // or true
|
|
1792
|
+
}
|
|
1793
|
+
)
|
|
1794
|
+
|
|
1795
|
+
// If you want to use a location
|
|
1796
|
+
await sock.sendMessage(
|
|
1797
|
+
jid,
|
|
1798
|
+
{
|
|
1799
|
+
location: {
|
|
1800
|
+
degreesLatitude: -0,
|
|
1801
|
+
degreesLongitude: 0,
|
|
1802
|
+
name: 'Hi'
|
|
1803
|
+
},
|
|
1804
|
+
caption: 'Body',
|
|
1805
|
+
title: 'Title',
|
|
1806
|
+
subtitle: 'Subtitle',
|
|
1807
|
+
footer: 'Footer',
|
|
1808
|
+
interactiveButtons: [
|
|
1809
|
+
{
|
|
1810
|
+
name: 'quick_reply',
|
|
1811
|
+
buttonParamsJson: JSON.stringify({
|
|
1812
|
+
display_text: 'DisplayText',
|
|
1813
|
+
id: 'ID1'
|
|
1814
|
+
})
|
|
1815
|
+
}
|
|
1816
|
+
],
|
|
1817
|
+
hasMediaAttachment: false // or true
|
|
1818
|
+
}
|
|
1819
|
+
)
|
|
1820
|
+
```
|
|
1821
|
+
|
|
1822
|
+
### Buttons Interactive Message PIX
|
|
1823
|
+
```ts
|
|
1824
|
+
await sock.sendMessage(
|
|
1825
|
+
jid,
|
|
1826
|
+
{
|
|
1827
|
+
text: '', // This string is required. Even it's empty.
|
|
1828
|
+
interactiveButtons: [
|
|
1829
|
+
{
|
|
1830
|
+
name: 'payment_info',
|
|
1831
|
+
buttonParamsJson: JSON.stringify({
|
|
1832
|
+
payment_settings: [{
|
|
1833
|
+
type: "pix_static_code",
|
|
1834
|
+
pix_static_code: {
|
|
1835
|
+
merchant_name: 'blckrose',
|
|
1836
|
+
key: 'example@blckrose.com',
|
|
1837
|
+
key_type: 'EMAIL' // PHONE || EMAIL || CPF || EVP
|
|
1838
|
+
}
|
|
1839
|
+
}]
|
|
1840
|
+
})
|
|
1841
|
+
}
|
|
1842
|
+
],
|
|
1843
|
+
}
|
|
1844
|
+
)
|
|
1845
|
+
```
|
|
1846
|
+
|
|
1847
|
+
### Buttons Interactive Message PAY
|
|
1848
|
+
```ts
|
|
1849
|
+
await sock.sendMessage(
|
|
1850
|
+
jid,
|
|
1851
|
+
{
|
|
1852
|
+
text: '', // This string is required. Even it's empty.
|
|
1853
|
+
interactiveButtons: [
|
|
1854
|
+
{
|
|
1855
|
+
name: 'review_and_pay',
|
|
1856
|
+
buttonParamsJson: JSON.stringify({
|
|
1857
|
+
currency: 'IDR',
|
|
1858
|
+
payment_configuration: '',
|
|
1859
|
+
payment_type: '',
|
|
1860
|
+
total_amount: {
|
|
1861
|
+
value: '999999999',
|
|
1862
|
+
offset: '100'
|
|
1863
|
+
},
|
|
1864
|
+
reference_id: '45XXXXX',
|
|
1865
|
+
type: 'physical-goods',
|
|
1866
|
+
payment_method: 'confirm',
|
|
1867
|
+
payment_status: 'captured',
|
|
1868
|
+
payment_timestamp: Math.floor(Date.now() / 1000),
|
|
1869
|
+
order: {
|
|
1870
|
+
status: 'completed',
|
|
1871
|
+
description: '',
|
|
1872
|
+
subtotal: {
|
|
1873
|
+
value: '0',
|
|
1874
|
+
offset: '100'
|
|
1875
|
+
},
|
|
1876
|
+
order_type: 'PAYMENT_REQUEST',
|
|
1877
|
+
items: [{
|
|
1878
|
+
retailer_id: 'your_retailer_id',
|
|
1879
|
+
name: 'blckrose',
|
|
1880
|
+
amount: {
|
|
1881
|
+
value: '999999999',
|
|
1882
|
+
offset: '100'
|
|
1883
|
+
},
|
|
1884
|
+
quantity: '1',
|
|
1885
|
+
}]
|
|
1886
|
+
},
|
|
1887
|
+
additional_note: 'blckrose',
|
|
1888
|
+
native_payment_methods: [],
|
|
1889
|
+
share_payment_status: false
|
|
1890
|
+
})
|
|
1891
|
+
}
|
|
1892
|
+
],
|
|
1893
|
+
}
|
|
1894
|
+
)
|
|
1895
|
+
```
|
|
1896
|
+
|
|
1897
|
+
### Status Mentions Message
|
|
1898
|
+
```ts
|
|
1899
|
+
const jidat = [
|
|
1900
|
+
'123451679@g.us',
|
|
1901
|
+
'124848899@g.us',
|
|
1902
|
+
'111384848@g.us',
|
|
1903
|
+
'62689xxxx@s.whatsapp.net',
|
|
1904
|
+
'62xxxxxxx@s.whatsapp.net'
|
|
1905
|
+
]
|
|
1906
|
+
// Text
|
|
1907
|
+
await sock.sendStatusMentions(
|
|
1908
|
+
{
|
|
1909
|
+
text: 'Hello Everyone :3',
|
|
1910
|
+
font: 2, // optional
|
|
1911
|
+
textColor: 'FF0000', // optional
|
|
1912
|
+
backgroundColor: '#000000' // optional
|
|
1913
|
+
},
|
|
1914
|
+
jids // Limit to 5 mentions per status
|
|
1915
|
+
)
|
|
1916
|
+
|
|
1917
|
+
// Image
|
|
1918
|
+
await sock.sendStatusMentions(
|
|
1919
|
+
{
|
|
1920
|
+
Image: { url: 'https://example.com/ruriooe.jpg' }, // or image buffer
|
|
1921
|
+
caption: 'Hello Everyone :3' // optional
|
|
1922
|
+
},
|
|
1923
|
+
jids // Limit to 5 mentions per status
|
|
1924
|
+
)
|
|
1925
|
+
|
|
1926
|
+
// Video
|
|
1927
|
+
await sock.sendStatusMentions(
|
|
1928
|
+
{
|
|
1929
|
+
video: { url: 'https://example.com/ruriooe.mp4' }, // or video buffer
|
|
1930
|
+
caption: 'Hello Everyone :3' // optional
|
|
1931
|
+
},
|
|
1932
|
+
jids // Limit to 5 mentions per status
|
|
1933
|
+
)
|
|
1934
|
+
|
|
1935
|
+
// Audio
|
|
1936
|
+
await sock.sendStatusMentions(
|
|
1937
|
+
{
|
|
1938
|
+
audio: { url: 'https://example.com/ruriooe.mp3' }, // or audio buffer
|
|
1939
|
+
backgroundColor: '#000000', // optional
|
|
1940
|
+
mimetype: 'audio/mp4',
|
|
1941
|
+
ppt: true
|
|
1942
|
+
},
|
|
1943
|
+
jids // Limit to 5 mentions per status
|
|
1944
|
+
)
|
|
1945
|
+
```
|
|
1946
|
+
|
|
1947
|
+
### Shop Message
|
|
1948
|
+
```ts
|
|
1949
|
+
await sock.sendMessage(
|
|
1950
|
+
jid,
|
|
1951
|
+
{
|
|
1952
|
+
text: 'Body',
|
|
1953
|
+
title: 'Title',
|
|
1954
|
+
subtitle: 'Subtitle',
|
|
1955
|
+
footer: 'Footer',
|
|
1956
|
+
shop: {
|
|
1957
|
+
surface: 1, // 2 | 3 | 4
|
|
1958
|
+
id: 'https://example.com'
|
|
1959
|
+
},
|
|
1960
|
+
viewOnce: true
|
|
1961
|
+
}
|
|
1962
|
+
)
|
|
1963
|
+
|
|
1964
|
+
// Image
|
|
1965
|
+
await sock.sendMessage(
|
|
1966
|
+
jid,
|
|
1967
|
+
{
|
|
1968
|
+
image: {
|
|
1969
|
+
url: 'https://example.com/jdbenkksjs.jpg'
|
|
1970
|
+
},
|
|
1971
|
+
caption: 'Body',
|
|
1972
|
+
title: 'Title',
|
|
1973
|
+
subtitle: 'Subtitle',
|
|
1974
|
+
footer: 'Footer',
|
|
1975
|
+
shop: {
|
|
1976
|
+
surface: 1, // 2 | 3 | 4
|
|
1977
|
+
id: 'https://example.com'
|
|
1978
|
+
},
|
|
1979
|
+
hasMediaAttachment: false, // or true
|
|
1980
|
+
viewOnce: true
|
|
1981
|
+
}
|
|
1982
|
+
)
|
|
1983
|
+
```
|
|
1984
|
+
|
|
1985
|
+
### Collection Message
|
|
1986
|
+
```ts
|
|
1987
|
+
await sock.sendMessage(
|
|
1988
|
+
jid,
|
|
1989
|
+
{
|
|
1990
|
+
text: 'Body',
|
|
1991
|
+
title: 'Title',
|
|
1992
|
+
subtitle: 'Subtitle',
|
|
1993
|
+
footer: 'Footer',
|
|
1994
|
+
collection: {
|
|
1995
|
+
bizJid: 'jid',
|
|
1996
|
+
id: 'https://example.com',
|
|
1997
|
+
version: 1
|
|
1998
|
+
},
|
|
1999
|
+
viewOnce: true
|
|
2000
|
+
}
|
|
2001
|
+
)
|
|
2002
|
+
|
|
2003
|
+
// Image
|
|
2004
|
+
await sock.sendMessage(
|
|
2005
|
+
jid,
|
|
2006
|
+
{
|
|
2007
|
+
image: {
|
|
2008
|
+
url: 'https://example.com/jdbenkksjs.jpg'
|
|
2009
|
+
},
|
|
2010
|
+
caption: 'Body',
|
|
2011
|
+
title: 'Title',
|
|
2012
|
+
subtitle: 'Subtitle',
|
|
2013
|
+
footer: 'Footer',
|
|
2014
|
+
collection: {
|
|
2015
|
+
bizJid: 'jid',
|
|
2016
|
+
id: 'https://example.com',
|
|
2017
|
+
version: 1
|
|
2018
|
+
},
|
|
2019
|
+
hasMediaAttachment: false, // or true
|
|
2020
|
+
viewOnce: true
|
|
2021
|
+
}
|
|
2022
|
+
)
|
|
2023
|
+
```
|
|
2024
|
+
|
|
2025
|
+
### AI Icon Feature
|
|
2026
|
+
```ts
|
|
2027
|
+
await sock.sendMessage(
|
|
2028
|
+
jid,
|
|
2029
|
+
{
|
|
2030
|
+
text: 'Hi'
|
|
2031
|
+
}, {
|
|
2032
|
+
ai: true // Add ai usage and change it to true
|
|
2033
|
+
}
|
|
2034
|
+
)
|
|
2035
|
+
|
|
2036
|
+
// If using relay
|
|
2037
|
+
await sock.relayMessage(
|
|
2038
|
+
jid,
|
|
2039
|
+
{
|
|
2040
|
+
extendedTextMessage: {
|
|
2041
|
+
text: 'Hi'
|
|
2042
|
+
}
|
|
2043
|
+
}, {
|
|
2044
|
+
AI: true // Use capital letters
|
|
2045
|
+
}
|
|
2046
|
+
)
|
|
2047
|
+
```
|
|
2048
|
+
|
|
592
2049
|
### Sending Messages with Link Previews
|
|
593
2050
|
|
|
594
2051
|
1. By default, wa does not have link generation when sent from the web
|
|
@@ -680,6 +2137,45 @@ await sock.sendMessage(
|
|
|
680
2137
|
)
|
|
681
2138
|
```
|
|
682
2139
|
|
|
2140
|
+
### Album Message
|
|
2141
|
+
```ts
|
|
2142
|
+
await sock.sendMessage(
|
|
2143
|
+
id,
|
|
2144
|
+
{
|
|
2145
|
+
album: [{
|
|
2146
|
+
image: {
|
|
2147
|
+
url: 'https://example.com/blckrose.jpg'
|
|
2148
|
+
},
|
|
2149
|
+
caption: 'Hay'
|
|
2150
|
+
}, {
|
|
2151
|
+
image: Buffer,
|
|
2152
|
+
caption: 'Hay'
|
|
2153
|
+
}, {
|
|
2154
|
+
video: {
|
|
2155
|
+
url: 'https://example.com/blckrose.mp4'
|
|
2156
|
+
},
|
|
2157
|
+
caption: 'Hay'
|
|
2158
|
+
}, {
|
|
2159
|
+
video: Buffer,
|
|
2160
|
+
caption: 'Hay'
|
|
2161
|
+
}]
|
|
2162
|
+
}
|
|
2163
|
+
)
|
|
2164
|
+
```
|
|
2165
|
+
|
|
2166
|
+
#### Ptv Video Message
|
|
2167
|
+
```ts
|
|
2168
|
+
await sock.sendMessage(
|
|
2169
|
+
id,
|
|
2170
|
+
{
|
|
2171
|
+
video: {
|
|
2172
|
+
url: './Media/ma_gif.mp4'
|
|
2173
|
+
},
|
|
2174
|
+
ptv: true
|
|
2175
|
+
}
|
|
2176
|
+
)
|
|
2177
|
+
```
|
|
2178
|
+
|
|
683
2179
|
#### View Once Message
|
|
684
2180
|
|
|
685
2181
|
- You can send all messages above as `viewOnce`, you only need to pass `viewOnce: true` in content object
|
|
@@ -924,6 +2420,11 @@ await sock.sendMessage(
|
|
|
924
2420
|
)
|
|
925
2421
|
```
|
|
926
2422
|
|
|
2423
|
+
### Clear Messages
|
|
2424
|
+
```ts
|
|
2425
|
+
await sock.clearMessage(jid, key, timestamps)
|
|
2426
|
+
```
|
|
2427
|
+
|
|
927
2428
|
## User Querys
|
|
928
2429
|
|
|
929
2430
|
### Check If ID Exists in Whatsapp
|