@nexustechpro/baileys 1.1.2 → 1.1.4
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 +306 -261
- package/WAProto/fix-imports.js +71 -19
- package/WAProto/index.js +65468 -137440
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +145 -114
- package/lib/Socket/Client/websocket.js +35 -131
- package/lib/Socket/communities.js +1 -1
- package/lib/Socket/messages-recv.js +364 -1003
- package/lib/Socket/messages-send.js +179 -576
- package/lib/Socket/newsletter.js +141 -293
- package/lib/Socket/nexus-handler.js +29 -7
- package/lib/Socket/socket.js +162 -644
- package/lib/Store/index.js +5 -5
- package/lib/Store/make-in-memory-store.js +2 -2
- package/lib/Types/Newsletter.js +29 -31
- package/lib/Utils/chat-utils.js +1 -1
- package/lib/Utils/crypto.js +21 -47
- package/lib/Utils/generics.js +269 -352
- package/lib/Utils/identity-chnage-handler.js +55 -0
- package/lib/Utils/index.js +1 -0
- package/lib/Utils/lt-hash.js +2 -2
- package/lib/Utils/messages-media.js +200 -15
- package/lib/Utils/messages.js +354 -287
- package/lib/Utils/noise-handler.js +200 -166
- package/lib/WABinary/generic-utils.js +94 -0
- package/lib/index.js +2 -2
- package/package.json +137 -120
package/README.md
CHANGED
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
- [🛠️ Data Store](#️-data-store)
|
|
30
30
|
- [🔑 WhatsApp IDs](#-whatsapp-ids)
|
|
31
31
|
- [💬 Sending Messages](#-sending-messages)
|
|
32
|
-
- [
|
|
32
|
+
- [Text & Special Messages](#text--special-messages)
|
|
33
33
|
- [Media Messages](#media-messages)
|
|
34
|
-
- [Interactive Messages](#interactive-messages)
|
|
34
|
+
- [Buttons & Interactive Messages](#buttons--interactive-messages)
|
|
35
35
|
- [✏️ Message Modifications](#️-message-modifications)
|
|
36
36
|
- [📥 Media Operations](#-media-operations)
|
|
37
37
|
- [👥 Group Management](#-group-management)
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
<td>
|
|
62
62
|
|
|
63
63
|
### Extended Features
|
|
64
|
-
- 🎨 **
|
|
64
|
+
- 🎨 **Universal Button System** - Auto-converts any button format
|
|
65
65
|
- 📸 **Media Handling** - Images, videos, audio, documents
|
|
66
66
|
- 🤖 **Poll Support** - Create and manage polls
|
|
67
67
|
- 📍 **Location Sharing** - Share locations with metadata
|
|
@@ -108,7 +108,6 @@ const { default: makeWASocket } = require('@nexustechpro/baileys')
|
|
|
108
108
|
---
|
|
109
109
|
|
|
110
110
|
## 🔌 Quick Start
|
|
111
|
-
|
|
112
111
|
```javascript
|
|
113
112
|
import makeWASocket, { DisconnectReason, useMultiFileAuthState } from '@nexustechpro/baileys'
|
|
114
113
|
|
|
@@ -289,7 +288,6 @@ sock.ev.on('messages.update', async (event) => {
|
|
|
289
288
|
---
|
|
290
289
|
|
|
291
290
|
## 🛠️ Data Store
|
|
292
|
-
|
|
293
291
|
```javascript
|
|
294
292
|
import makeWASocket, { makeInMemoryStore } from '@nexustechpro/baileys'
|
|
295
293
|
|
|
@@ -329,7 +327,7 @@ sock.ev.on('contacts.upsert', () => {
|
|
|
329
327
|
|
|
330
328
|
## 💬 Sending Messages
|
|
331
329
|
|
|
332
|
-
###
|
|
330
|
+
### Text & Special Messages
|
|
333
331
|
|
|
334
332
|
#### Text Message
|
|
335
333
|
```javascript
|
|
@@ -519,175 +517,6 @@ await sock.sendMessage(jid, {
|
|
|
519
517
|
}, { quoted: message })
|
|
520
518
|
```
|
|
521
519
|
|
|
522
|
-
#### Interactive Message with Native Flow
|
|
523
|
-
```javascript
|
|
524
|
-
await sock.sendMessage(jid, {
|
|
525
|
-
interactiveMessage: {
|
|
526
|
-
title: "Hello World",
|
|
527
|
-
footer: "NexusTechPro",
|
|
528
|
-
image: { url: "https://example.com/image.jpg" },
|
|
529
|
-
nativeFlowMessage: {
|
|
530
|
-
messageParamsJson: JSON.stringify({
|
|
531
|
-
limited_time_offer: {
|
|
532
|
-
text: "Limited offer!",
|
|
533
|
-
url: "https://nexustechpro.com",
|
|
534
|
-
copy_code: "NEXUS2025",
|
|
535
|
-
expiration_time: Date.now() + (24 * 60 * 60 * 1000)
|
|
536
|
-
},
|
|
537
|
-
bottom_sheet: {
|
|
538
|
-
in_thread_buttons_limit: 2,
|
|
539
|
-
divider_indices: [1, 2, 3, 4, 5],
|
|
540
|
-
list_title: "Select Option",
|
|
541
|
-
button_title: "Click Here"
|
|
542
|
-
},
|
|
543
|
-
tap_target_configuration: {
|
|
544
|
-
title: "Tap Target",
|
|
545
|
-
description: "Description here",
|
|
546
|
-
canonical_url: "https://nexustechpro.com",
|
|
547
|
-
domain: "nexustechpro.com",
|
|
548
|
-
button_index: 0
|
|
549
|
-
}
|
|
550
|
-
}),
|
|
551
|
-
buttons: [
|
|
552
|
-
{
|
|
553
|
-
name: "single_select",
|
|
554
|
-
buttonParamsJson: JSON.stringify({
|
|
555
|
-
has_multiple_buttons: true
|
|
556
|
-
})
|
|
557
|
-
},
|
|
558
|
-
{
|
|
559
|
-
name: "call_permission_request",
|
|
560
|
-
buttonParamsJson: JSON.stringify({
|
|
561
|
-
has_multiple_buttons: true
|
|
562
|
-
})
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
name: "single_select",
|
|
566
|
-
buttonParamsJson: JSON.stringify({
|
|
567
|
-
title: "Select Option",
|
|
568
|
-
sections: [
|
|
569
|
-
{
|
|
570
|
-
title: "Section Title",
|
|
571
|
-
highlight_label: "Popular",
|
|
572
|
-
rows: [
|
|
573
|
-
{
|
|
574
|
-
title: "Option 1",
|
|
575
|
-
description: "Description 1",
|
|
576
|
-
id: "row_1"
|
|
577
|
-
},
|
|
578
|
-
{
|
|
579
|
-
title: "Option 2",
|
|
580
|
-
description: "Description 2",
|
|
581
|
-
id: "row_2"
|
|
582
|
-
}
|
|
583
|
-
]
|
|
584
|
-
}
|
|
585
|
-
],
|
|
586
|
-
has_multiple_buttons: true
|
|
587
|
-
})
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
name: "cta_copy",
|
|
591
|
-
buttonParamsJson: JSON.stringify({
|
|
592
|
-
display_text: "Copy Code",
|
|
593
|
-
id: "123456789",
|
|
594
|
-
copy_code: "NEXUS2025"
|
|
595
|
-
})
|
|
596
|
-
}
|
|
597
|
-
]
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}, { quoted: message })
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
#### Interactive Buttons
|
|
604
|
-
```javascript
|
|
605
|
-
// Example non header media
|
|
606
|
-
await sock.sendMessage(jid, {
|
|
607
|
-
text: "Description of Message",
|
|
608
|
-
title: "Title of Message",
|
|
609
|
-
subtitle: "Subtitle Message",
|
|
610
|
-
footer: "Footer Message",
|
|
611
|
-
interactiveButtons: [
|
|
612
|
-
{
|
|
613
|
-
name: "quick_reply",
|
|
614
|
-
buttonParamsJson: JSON.stringify({
|
|
615
|
-
display_text: "Quick Reply",
|
|
616
|
-
id: "button_1"
|
|
617
|
-
})
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
name: "cta_url",
|
|
621
|
-
buttonParamsJson: JSON.stringify({
|
|
622
|
-
display_text: "Visit Website",
|
|
623
|
-
url: "https://nexustechpro.com"
|
|
624
|
-
})
|
|
625
|
-
}
|
|
626
|
-
]
|
|
627
|
-
}, { quoted: message })
|
|
628
|
-
|
|
629
|
-
// Example with media
|
|
630
|
-
await sock.sendMessage(jid, {
|
|
631
|
-
image: { url: "https://example.jpg" }, // or buffer
|
|
632
|
-
caption: "Description of Message",
|
|
633
|
-
title: "Title of Message",
|
|
634
|
-
subtitle: "Subtitle Message",
|
|
635
|
-
footer: "Footer Message",
|
|
636
|
-
media: true,
|
|
637
|
-
interactiveButtons: [
|
|
638
|
-
{
|
|
639
|
-
name: "quick_reply",
|
|
640
|
-
buttonParamsJson: JSON.stringify({
|
|
641
|
-
display_text: "Quick Reply",
|
|
642
|
-
id: "button_1"
|
|
643
|
-
})
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
name: "cta_url",
|
|
647
|
-
buttonParamsJson: JSON.stringify({
|
|
648
|
-
display_text: "Visit Website",
|
|
649
|
-
url: "https://nexustechpro.com"
|
|
650
|
-
})
|
|
651
|
-
}
|
|
652
|
-
]
|
|
653
|
-
}, { quoted: message })
|
|
654
|
-
|
|
655
|
-
// Example with header product
|
|
656
|
-
await sock.sendMessage(jid, {
|
|
657
|
-
product: {
|
|
658
|
-
productImage: { url: "https://example.jpg" }, // or buffer
|
|
659
|
-
productImageCount: 1,
|
|
660
|
-
title: "Product Title",
|
|
661
|
-
description: "Product Description",
|
|
662
|
-
priceAmount1000: 20000 * 1000,
|
|
663
|
-
currencyCode: "USD",
|
|
664
|
-
retailerId: "Retail",
|
|
665
|
-
url: "https://example.com",
|
|
666
|
-
},
|
|
667
|
-
businessOwnerJid: "1234@s.whatsapp.net",
|
|
668
|
-
caption: "Description of Message",
|
|
669
|
-
title: "Title of Message",
|
|
670
|
-
footer: "Footer Message",
|
|
671
|
-
media: true,
|
|
672
|
-
interactiveButtons: [
|
|
673
|
-
{
|
|
674
|
-
name: "quick_reply",
|
|
675
|
-
buttonParamsJson: JSON.stringify({
|
|
676
|
-
display_text: "Quick Reply",
|
|
677
|
-
id: "button_1"
|
|
678
|
-
})
|
|
679
|
-
},
|
|
680
|
-
{
|
|
681
|
-
name: "cta_url",
|
|
682
|
-
buttonParamsJson: JSON.stringify({
|
|
683
|
-
display_text: "Visit Website",
|
|
684
|
-
url: "https://nexustechpro.com"
|
|
685
|
-
})
|
|
686
|
-
}
|
|
687
|
-
]
|
|
688
|
-
}, { quoted: message })
|
|
689
|
-
```
|
|
690
|
-
|
|
691
520
|
#### Forward Messages
|
|
692
521
|
```javascript
|
|
693
522
|
const msg = getMessageFromStore() // implement this on your end
|
|
@@ -863,12 +692,10 @@ await sock.sendMessage(jid, {
|
|
|
863
692
|
sticker: { url: './sticker.webp' }
|
|
864
693
|
})
|
|
865
694
|
```
|
|
866
|
-
#### Sticker Pack
|
|
867
695
|
|
|
868
|
-
|
|
696
|
+
#### Sticker Pack
|
|
869
697
|
|
|
870
698
|
### Method 1: Direct Socket Method (Recommended)
|
|
871
|
-
|
|
872
699
|
```javascript
|
|
873
700
|
await sock.stickerPackMessage(jid, {
|
|
874
701
|
name: 'My Stickers',
|
|
@@ -885,7 +712,6 @@ await sock.stickerPackMessage(jid, {
|
|
|
885
712
|
```
|
|
886
713
|
|
|
887
714
|
### Method 2: Via sendMessage
|
|
888
|
-
|
|
889
715
|
```javascript
|
|
890
716
|
await sock.sendMessage(jid, {
|
|
891
717
|
stickerPack: {
|
|
@@ -903,111 +729,125 @@ await sock.sendMessage(jid, {
|
|
|
903
729
|
}, { quoted: message });
|
|
904
730
|
```
|
|
905
731
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
## Supported Image Formats
|
|
909
|
-
|
|
910
|
-
Stickers automatically convert to WebP format. The following image formats are supported:
|
|
732
|
+
### Supported Image Formats
|
|
911
733
|
|
|
912
734
|
| Format | Support | Notes |
|
|
913
735
|
|--------|---------|-------|
|
|
914
736
|
| **WebP** | ✅ Full | Used as-is, no conversion needed |
|
|
915
737
|
| **PNG** | ✅ Full | Auto-converts to WebP |
|
|
916
738
|
| **JPG/JPEG** | ✅ Full | Auto-converts to WebP |
|
|
917
|
-
| **GIF** | ✅ Limited | Converts to static WebP
|
|
739
|
+
| **GIF** | ✅ Limited | Converts to static WebP |
|
|
918
740
|
| **BMP** | ✅ Full | Auto-converts to WebP |
|
|
919
|
-
| **Video
|
|
920
|
-
|
|
921
|
-
---
|
|
741
|
+
| **Video** | ❌ Not supported | Only static images |
|
|
922
742
|
|
|
923
|
-
|
|
743
|
+
### Key Features
|
|
924
744
|
|
|
925
|
-
|
|
745
|
+
✅ **Automatic batching** - Splits packs >60 stickers
|
|
746
|
+
✅ **Compression** - Auto-compresses stickers >1MB
|
|
747
|
+
✅ **Auto-conversion** - Converts PNG, JPG, GIF, BMP to WebP
|
|
748
|
+
✅ **Multiple formats** - Supports buffers, file paths, URLs
|
|
749
|
+
✅ **Rate limiting** - 2-second delays between batches
|
|
750
|
+
✅ **Error handling** - Gracefully skips invalid stickers
|
|
926
751
|
|
|
927
|
-
|
|
752
|
+
#### View Once Message
|
|
928
753
|
```javascript
|
|
929
|
-
{
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
754
|
+
await sock.sendMessage(jid, {
|
|
755
|
+
image: { url: './secret.jpg' },
|
|
756
|
+
viewOnce: true,
|
|
757
|
+
caption: 'View once only!'
|
|
758
|
+
})
|
|
933
759
|
```
|
|
934
760
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
data: './stickers/sticker.jpg',
|
|
939
|
-
emojis: ['😊']
|
|
940
|
-
}
|
|
941
|
-
```
|
|
761
|
+
---
|
|
762
|
+
|
|
763
|
+
### Buttons & Interactive Messages
|
|
942
764
|
|
|
943
|
-
|
|
765
|
+
#### Simple Text with Buttons
|
|
944
766
|
```javascript
|
|
945
|
-
{
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
767
|
+
await sock.sendMessage(jid, {
|
|
768
|
+
text: "Choose an option",
|
|
769
|
+
footer: "© NexusTechPro",
|
|
770
|
+
buttons: [
|
|
771
|
+
{
|
|
772
|
+
name: "quick_reply",
|
|
773
|
+
buttonParamsJson: JSON.stringify({
|
|
774
|
+
display_text: "Option 1",
|
|
775
|
+
id: "opt1"
|
|
776
|
+
})
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
name: "cta_url",
|
|
780
|
+
buttonParamsJson: JSON.stringify({
|
|
781
|
+
display_text: "Visit Website",
|
|
782
|
+
url: "https://nexustechpro.com",
|
|
783
|
+
merchant_url: "https://nexustechpro.com"
|
|
784
|
+
})
|
|
785
|
+
}
|
|
786
|
+
]
|
|
787
|
+
})
|
|
949
788
|
```
|
|
950
789
|
|
|
951
|
-
|
|
952
|
-
The cover image supports all the same formats:
|
|
953
|
-
|
|
790
|
+
#### Image with Buttons
|
|
954
791
|
```javascript
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
792
|
+
await sock.sendMessage(jid, {
|
|
793
|
+
image: { url: "https://example.com/image.jpg" },
|
|
794
|
+
caption: "Description",
|
|
795
|
+
footer: "© NexusTechPro",
|
|
796
|
+
buttons: [
|
|
797
|
+
{
|
|
798
|
+
name: "quick_reply",
|
|
799
|
+
buttonParamsJson: JSON.stringify({
|
|
800
|
+
display_text: "Reply",
|
|
801
|
+
id: "btn1"
|
|
802
|
+
})
|
|
803
|
+
}
|
|
804
|
+
]
|
|
805
|
+
})
|
|
963
806
|
```
|
|
964
807
|
|
|
965
|
-
|
|
808
|
+
#### Video with Buttons
|
|
966
809
|
```javascript
|
|
967
|
-
await sock.
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
{
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
}
|
|
810
|
+
await sock.sendMessage(jid, {
|
|
811
|
+
video: { url: "https://example.com/video.mp4" },
|
|
812
|
+
caption: "Watch this",
|
|
813
|
+
footer: "© NexusTechPro",
|
|
814
|
+
buttons: [
|
|
815
|
+
{
|
|
816
|
+
name: "quick_reply",
|
|
817
|
+
buttonParamsJson: JSON.stringify({
|
|
818
|
+
display_text: "Like",
|
|
819
|
+
id: "like"
|
|
820
|
+
})
|
|
821
|
+
}
|
|
822
|
+
]
|
|
823
|
+
})
|
|
979
824
|
```
|
|
980
825
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
## Key Features
|
|
984
|
-
|
|
985
|
-
✅ **Automatic batching** - Splits packs >60 stickers into multiple messages
|
|
986
|
-
✅ **Compression** - Auto-compresses stickers exceeding 1MB
|
|
987
|
-
✅ **Auto-conversion** - Converts PNG, JPG, GIF, BMP to WebP
|
|
988
|
-
✅ **Multiple formats** - Supports buffers, file paths, URLs, and streams
|
|
989
|
-
✅ **Rate limiting** - 2-second delays between batch sends
|
|
990
|
-
✅ **Error handling** - Gracefully skips invalid stickers
|
|
991
|
-
✅ **Emoji support** - Each sticker supports multiple emojis
|
|
992
|
-
✅ **Cover image** - Custom pack thumbnail
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
#### View Once Message
|
|
826
|
+
#### Document with Buttons
|
|
996
827
|
```javascript
|
|
997
828
|
await sock.sendMessage(jid, {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
829
|
+
document: { url: "./file.pdf" },
|
|
830
|
+
fileName: "Document.pdf",
|
|
831
|
+
mimetype: "application/pdf",
|
|
832
|
+
caption: "Read this",
|
|
833
|
+
footer: "© NexusTechPro",
|
|
834
|
+
buttons: [
|
|
835
|
+
{
|
|
836
|
+
name: "quick_reply",
|
|
837
|
+
buttonParamsJson: JSON.stringify({
|
|
838
|
+
display_text: "Download",
|
|
839
|
+
id: "download"
|
|
840
|
+
})
|
|
841
|
+
}
|
|
842
|
+
]
|
|
1001
843
|
})
|
|
1002
844
|
```
|
|
1003
845
|
|
|
1004
846
|
---
|
|
1005
847
|
|
|
1006
|
-
###
|
|
848
|
+
### All Button Types
|
|
1007
849
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
#### Quick Reply Button
|
|
850
|
+
#### 1. Quick Reply
|
|
1011
851
|
```javascript
|
|
1012
852
|
{
|
|
1013
853
|
name: "quick_reply",
|
|
@@ -1018,7 +858,7 @@ All button types available in NexusTechPro Baileys:
|
|
|
1018
858
|
}
|
|
1019
859
|
```
|
|
1020
860
|
|
|
1021
|
-
#### URL Button
|
|
861
|
+
#### 2. URL Button
|
|
1022
862
|
```javascript
|
|
1023
863
|
{
|
|
1024
864
|
name: "cta_url",
|
|
@@ -1030,7 +870,7 @@ All button types available in NexusTechPro Baileys:
|
|
|
1030
870
|
}
|
|
1031
871
|
```
|
|
1032
872
|
|
|
1033
|
-
#### Call Button
|
|
873
|
+
#### 3. Call Button
|
|
1034
874
|
```javascript
|
|
1035
875
|
{
|
|
1036
876
|
name: "cta_call",
|
|
@@ -1041,7 +881,7 @@ All button types available in NexusTechPro Baileys:
|
|
|
1041
881
|
}
|
|
1042
882
|
```
|
|
1043
883
|
|
|
1044
|
-
#### Copy Button
|
|
884
|
+
#### 4. Copy Button
|
|
1045
885
|
```javascript
|
|
1046
886
|
{
|
|
1047
887
|
name: "cta_copy",
|
|
@@ -1053,7 +893,7 @@ All button types available in NexusTechPro Baileys:
|
|
|
1053
893
|
}
|
|
1054
894
|
```
|
|
1055
895
|
|
|
1056
|
-
#### Single Select
|
|
896
|
+
#### 5. List/Single Select
|
|
1057
897
|
```javascript
|
|
1058
898
|
{
|
|
1059
899
|
name: "single_select",
|
|
@@ -1063,15 +903,15 @@ All button types available in NexusTechPro Baileys:
|
|
|
1063
903
|
title: "Section 1",
|
|
1064
904
|
highlight_label: "Popular",
|
|
1065
905
|
rows: [
|
|
1066
|
-
{ title: "Option 1", description: "
|
|
1067
|
-
{ title: "Option 2", description: "
|
|
906
|
+
{ title: "Option 1", description: "Desc 1", id: "opt1" },
|
|
907
|
+
{ title: "Option 2", description: "Desc 2", id: "opt2" }
|
|
1068
908
|
]
|
|
1069
909
|
}]
|
|
1070
910
|
})
|
|
1071
911
|
}
|
|
1072
912
|
```
|
|
1073
913
|
|
|
1074
|
-
#### Call Permission Request
|
|
914
|
+
#### 6. Call Permission Request
|
|
1075
915
|
```javascript
|
|
1076
916
|
{
|
|
1077
917
|
name: "call_permission_request",
|
|
@@ -1083,6 +923,211 @@ All button types available in NexusTechPro Baileys:
|
|
|
1083
923
|
|
|
1084
924
|
---
|
|
1085
925
|
|
|
926
|
+
### Classic Buttons (Old Style)
|
|
927
|
+
|
|
928
|
+
For compatibility with older WhatsApp versions:
|
|
929
|
+
```javascript
|
|
930
|
+
await sock.sendMessage(jid, {
|
|
931
|
+
text: "Message with classic buttons",
|
|
932
|
+
footer: "Footer text",
|
|
933
|
+
buttons: [
|
|
934
|
+
{
|
|
935
|
+
buttonId: "btn1",
|
|
936
|
+
buttonText: { displayText: "Button 1" },
|
|
937
|
+
type: 1
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
buttonId: "btn2",
|
|
941
|
+
buttonText: { displayText: "Button 2" },
|
|
942
|
+
type: 1
|
|
943
|
+
}
|
|
944
|
+
],
|
|
945
|
+
headerType: 1
|
|
946
|
+
})
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
#### Header Types (Classic Buttons)
|
|
950
|
+
|
|
951
|
+
| Value | Type | Description |
|
|
952
|
+
|-------|------|-------------|
|
|
953
|
+
| `0` | EMPTY | No header |
|
|
954
|
+
| `1` | TEXT | Text header (use `title` field) |
|
|
955
|
+
| `2` | DOCUMENT | Document header |
|
|
956
|
+
| `3` | IMAGE | Image header |
|
|
957
|
+
| `4` | VIDEO | Video header |
|
|
958
|
+
| `5` | LOCATION | Location header |
|
|
959
|
+
|
|
960
|
+
#### Button Types (Classic Buttons)
|
|
961
|
+
|
|
962
|
+
| Value | Type | Description |
|
|
963
|
+
|-------|------|-------------|
|
|
964
|
+
| `1` | RESPONSE | Standard clickable button |
|
|
965
|
+
| `2` | NATIVE_FLOW | Native flow button |
|
|
966
|
+
|
|
967
|
+
**Example with Image Header:**
|
|
968
|
+
```javascript
|
|
969
|
+
await sock.sendMessage(jid, {
|
|
970
|
+
image: { url: "https://example.com/image.jpg" },
|
|
971
|
+
caption: "Body text",
|
|
972
|
+
footer: "Footer",
|
|
973
|
+
buttons: [
|
|
974
|
+
{ buttonId: "btn1", buttonText: { displayText: "Button 1" }, type: 1 }
|
|
975
|
+
],
|
|
976
|
+
headerType: 3
|
|
977
|
+
})
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
---
|
|
981
|
+
|
|
982
|
+
### Advanced: Native Flow Messages
|
|
983
|
+
|
|
984
|
+
Complete example with all features:
|
|
985
|
+
```javascript
|
|
986
|
+
await sock.sendMessage(jid, {
|
|
987
|
+
interactiveMessage: {
|
|
988
|
+
title: "Interactive Message",
|
|
989
|
+
footer: "© NexusTechPro",
|
|
990
|
+
image: { url: "https://example.com/image.jpg" },
|
|
991
|
+
nativeFlowMessage: {
|
|
992
|
+
messageParamsJson: JSON.stringify({
|
|
993
|
+
limited_time_offer: {
|
|
994
|
+
text: "Limited offer!",
|
|
995
|
+
url: "https://nexustechpro.com",
|
|
996
|
+
copy_code: "NEXUS2025",
|
|
997
|
+
expiration_time: Date.now() + (24 * 60 * 60 * 1000)
|
|
998
|
+
},
|
|
999
|
+
bottom_sheet: {
|
|
1000
|
+
in_thread_buttons_limit: 2,
|
|
1001
|
+
divider_indices: [0, 1, 2],
|
|
1002
|
+
list_title: "Select Option",
|
|
1003
|
+
button_title: "Click Here"
|
|
1004
|
+
},
|
|
1005
|
+
tap_target_configuration: {
|
|
1006
|
+
title: "Tap Target",
|
|
1007
|
+
description: "Description",
|
|
1008
|
+
canonical_url: "https://nexustechpro.com",
|
|
1009
|
+
domain: "nexustechpro.com",
|
|
1010
|
+
button_index: 0
|
|
1011
|
+
}
|
|
1012
|
+
}),
|
|
1013
|
+
buttons: [
|
|
1014
|
+
{
|
|
1015
|
+
name: "single_select",
|
|
1016
|
+
buttonParamsJson: JSON.stringify({
|
|
1017
|
+
title: "Select",
|
|
1018
|
+
sections: [{
|
|
1019
|
+
title: "Options",
|
|
1020
|
+
rows: [
|
|
1021
|
+
{ title: "Option 1", description: "Desc 1", id: "opt1" }
|
|
1022
|
+
]
|
|
1023
|
+
}]
|
|
1024
|
+
})
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
name: "cta_copy",
|
|
1028
|
+
buttonParamsJson: JSON.stringify({
|
|
1029
|
+
display_text: "Copy Code",
|
|
1030
|
+
copy_code: "PROMO2025"
|
|
1031
|
+
})
|
|
1032
|
+
}
|
|
1033
|
+
]
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
})
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
---
|
|
1040
|
+
|
|
1041
|
+
### Interactive Buttons (Alternative Format)
|
|
1042
|
+
```javascript
|
|
1043
|
+
// Example non header media
|
|
1044
|
+
await sock.sendMessage(jid, {
|
|
1045
|
+
text: "Description of Message",
|
|
1046
|
+
title: "Title of Message",
|
|
1047
|
+
subtitle: "Subtitle Message",
|
|
1048
|
+
footer: "Footer Message",
|
|
1049
|
+
interactiveButtons: [
|
|
1050
|
+
{
|
|
1051
|
+
name: "quick_reply",
|
|
1052
|
+
buttonParamsJson: JSON.stringify({
|
|
1053
|
+
display_text: "Quick Reply",
|
|
1054
|
+
id: "button_1"
|
|
1055
|
+
})
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
name: "cta_url",
|
|
1059
|
+
buttonParamsJson: JSON.stringify({
|
|
1060
|
+
display_text: "Visit Website",
|
|
1061
|
+
url: "https://nexustechpro.com"
|
|
1062
|
+
})
|
|
1063
|
+
}
|
|
1064
|
+
]
|
|
1065
|
+
}, { quoted: message })
|
|
1066
|
+
|
|
1067
|
+
// Example with media
|
|
1068
|
+
await sock.sendMessage(jid, {
|
|
1069
|
+
image: { url: "https://example.jpg" }, // or buffer
|
|
1070
|
+
caption: "Description of Message",
|
|
1071
|
+
title: "Title of Message",
|
|
1072
|
+
subtitle: "Subtitle Message",
|
|
1073
|
+
footer: "Footer Message",
|
|
1074
|
+
media: true,
|
|
1075
|
+
interactiveButtons: [
|
|
1076
|
+
{
|
|
1077
|
+
name: "quick_reply",
|
|
1078
|
+
buttonParamsJson: JSON.stringify({
|
|
1079
|
+
display_text: "Quick Reply",
|
|
1080
|
+
id: "button_1"
|
|
1081
|
+
})
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
name: "cta_url",
|
|
1085
|
+
buttonParamsJson: JSON.stringify({
|
|
1086
|
+
display_text: "Visit Website",
|
|
1087
|
+
url: "https://nexustechpro.com"
|
|
1088
|
+
})
|
|
1089
|
+
}
|
|
1090
|
+
]
|
|
1091
|
+
}, { quoted: message })
|
|
1092
|
+
|
|
1093
|
+
// Example with header product
|
|
1094
|
+
await sock.sendMessage(jid, {
|
|
1095
|
+
product: {
|
|
1096
|
+
productImage: { url: "https://example.jpg" }, // or buffer
|
|
1097
|
+
productImageCount: 1,
|
|
1098
|
+
title: "Product Title",
|
|
1099
|
+
description: "Product Description",
|
|
1100
|
+
priceAmount1000: 20000 * 1000,
|
|
1101
|
+
currencyCode: "USD",
|
|
1102
|
+
retailerId: "Retail",
|
|
1103
|
+
url: "https://example.com",
|
|
1104
|
+
},
|
|
1105
|
+
businessOwnerJid: "1234@s.whatsapp.net",
|
|
1106
|
+
caption: "Description of Message",
|
|
1107
|
+
title: "Title of Message",
|
|
1108
|
+
footer: "Footer Message",
|
|
1109
|
+
media: true,
|
|
1110
|
+
interactiveButtons: [
|
|
1111
|
+
{
|
|
1112
|
+
name: "quick_reply",
|
|
1113
|
+
buttonParamsJson: JSON.stringify({
|
|
1114
|
+
display_text: "Quick Reply",
|
|
1115
|
+
id: "button_1"
|
|
1116
|
+
})
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
name: "cta_url",
|
|
1120
|
+
buttonParamsJson: JSON.stringify({
|
|
1121
|
+
display_text: "Visit Website",
|
|
1122
|
+
url: "https://nexustechpro.com"
|
|
1123
|
+
})
|
|
1124
|
+
}
|
|
1125
|
+
]
|
|
1126
|
+
}, { quoted: message })
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
---
|
|
1130
|
+
|
|
1086
1131
|
## ✏️ Message Modifications
|
|
1087
1132
|
|
|
1088
1133
|
### Delete Message (for everyone)
|
|
@@ -1698,4 +1743,4 @@ Special thanks to:
|
|
|
1698
1743
|
|
|
1699
1744
|
[GitHub](https://github.com/nexustechpro/baileys) • [NPM](https://www.npmjs.com/package/@nexustechpro/baileys) • [Documentation](https://github.com/nexustechpro/baileys/wiki)
|
|
1700
1745
|
|
|
1701
|
-
</div>
|
|
1746
|
+
</div>
|