@pontalabs/baileys 1.2.3 โ 1.2.5
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 +479 -605
- package/lib/Socket/messages-send.js +147 -10
- package/lib/Utils/mbuilder.d.ts +9 -3
- package/lib/Utils/mbuilder.js +25 -14
- package/lib/Utils/rich-message-utils.js +31 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -584,215 +584,170 @@ await sock.sendMessage(jid, {
|
|
|
584
584
|
|
|
585
585
|
---
|
|
586
586
|
|
|
587
|
-
###
|
|
588
|
-
|
|
589
|
-
`build.*` adalah cara singkat untuk membuat **Rich AI item** yang langsung bisa dipakai di `sock.sendMessage()`.
|
|
587
|
+
### ๐ค Rich Messages
|
|
590
588
|
|
|
591
|
-
>
|
|
589
|
+
> Semua fitur **Rich Message** dikirim melalui `sock.sendMessage()` dan dirender sebagai AI bot message di WhatsApp.
|
|
590
|
+
>
|
|
591
|
+
> **Tidak ada daftar `build.*` terpisah.** Builder, shortcut lama, `items`, `richResponse`, HTML WebView, interactive builder, dan opsi terkait semuanya didokumentasikan di bagian ini supaya API Rich tetap berada di satu tempat.
|
|
592
592
|
|
|
593
|
-
|
|
593
|
+
<details>
|
|
594
|
+
<summary><b>๐ Quick Start โ Rich Message</b></summary>
|
|
594
595
|
|
|
595
596
|
```js
|
|
596
597
|
await sock.sendMessage(jid, {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
build.richCode('console.log("hello")', 'javascript'),
|
|
600
|
-
build.richTip('Selesai!')
|
|
601
|
-
]
|
|
602
|
-
})
|
|
598
|
+
richText: 'Halo! ๐'
|
|
599
|
+
}, { quoted: message })
|
|
603
600
|
```
|
|
604
601
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
#### โฑ๏ธ Delay antar build
|
|
608
|
-
|
|
609
|
-
Kalau setiap item builder ingin dikirim sebagai **pesan terpisah**, gunakan `buildDelay` dalam milidetik:
|
|
602
|
+
Builder `build.*` hanya membuat payload. Pengiriman tetap melalui `sock.sendMessage()`:
|
|
610
603
|
|
|
611
604
|
```js
|
|
612
605
|
await sock.sendMessage(jid, {
|
|
613
606
|
items: [
|
|
614
|
-
build.richText('
|
|
615
|
-
build.
|
|
616
|
-
|
|
617
|
-
],
|
|
618
|
-
buildDelay: 1000
|
|
607
|
+
build.richText('Halo! ๐'),
|
|
608
|
+
build.richTip('Dikirim dari PontaLabs')
|
|
609
|
+
]
|
|
619
610
|
})
|
|
620
611
|
```
|
|
621
612
|
|
|
622
|
-
|
|
613
|
+
> `build` tersedia dari package dan tidak membutuhkan `sock` saat membuat payload.
|
|
623
614
|
|
|
624
|
-
|
|
615
|
+
</details>
|
|
625
616
|
|
|
626
|
-
>
|
|
617
|
+
<details>
|
|
618
|
+
<summary><b>๐ Rich Text โ <code>richText</code></b></summary>
|
|
627
619
|
|
|
628
|
-
|
|
620
|
+
Rich markdown text yang dirender sebagai `GenAIMarkdownTextUXPrimitive`.
|
|
629
621
|
|
|
630
|
-
|
|
631
|
-
| --- | --- | --- |
|
|
632
|
-
| `build.richText(text)` | `build.richText('Halo')` | Text |
|
|
633
|
-
| `build.richFOAText(text)` | `build.richFOAText('Halo')` | FOA text |
|
|
634
|
-
| `build.richHtml(html)` | `build.richHtml('<html>...</html>')` | HTML WebView |
|
|
635
|
-
| `build.richCode(code, language)` | `build.richCode('console.log(1)', 'javascript')` | Code |
|
|
636
|
-
| `build.richTable(table)` | `build.richTable([['A', 'B']])` | Table |
|
|
637
|
-
| `build.richSource(sources)` | `build.richSource([...])` | Sources |
|
|
638
|
-
| `build.richReels(items)` | `build.richReels([...])` | Reels |
|
|
639
|
-
| `build.richImage(url)` | `build.richImage('https://...')` | Image |
|
|
640
|
-
| `build.richVideo(url)` | `build.richVideo('https://...')` | Video |
|
|
641
|
-
| `build.richProduct(data)` | `build.richProduct({...})` | Product |
|
|
642
|
-
| `build.richPost(data)` | `build.richPost({...})` | Post |
|
|
643
|
-
| `build.richMetadata(text)` | `build.richMetadata('Info')` | Metadata |
|
|
644
|
-
| `build.richTip(text)` | `build.richTip('Tip')` | Tip |
|
|
645
|
-
| `build.richWidget(data)` | `build.richWidget({...})` | Widget |
|
|
646
|
-
| `build.richFooterAction(data)` | `build.richFooterAction({...})` | Footer action |
|
|
647
|
-
| `build.richSuggest(value)` | `build.richSuggest('Lanjutkan')` | Suggestion |
|
|
622
|
+
**Direct:**
|
|
648
623
|
|
|
649
|
-
|
|
624
|
+
```js
|
|
625
|
+
await sock.sendMessage(jid, {
|
|
626
|
+
richText: '*Halo!* Ini rich text dari bot.\nStatus: `success`\nWaktu: _120ms_'
|
|
627
|
+
}, { quoted: message })
|
|
628
|
+
```
|
|
650
629
|
|
|
651
|
-
|
|
630
|
+
**Array / beberapa paragraf:**
|
|
652
631
|
|
|
653
632
|
```js
|
|
654
633
|
await sock.sendMessage(jid, {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
build.richTip('Tip dari Builder')
|
|
634
|
+
richText: [
|
|
635
|
+
'Baris pertama.',
|
|
636
|
+
'Baris kedua.',
|
|
637
|
+
'Baris ketiga.'
|
|
660
638
|
]
|
|
661
|
-
})
|
|
639
|
+
}, { quoted: message })
|
|
662
640
|
```
|
|
663
641
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
`build.richHtml()` membuat primitive HTML Rich AI seperti webview. HTML dikirim sebagai payload langsung ke primitive `GenAIaeacdsnwHtmlPrimitive`.
|
|
642
|
+
**Builder:**
|
|
667
643
|
|
|
668
644
|
```js
|
|
669
|
-
const html = `<!DOCTYPE html>
|
|
670
|
-
<html>
|
|
671
|
-
<body style="margin:0;padding:20px;font-family:Arial">
|
|
672
|
-
<h2>๐ฎ Game Center</h2>
|
|
673
|
-
<button onclick="document.body.innerHTML += '<p>Clicked!</p>'">
|
|
674
|
-
Play
|
|
675
|
-
</button>
|
|
676
|
-
</body>
|
|
677
|
-
</html>`
|
|
678
|
-
|
|
679
645
|
await sock.sendMessage(jid, {
|
|
680
|
-
items: [
|
|
646
|
+
items: [
|
|
647
|
+
build.richText('Halo! ๐')
|
|
648
|
+
]
|
|
681
649
|
})
|
|
682
650
|
```
|
|
683
651
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
#### ๐ ๏ธ Builder untuk edit / delete
|
|
687
|
-
|
|
688
|
-
Untuk kebutuhan yang benar-benar membutuhkan state dan manipulasi node, gunakan `build.AIRich(sock)`.
|
|
652
|
+
**Raw item:**
|
|
689
653
|
|
|
690
654
|
```js
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
await ai.send(jid)
|
|
697
|
-
|
|
698
|
-
// Ganti node berdasarkan ID
|
|
699
|
-
ai.addText('โ
Selesai!', { replace: 'status' })
|
|
700
|
-
|
|
701
|
-
// Hapus node
|
|
702
|
-
ai.delete('status')
|
|
703
|
-
|
|
704
|
-
// Sisipkan setelah node tertentu
|
|
705
|
-
ai.addTip('Tambahan', { insertAt: 'status' })
|
|
655
|
+
await sock.sendMessage(jid, {
|
|
656
|
+
items: [
|
|
657
|
+
{ text: 'Halo! ๐' }
|
|
658
|
+
]
|
|
659
|
+
})
|
|
706
660
|
```
|
|
707
661
|
|
|
708
|
-
>
|
|
709
|
-
|
|
710
|
-
#### ๐ Contoh workflow edit
|
|
662
|
+
</details>
|
|
711
663
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
ai.addText('โณ Memproses...', { id: 'answer' })
|
|
664
|
+
<details>
|
|
665
|
+
<summary><b>๐ Rich HTML WebView โ <code>richHtml</code></b></summary>
|
|
715
666
|
|
|
716
|
-
|
|
667
|
+
Mengirim HTML langsung ke primitive `GenAIaeacdsnwHtmlPrimitive`.
|
|
717
668
|
|
|
718
|
-
|
|
669
|
+
**Direct `sendMessage`:**
|
|
719
670
|
|
|
720
|
-
|
|
721
|
-
|
|
671
|
+
```js
|
|
672
|
+
const html = `<!DOCTYPE html>
|
|
673
|
+
<html>
|
|
674
|
+
<head>
|
|
675
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
676
|
+
</head>
|
|
677
|
+
<body>
|
|
678
|
+
<h2>๐ฎ Game Center</h2>
|
|
679
|
+
<button onclick="document.body.innerHTML += '<p>Clicked!</p>'">
|
|
680
|
+
Play
|
|
681
|
+
</button>
|
|
682
|
+
</body>
|
|
683
|
+
</html>`
|
|
722
684
|
|
|
723
|
-
await
|
|
685
|
+
await sock.sendMessage(jid, {
|
|
686
|
+
richHtml: html
|
|
687
|
+
}, { quoted: message })
|
|
724
688
|
```
|
|
725
689
|
|
|
726
|
-
|
|
690
|
+
**Builder:**
|
|
727
691
|
|
|
728
692
|
```js
|
|
729
|
-
await sock.sendMessage(jid, {
|
|
730
|
-
richText: 'Halo'
|
|
731
|
-
})
|
|
732
|
-
|
|
733
693
|
await sock.sendMessage(jid, {
|
|
734
694
|
items: [
|
|
735
|
-
|
|
736
|
-
{ richTip: 'Testing' }
|
|
695
|
+
build.richHtml(html)
|
|
737
696
|
]
|
|
738
697
|
})
|
|
739
698
|
```
|
|
740
699
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
- **`sock.sendMessage()` + shortcut** โ paling sederhana.
|
|
744
|
-
- **`sock.sendMessage()` + `build.rich*()`** โ payload Rich AI yang lebih rapi dan mudah dirangkai.
|
|
745
|
-
- **`build.AIRich(sock)`** โ kebutuhan advanced seperti `id`, `replace`, `insertAt`, `delete`, dan edit message.
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
### ๐ค Rich Messages
|
|
749
|
-
|
|
750
|
-
> All rich messages are sent via standard `sendMessage` and rendered as AI bot messages in WhatsApp. Use the appropriate key instead of `text`, `image`, `video`, etc.
|
|
751
|
-
|
|
752
|
-
**Quick jump:** [Rich Text](#rich-text) ยท [Code](#rich-code-block) ยท [Table](#rich-table) ยท [Images](#rich-images) ยท [Video](#rich-video) ยท [Suggestions](#rich-suggestions) ยท [LaTeX](#rich-latex) ยท [Product](#rich-product) ยท [Post](#rich-post) ยท [Reels](#rich-reels) ยท [Sources](#rich-sources) ยท [Tip & Footer](#rich-tip--footer) ยท [Mixed](#rich-mixed) ยท [Response](#rich-response)
|
|
753
|
-
|
|
754
|
-
---
|
|
755
|
-
|
|
756
|
-
#### ๐ Rich Text
|
|
757
|
-
|
|
758
|
-
> AI bot-styled markdown text rendered in `richResponseMessage`.
|
|
759
|
-
|
|
760
|
-
<details>
|
|
761
|
-
<summary><b>Simple Text</b></summary>
|
|
700
|
+
**Raw item:**
|
|
762
701
|
|
|
763
702
|
```js
|
|
764
|
-
await sock.sendMessage(jid, {
|
|
703
|
+
await sock.sendMessage(jid, {
|
|
704
|
+
items: [
|
|
705
|
+
{ html: html }
|
|
706
|
+
]
|
|
707
|
+
})
|
|
765
708
|
```
|
|
766
|
-
</details>
|
|
767
709
|
|
|
768
|
-
|
|
769
|
-
<summary><b>Markdown (bold, italic, inline code)</b></summary>
|
|
710
|
+
> HTML berjalan di sisi client/webview. Gunakan HTML/JavaScript yang kamu kontrol dan sesuaikan dengan dukungan client WhatsApp yang dituju.
|
|
770
711
|
|
|
771
|
-
```js
|
|
772
|
-
await sock.sendMessage(jid, {
|
|
773
|
-
richText: '*Hasil eksekusi:*\nStatus: `success`\nWaktu: _120ms_'
|
|
774
|
-
}, { quoted: message })
|
|
775
|
-
```
|
|
776
712
|
</details>
|
|
777
|
-
|
|
778
713
|
<details>
|
|
779
|
-
<summary
|
|
714
|
+
<summary>๐ค richCard โ Entity Card</summary>
|
|
715
|
+
|
|
716
|
+
Membuat Card Entity/Profile langsung melalui `sendMessage()`. Tidak membutuhkan `build` atau `AIRich`.
|
|
780
717
|
|
|
781
718
|
```js
|
|
782
|
-
await
|
|
783
|
-
|
|
784
|
-
|
|
719
|
+
await conn.sendMessage(m.chat, {
|
|
720
|
+
richCard: {
|
|
721
|
+
thumbnail_url: 'https://example.com/profile.jpg',
|
|
722
|
+
verification: true,
|
|
723
|
+
title: 'PontaLabs',
|
|
724
|
+
subtitle: 'Owner: Ponta',
|
|
725
|
+
description: 'Ini Ownernya',
|
|
726
|
+
entity_id: '6283857182374',
|
|
727
|
+
entity_url: 'https://wa.me/6283857182374',
|
|
728
|
+
profile_url: 'https://example.com/profile.jpg'
|
|
729
|
+
}
|
|
730
|
+
});
|
|
785
731
|
```
|
|
786
|
-
</details>
|
|
787
732
|
|
|
788
|
-
|
|
733
|
+
| Property | Type | Description |
|
|
734
|
+
|---|---|---|
|
|
735
|
+
| `thumbnail_url` | `string` | Thumbnail Card |
|
|
736
|
+
| `verification` | `boolean` | Status verified |
|
|
737
|
+
| `title` | `string` | Judul Entity |
|
|
738
|
+
| `subtitle` | `string` | Subjudul |
|
|
739
|
+
| `description` | `string` | Deskripsi |
|
|
740
|
+
| `entity_id` | `string` | ID Entity |
|
|
741
|
+
| `entity_url` | `string` | URL Entity |
|
|
742
|
+
| `profile_url` | `string` | URL fallback/profile |
|
|
789
743
|
|
|
790
|
-
|
|
744
|
+
</details>
|
|
791
745
|
|
|
792
|
-
> Syntax-highlighted code. Use `code` for single block, `codes` for multiple.
|
|
793
746
|
|
|
794
747
|
<details>
|
|
795
|
-
<summary><b>
|
|
748
|
+
<summary><b>๐ป Rich Code โ <code>code</code> / <code>codes</code> / <code>richCode</code></b></summary>
|
|
749
|
+
|
|
750
|
+
**Single block:**
|
|
796
751
|
|
|
797
752
|
```js
|
|
798
753
|
await sock.sendMessage(jid, {
|
|
@@ -800,50 +755,36 @@ await sock.sendMessage(jid, {
|
|
|
800
755
|
language: 'javascript'
|
|
801
756
|
}, { quoted: message })
|
|
802
757
|
```
|
|
803
|
-
</details>
|
|
804
758
|
|
|
805
|
-
|
|
806
|
-
<summary><b>Multiple Blocks</b></summary>
|
|
759
|
+
**Multiple blocks:**
|
|
807
760
|
|
|
808
761
|
```js
|
|
809
762
|
await sock.sendMessage(jid, {
|
|
810
763
|
codes: [
|
|
811
|
-
{ code: '
|
|
812
|
-
{ code: '
|
|
764
|
+
{ code: 'console.log("hello")', language: 'javascript' },
|
|
765
|
+
{ code: 'SELECT * FROM users;', language: 'sql' }
|
|
813
766
|
]
|
|
814
767
|
}, { quoted: message })
|
|
815
768
|
```
|
|
816
|
-
</details>
|
|
817
|
-
|
|
818
|
-
<details>
|
|
819
|
-
<summary><b>Supported Languages</b></summary>
|
|
820
|
-
|
|
821
|
-
| Language | Key |
|
|
822
|
-
|:---|:---|
|
|
823
|
-
| JavaScript | `javascript` ยท `js` |
|
|
824
|
-
| TypeScript | `typescript` ยท `ts` |
|
|
825
|
-
| Python | `python` ยท `py` |
|
|
826
|
-
| Bash / Shell | `bash` ยท `sh` ยท `zsh` |
|
|
827
|
-
| Go | `go` ยท `golang` |
|
|
828
|
-
| Rust | `rust` ยท `rs` |
|
|
829
|
-
| C / C++ | `c` ยท `h` ยท `cpp` ยท `c++` |
|
|
830
|
-
| C# | `csharp` ยท `cs` |
|
|
831
|
-
| CSS / HTML | `css` ยท `html` |
|
|
832
|
-
| PowerShell / CMD | `powershell` ยท `ps1` ยท `cmd` ยท `bat` |
|
|
833
|
-
| SQL / JSON | `sql` ยท `json` |
|
|
834
769
|
|
|
835
|
-
|
|
770
|
+
**Builder:**
|
|
836
771
|
|
|
837
|
-
|
|
772
|
+
```js
|
|
773
|
+
await sock.sendMessage(jid, {
|
|
774
|
+
items: [
|
|
775
|
+
build.richCode('console.log("hello")', 'javascript')
|
|
776
|
+
]
|
|
777
|
+
})
|
|
778
|
+
```
|
|
838
779
|
|
|
839
|
-
|
|
780
|
+
**Supported language aliases:** `javascript`, `js`, `typescript`, `ts`, `python`, `py`, `bash`, `sh`, `zsh`, `go`, `golang`, `rust`, `rs`, `c`, `h`, `cpp`, `c++`, `csharp`, `cs`, `css`, `html`, `powershell`, `ps1`, `cmd`, `bat`, `sql`, `json`.
|
|
840
781
|
|
|
841
|
-
>
|
|
842
|
-
>
|
|
843
|
-
> โ ๏ธ Shorthand `{ title?, headers?, rows }` ini hanya berlaku untuk key `table` top-level dan di dalam `items`. Kalau dipakai di dalam `richResponse`, isi `table` harus sudah berupa array baris jadi โ lihat [Rich Response](#-rich-response--richresponse).
|
|
782
|
+
</details>
|
|
844
783
|
|
|
845
784
|
<details>
|
|
846
|
-
<summary><b
|
|
785
|
+
<summary><b>๐ Rich Table โ <code>table</code> / <code>richTable</code></b></summary>
|
|
786
|
+
|
|
787
|
+
**Top-level:**
|
|
847
788
|
|
|
848
789
|
```js
|
|
849
790
|
await sock.sendMessage(jid, {
|
|
@@ -858,57 +799,37 @@ await sock.sendMessage(jid, {
|
|
|
858
799
|
}
|
|
859
800
|
}, { quoted: message })
|
|
860
801
|
```
|
|
861
|
-
</details>
|
|
862
802
|
|
|
863
|
-
|
|
864
|
-
<summary><b>Table without Title</b></summary>
|
|
803
|
+
**Builder:**
|
|
865
804
|
|
|
866
805
|
```js
|
|
867
806
|
await sock.sendMessage(jid, {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
['
|
|
872
|
-
['
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
}, { quoted: message })
|
|
807
|
+
items: [
|
|
808
|
+
build.richTable([
|
|
809
|
+
['Name', 'Role'],
|
|
810
|
+
['Ponta', 'Admin'],
|
|
811
|
+
['Yue', 'Member']
|
|
812
|
+
])
|
|
813
|
+
]
|
|
814
|
+
})
|
|
877
815
|
```
|
|
878
|
-
</details>
|
|
879
816
|
|
|
880
|
-
|
|
881
|
-
<summary><b>Data Only (no header)</b></summary>
|
|
817
|
+
> Untuk `richResponse`, format `table` berbeda: gunakan array baris siap-pakai seperti `{ items: [...], isHeading }`, bukan `{ headers, rows }`.
|
|
882
818
|
|
|
883
|
-
```js
|
|
884
|
-
await sock.sendMessage(jid, {
|
|
885
|
-
table: {
|
|
886
|
-
rows: [
|
|
887
|
-
['RAM', '512 MB'],
|
|
888
|
-
['CPU', '4 Core'],
|
|
889
|
-
['Uptime', '99.9%']
|
|
890
|
-
]
|
|
891
|
-
}
|
|
892
|
-
}, { quoted: message })
|
|
893
|
-
```
|
|
894
819
|
</details>
|
|
895
820
|
|
|
896
|
-
---
|
|
897
|
-
|
|
898
|
-
#### ๐ผ๏ธ Rich Images
|
|
899
|
-
|
|
900
|
-
> AI image grid. Single URL = single image, multiple URLs = carousel.
|
|
901
|
-
|
|
902
821
|
<details>
|
|
903
|
-
<summary><b>
|
|
822
|
+
<summary><b>๐ผ๏ธ Rich Images โ <code>richImages</code> / <code>richImage</code></b></summary>
|
|
823
|
+
|
|
824
|
+
**Single image:**
|
|
904
825
|
|
|
905
826
|
```js
|
|
906
|
-
await sock.sendMessage(jid, {
|
|
827
|
+
await sock.sendMessage(jid, {
|
|
828
|
+
richImages: 'https://example.com/photo.jpg'
|
|
829
|
+
}, { quoted: message })
|
|
907
830
|
```
|
|
908
|
-
</details>
|
|
909
831
|
|
|
910
|
-
|
|
911
|
-
<summary><b>Multiple Images (Grid)</b></summary>
|
|
832
|
+
**Multiple images:**
|
|
912
833
|
|
|
913
834
|
```js
|
|
914
835
|
await sock.sendMessage(jid, {
|
|
@@ -919,252 +840,156 @@ await sock.sendMessage(jid, {
|
|
|
919
840
|
]
|
|
920
841
|
}, { quoted: message })
|
|
921
842
|
```
|
|
922
|
-
</details>
|
|
923
843
|
|
|
924
|
-
|
|
925
|
-
<summary><b>Inside items / richResponse</b></summary>
|
|
844
|
+
**Builder:**
|
|
926
845
|
|
|
927
846
|
```js
|
|
928
|
-
// items
|
|
929
847
|
await sock.sendMessage(jid, {
|
|
930
848
|
items: [
|
|
931
|
-
|
|
932
|
-
{ images: ['https://example.com/1.jpg', 'https://example.com/2.jpg'] }
|
|
849
|
+
build.richImage('https://example.com/photo.jpg')
|
|
933
850
|
]
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
// richResponse
|
|
937
|
-
await sock.sendMessage(jid, {
|
|
938
|
-
richResponse: [
|
|
939
|
-
{ text: 'Lihat gambarnya:' },
|
|
940
|
-
{ images: 'https://example.com/banner.jpg' }
|
|
941
|
-
]
|
|
942
|
-
}, { quoted: message })
|
|
851
|
+
})
|
|
943
852
|
```
|
|
944
|
-
</details>
|
|
945
|
-
|
|
946
|
-
---
|
|
947
|
-
|
|
948
|
-
#### ๐ฅ Rich Video
|
|
949
853
|
|
|
950
|
-
>
|
|
854
|
+
</details>
|
|
951
855
|
|
|
952
856
|
<details>
|
|
953
|
-
<summary><b>
|
|
857
|
+
<summary><b>๐ฅ Rich Video โ <code>richVideo</code> / <code>richVideo</code> builder</b></summary>
|
|
858
|
+
|
|
859
|
+
**Shorthand:**
|
|
954
860
|
|
|
955
861
|
```js
|
|
956
|
-
await sock.sendMessage(jid, {
|
|
862
|
+
await sock.sendMessage(jid, {
|
|
863
|
+
richVideo: 'https://example.com/clip.mp4'
|
|
864
|
+
}, { quoted: message })
|
|
957
865
|
```
|
|
958
|
-
</details>
|
|
959
866
|
|
|
960
|
-
|
|
961
|
-
<summary><b>Full Options</b></summary>
|
|
867
|
+
**Full options:**
|
|
962
868
|
|
|
963
869
|
```js
|
|
964
870
|
await sock.sendMessage(jid, {
|
|
965
871
|
richVideo: {
|
|
966
872
|
url: 'https://example.com/clip.mp4',
|
|
967
|
-
mimeType: 'video/mp4',
|
|
968
|
-
duration: 15,
|
|
969
|
-
fallbackText: 'Preview video'
|
|
873
|
+
mimeType: 'video/mp4',
|
|
874
|
+
duration: 15,
|
|
875
|
+
fallbackText: 'Preview video'
|
|
970
876
|
}
|
|
971
877
|
}, { quoted: message })
|
|
972
878
|
```
|
|
973
|
-
</details>
|
|
974
879
|
|
|
975
|
-
|
|
976
|
-
<summary><b>Inside items / richResponse</b></summary>
|
|
880
|
+
**Builder:**
|
|
977
881
|
|
|
978
882
|
```js
|
|
979
|
-
// items
|
|
980
883
|
await sock.sendMessage(jid, {
|
|
981
884
|
items: [
|
|
982
|
-
|
|
983
|
-
{ videoUrl: 'https://example.com/clip.mp4', duration: 20 }
|
|
984
|
-
]
|
|
985
|
-
}, { quoted: message })
|
|
986
|
-
|
|
987
|
-
// richResponse
|
|
988
|
-
await sock.sendMessage(jid, {
|
|
989
|
-
richResponse: [
|
|
990
|
-
{ text: 'Tutorial:' },
|
|
991
|
-
{ video: { url: 'https://example.com/tutorial.mp4', duration: 30 } }
|
|
885
|
+
build.richVideo('https://example.com/clip.mp4')
|
|
992
886
|
]
|
|
993
|
-
}
|
|
887
|
+
})
|
|
994
888
|
```
|
|
995
|
-
</details>
|
|
996
|
-
|
|
997
|
-
---
|
|
998
|
-
|
|
999
|
-
#### ๐ก Rich Suggestions
|
|
1000
889
|
|
|
1001
|
-
>
|
|
890
|
+
</details>
|
|
1002
891
|
|
|
1003
892
|
<details>
|
|
1004
|
-
<summary><b>
|
|
893
|
+
<summary><b>๐ก Rich Suggestions โ <code>richSuggestions</code> / <code>richSuggest</code></b></summary>
|
|
894
|
+
|
|
895
|
+
**Direct:**
|
|
1005
896
|
|
|
1006
897
|
```js
|
|
1007
898
|
await sock.sendMessage(jid, {
|
|
1008
899
|
richSuggestions: ['Coba lagi', 'Lihat detail', 'Batalkan']
|
|
1009
900
|
}, { quoted: message })
|
|
1010
901
|
```
|
|
1011
|
-
</details>
|
|
1012
902
|
|
|
1013
|
-
|
|
1014
|
-
<summary><b>Inside items / richResponse</b></summary>
|
|
903
|
+
**Builder:**
|
|
1015
904
|
|
|
1016
905
|
```js
|
|
1017
|
-
// items
|
|
1018
906
|
await sock.sendMessage(jid, {
|
|
1019
907
|
items: [
|
|
1020
|
-
|
|
1021
|
-
{ suggestions: ['Halaman utama', 'Bantuan', 'Hubungi admin'] }
|
|
1022
|
-
]
|
|
1023
|
-
}, { quoted: message })
|
|
1024
|
-
|
|
1025
|
-
// richResponse
|
|
1026
|
-
await sock.sendMessage(jid, {
|
|
1027
|
-
richResponse: [
|
|
1028
|
-
{ text: 'Hasil pencarian ditemukan.' },
|
|
1029
|
-
{ suggestions: ['Tampilkan semua', 'Filter ulang', 'Export'] }
|
|
908
|
+
build.richSuggest('Lihat detail')
|
|
1030
909
|
]
|
|
1031
|
-
}
|
|
910
|
+
})
|
|
1032
911
|
```
|
|
1033
|
-
</details>
|
|
1034
912
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
#### ๐ฃ Rich LaTeX
|
|
1038
|
-
|
|
1039
|
-
> Math formula rendering as `GenAILatexItem` inline entity. `url` points to a rendered formula image (PNG/JPG from external LaTeX renderer).
|
|
913
|
+
</details>
|
|
1040
914
|
|
|
1041
915
|
<details>
|
|
1042
|
-
<summary><b>
|
|
916
|
+
<summary><b>๐ฃ Rich LaTeX โ <code>richLatex</code></b></summary>
|
|
917
|
+
|
|
918
|
+
**Shorthand URL:**
|
|
1043
919
|
|
|
1044
920
|
```js
|
|
1045
921
|
await sock.sendMessage(jid, {
|
|
1046
922
|
richLatex: 'https://latex.codecogs.com/png.latex?E%3Dmc%5E2'
|
|
1047
923
|
}, { quoted: message })
|
|
1048
924
|
```
|
|
1049
|
-
</details>
|
|
1050
925
|
|
|
1051
|
-
|
|
1052
|
-
<summary><b>Full Options</b></summary>
|
|
926
|
+
**Full options:**
|
|
1053
927
|
|
|
1054
928
|
```js
|
|
1055
929
|
await sock.sendMessage(jid, {
|
|
1056
930
|
richLatex: {
|
|
1057
931
|
url: 'https://latex.codecogs.com/png.latex?E%3Dmc%5E2',
|
|
1058
|
-
text: 'E = mcยฒ',
|
|
1059
|
-
width: 120,
|
|
1060
|
-
height: 60,
|
|
1061
|
-
font_height: 83.33,
|
|
1062
|
-
padding: 15
|
|
932
|
+
text: 'E = mcยฒ',
|
|
933
|
+
width: 120,
|
|
934
|
+
height: 60,
|
|
935
|
+
font_height: 83.33,
|
|
936
|
+
padding: 15
|
|
1063
937
|
}
|
|
1064
938
|
}, { quoted: message })
|
|
1065
939
|
```
|
|
1066
|
-
</details>
|
|
1067
|
-
|
|
1068
|
-
<details>
|
|
1069
|
-
<summary><b>Inside items / richResponse</b></summary>
|
|
1070
|
-
|
|
1071
|
-
```js
|
|
1072
|
-
// items
|
|
1073
|
-
await sock.sendMessage(jid, {
|
|
1074
|
-
items: [
|
|
1075
|
-
{ text: 'Rumus energi kinetik:' },
|
|
1076
|
-
{
|
|
1077
|
-
latexUrl: 'https://latex.codecogs.com/png.latex?E_k%3D%5Cfrac%7B1%7D%7B2%7Dmv%5E2',
|
|
1078
|
-
latexText: 'Ek = ยฝmvยฒ',
|
|
1079
|
-
latexWidth: 150,
|
|
1080
|
-
latexHeight: 60
|
|
1081
|
-
}
|
|
1082
|
-
]
|
|
1083
|
-
}, { quoted: message })
|
|
1084
940
|
|
|
1085
|
-
// richResponse
|
|
1086
|
-
await sock.sendMessage(jid, {
|
|
1087
|
-
richResponse: [
|
|
1088
|
-
{ text: 'Solusi integral:' },
|
|
1089
|
-
{ latex: { url: 'https://latex.codecogs.com/png.latex?%5Cint%20x%5E2%20dx', text: 'โซxยฒ dx = xยณ/3 + C' } }
|
|
1090
|
-
]
|
|
1091
|
-
}, { quoted: message })
|
|
1092
|
-
```
|
|
1093
941
|
</details>
|
|
1094
942
|
|
|
1095
|
-
---
|
|
1096
|
-
|
|
1097
|
-
#### ๐๏ธ Rich Product
|
|
1098
|
-
|
|
1099
|
-
> Product card(s) as `GenAIProductItemCardPrimitive`. Object = single card, Array = horizontal scroll carousel.
|
|
1100
|
-
|
|
1101
943
|
<details>
|
|
1102
|
-
<summary><b
|
|
944
|
+
<summary><b>๐๏ธ Rich Product โ <code>richProduct</code> / <code>richProduct</code> builder</b></summary>
|
|
945
|
+
|
|
946
|
+
**Single product:**
|
|
1103
947
|
|
|
1104
948
|
```js
|
|
1105
949
|
await sock.sendMessage(jid, {
|
|
1106
950
|
richProduct: {
|
|
1107
951
|
title: 'Sepatu Adidas Samba',
|
|
1108
952
|
price_display_string: 'Rp 1.200.000',
|
|
1109
|
-
description: 'Sepatu casual ikonik
|
|
953
|
+
description: 'Sepatu casual ikonik.',
|
|
1110
954
|
retailer_id: 'adidas_store',
|
|
1111
|
-
thumbnail: {
|
|
955
|
+
thumbnail: {
|
|
956
|
+
url: 'https://example.com/adidas.jpg',
|
|
957
|
+
mime_type: 'image/jpeg',
|
|
958
|
+
width: 300,
|
|
959
|
+
height: 300
|
|
960
|
+
}
|
|
1112
961
|
}
|
|
1113
962
|
}, { quoted: message })
|
|
1114
963
|
```
|
|
1115
|
-
</details>
|
|
1116
964
|
|
|
1117
|
-
|
|
1118
|
-
<summary><b>Product Carousel</b></summary>
|
|
965
|
+
**Carousel:**
|
|
1119
966
|
|
|
1120
967
|
```js
|
|
1121
968
|
await sock.sendMessage(jid, {
|
|
1122
969
|
richProduct: [
|
|
1123
|
-
{
|
|
1124
|
-
|
|
1125
|
-
price_display_string: 'Rp 500.000',
|
|
1126
|
-
thumbnail: { url: 'https://example.com/a.jpg', mime_type: 'image/jpeg', width: 300, height: 300 }
|
|
1127
|
-
},
|
|
1128
|
-
{
|
|
1129
|
-
title: 'Sepatu B',
|
|
1130
|
-
price_display_string: 'Rp 750.000',
|
|
1131
|
-
thumbnail: { url: 'https://example.com/b.jpg', mime_type: 'image/jpeg', width: 300, height: 300 }
|
|
1132
|
-
}
|
|
970
|
+
{ title: 'Sepatu A', price_display_string: 'Rp 500.000' },
|
|
971
|
+
{ title: 'Sepatu B', price_display_string: 'Rp 750.000' }
|
|
1133
972
|
]
|
|
1134
973
|
}, { quoted: message })
|
|
1135
974
|
```
|
|
1136
|
-
</details>
|
|
1137
975
|
|
|
1138
|
-
|
|
1139
|
-
<summary><b>Inside items / richResponse</b></summary>
|
|
976
|
+
**Builder:**
|
|
1140
977
|
|
|
1141
978
|
```js
|
|
1142
|
-
// items
|
|
1143
979
|
await sock.sendMessage(jid, {
|
|
1144
980
|
items: [
|
|
1145
|
-
{
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
// richResponse
|
|
1151
|
-
await sock.sendMessage(jid, {
|
|
1152
|
-
richResponse: [
|
|
1153
|
-
{ text: 'Pilih produkmu:' },
|
|
1154
|
-
{ product: [{ title: 'A' }, { title: 'B' }] }
|
|
981
|
+
build.richProduct({
|
|
982
|
+
title: 'Produk A',
|
|
983
|
+
price_display_string: 'Rp 99.000'
|
|
984
|
+
})
|
|
1155
985
|
]
|
|
1156
|
-
}
|
|
986
|
+
})
|
|
1157
987
|
```
|
|
1158
|
-
</details>
|
|
1159
|
-
|
|
1160
|
-
---
|
|
1161
|
-
|
|
1162
|
-
#### ๐ฐ Rich Post
|
|
1163
988
|
|
|
1164
|
-
>
|
|
989
|
+
</details>
|
|
1165
990
|
|
|
1166
991
|
<details>
|
|
1167
|
-
<summary><b
|
|
992
|
+
<summary><b>๐ฐ Rich Post โ <code>richPost</code> / <code>richPost</code> builder</b></summary>
|
|
1168
993
|
|
|
1169
994
|
```js
|
|
1170
995
|
await sock.sendMessage(jid, {
|
|
@@ -1177,29 +1002,25 @@ await sock.sendMessage(jid, {
|
|
|
1177
1002
|
}
|
|
1178
1003
|
}, { quoted: message })
|
|
1179
1004
|
```
|
|
1180
|
-
</details>
|
|
1181
1005
|
|
|
1182
|
-
|
|
1183
|
-
<summary><b>Post Carousel</b></summary>
|
|
1006
|
+
**Builder:**
|
|
1184
1007
|
|
|
1185
1008
|
```js
|
|
1186
1009
|
await sock.sendMessage(jid, {
|
|
1187
|
-
|
|
1188
|
-
{
|
|
1189
|
-
|
|
1010
|
+
items: [
|
|
1011
|
+
build.richPost({
|
|
1012
|
+
title: 'Post PontaLabs',
|
|
1013
|
+
author_display_name: '@pontalabs',
|
|
1014
|
+
media_url: 'https://example.com/post.jpg'
|
|
1015
|
+
})
|
|
1190
1016
|
]
|
|
1191
|
-
}
|
|
1017
|
+
})
|
|
1192
1018
|
```
|
|
1193
|
-
</details>
|
|
1194
|
-
|
|
1195
|
-
---
|
|
1196
1019
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
> Reels carousel as `GenAIReelPrimitive` with `contentItemsMetadata`. Auto-injects `richResponseSourcesMetadata` with `provider: 'PontaCT'`.
|
|
1020
|
+
</details>
|
|
1200
1021
|
|
|
1201
1022
|
<details>
|
|
1202
|
-
<summary><b>
|
|
1023
|
+
<summary><b>๐ฌ Rich Reels โ <code>richReels</code> / <code>richReels</code> builder</b></summary>
|
|
1203
1024
|
|
|
1204
1025
|
```js
|
|
1205
1026
|
await sock.sendMessage(jid, {
|
|
@@ -1217,352 +1038,405 @@ await sock.sendMessage(jid, {
|
|
|
1217
1038
|
}
|
|
1218
1039
|
}, { quoted: message })
|
|
1219
1040
|
```
|
|
1220
|
-
</details>
|
|
1221
1041
|
|
|
1222
|
-
|
|
1223
|
-
<summary><b>Reels Carousel</b></summary>
|
|
1042
|
+
**Builder:**
|
|
1224
1043
|
|
|
1225
1044
|
```js
|
|
1226
1045
|
await sock.sendMessage(jid, {
|
|
1227
|
-
|
|
1228
|
-
{
|
|
1229
|
-
title: '@
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
likes_count: 5000,
|
|
1234
|
-
reel_source: 'IG'
|
|
1235
|
-
},
|
|
1236
|
-
{
|
|
1237
|
-
title: '@creator2',
|
|
1238
|
-
profileIconUrl: 'https://example.com/av2.jpg',
|
|
1239
|
-
thumbnailUrl: 'https://example.com/th2.jpg',
|
|
1240
|
-
videoUrl: 'https://example.com/r2.mp4',
|
|
1241
|
-
likes_count: 8200,
|
|
1242
|
-
reel_source: 'TT'
|
|
1243
|
-
}
|
|
1046
|
+
items: [
|
|
1047
|
+
build.richReels([{
|
|
1048
|
+
title: '@creator',
|
|
1049
|
+
thumbnailUrl: 'https://example.com/thumb.jpg',
|
|
1050
|
+
videoUrl: 'https://example.com/reel.mp4'
|
|
1051
|
+
}])
|
|
1244
1052
|
]
|
|
1245
|
-
}
|
|
1053
|
+
})
|
|
1246
1054
|
```
|
|
1247
|
-
</details>
|
|
1248
|
-
|
|
1249
|
-
<details>
|
|
1250
|
-
<summary><b>๐ Fields Reference</b></summary>
|
|
1251
|
-
|
|
1252
|
-
| Field | Type | Default | Description |
|
|
1253
|
-
|:---|:---|:---:|:---|
|
|
1254
|
-
| `title` | `string` | โ | Username / creator name |
|
|
1255
|
-
| `profileIconUrl` | `string` | โ | Avatar URL |
|
|
1256
|
-
| `thumbnailUrl` | `string` | โ | Thumbnail cover URL |
|
|
1257
|
-
| `videoUrl` | `string` | โ | Video source URL |
|
|
1258
|
-
| `reels_title` | `string` | `''` | Reel title |
|
|
1259
|
-
| `likes_count` | `number` | `0` | Like count |
|
|
1260
|
-
| `shares_count` | `number` | `0` | Share count |
|
|
1261
|
-
| `view_count` | `number` | `0` | View count |
|
|
1262
|
-
| `reel_source` | `string` | `'IG'` | Source platform |
|
|
1263
|
-
| `is_verified` | `boolean` | `false` | Verified badge |
|
|
1264
1055
|
|
|
1265
1056
|
</details>
|
|
1266
1057
|
|
|
1267
|
-
---
|
|
1268
|
-
|
|
1269
|
-
#### ๐ Rich Sources
|
|
1270
|
-
|
|
1271
|
-
> Search result source list as `GenAISearchResultPrimitive`. Accepts full objects **or** shorthand `[faviconUrl, sourceUrl, displayName]`.
|
|
1272
|
-
|
|
1273
1058
|
<details>
|
|
1274
|
-
<summary><b>
|
|
1059
|
+
<summary><b>๐ Rich Sources โ <code>richSources</code> / <code>richSource</code></b></summary>
|
|
1060
|
+
|
|
1061
|
+
**Shorthand:**
|
|
1275
1062
|
|
|
1276
1063
|
```js
|
|
1277
1064
|
await sock.sendMessage(jid, {
|
|
1278
1065
|
richSources: [
|
|
1279
1066
|
['https://wikipedia.org/favicon.ico', 'https://wikipedia.org/wiki/Node.js', 'Wikipedia'],
|
|
1280
|
-
['https://nodejs.org/favicon.ico', 'https://nodejs.org/en/docs', 'Node.js Docs']
|
|
1281
|
-
['https://github.com/favicon.ico', 'https://github.com/nodejs/node', 'GitHub']
|
|
1067
|
+
['https://nodejs.org/favicon.ico', 'https://nodejs.org/en/docs', 'Node.js Docs']
|
|
1282
1068
|
]
|
|
1283
1069
|
}, { quoted: message })
|
|
1284
1070
|
```
|
|
1285
|
-
</details>
|
|
1286
1071
|
|
|
1287
|
-
|
|
1288
|
-
<summary><b>Full Object</b></summary>
|
|
1072
|
+
**Full object:**
|
|
1289
1073
|
|
|
1290
1074
|
```js
|
|
1291
1075
|
await sock.sendMessage(jid, {
|
|
1292
|
-
richSources: [
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1076
|
+
richSources: [{
|
|
1077
|
+
source_type: 'THIRD_PARTY',
|
|
1078
|
+
source_display_name: 'Wikipedia',
|
|
1079
|
+
source_subtitle: 'wikipedia.org',
|
|
1080
|
+
source_url: 'https://wikipedia.org/wiki/Node.js',
|
|
1081
|
+
favicon: {
|
|
1082
|
+
url: 'https://wikipedia.org/favicon.ico',
|
|
1083
|
+
mime_type: 'image/jpeg',
|
|
1084
|
+
width: 16,
|
|
1085
|
+
height: 16
|
|
1299
1086
|
}
|
|
1300
|
-
]
|
|
1087
|
+
}]
|
|
1301
1088
|
}, { quoted: message })
|
|
1302
1089
|
```
|
|
1090
|
+
|
|
1091
|
+
**Builder:**
|
|
1092
|
+
|
|
1093
|
+
```js
|
|
1094
|
+
await sock.sendMessage(jid, {
|
|
1095
|
+
items: [
|
|
1096
|
+
build.richSource([
|
|
1097
|
+
['https://example.com/favicon.ico', 'https://example.com', 'Example']
|
|
1098
|
+
])
|
|
1099
|
+
]
|
|
1100
|
+
})
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1303
1103
|
</details>
|
|
1304
1104
|
|
|
1305
1105
|
<details>
|
|
1306
|
-
<summary><b>
|
|
1106
|
+
<summary><b>๐ Rich Tip, Footer & Metadata โ <code>richTip</code> / <code>richFooter</code> / <code>richMetadata</code></b></summary>
|
|
1307
1107
|
|
|
1308
1108
|
```js
|
|
1309
1109
|
await sock.sendMessage(jid, {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1110
|
+
richTip: 'Dihasilkan oleh AI ยท PontaLabs'
|
|
1111
|
+
}, { quoted: message })
|
|
1112
|
+
|
|
1113
|
+
await sock.sendMessage(jid, {
|
|
1114
|
+
richFooter: 'ยฉ PontaLabs ยท Data bersumber dari layanan publik'
|
|
1314
1115
|
}, { quoted: message })
|
|
1315
1116
|
```
|
|
1316
|
-
</details>
|
|
1317
1117
|
|
|
1318
|
-
|
|
1118
|
+
**Builder:**
|
|
1319
1119
|
|
|
1320
|
-
|
|
1120
|
+
```js
|
|
1121
|
+
await sock.sendMessage(jid, {
|
|
1122
|
+
items: [
|
|
1123
|
+
build.richTip('AI-generated content'),
|
|
1124
|
+
build.richMetadata('PontaLabs Rich Message'),
|
|
1125
|
+
build.richFooter('ยฉ PontaLabs')
|
|
1126
|
+
]
|
|
1127
|
+
})
|
|
1128
|
+
```
|
|
1321
1129
|
|
|
1322
|
-
>
|
|
1323
|
-
> `richFooter` โ metadata text below message (disclaimer / branding).
|
|
1130
|
+
</details>
|
|
1324
1131
|
|
|
1325
1132
|
<details>
|
|
1326
|
-
<summary><b
|
|
1133
|
+
<summary><b>๐งฉ Rich FOA Text โ <code>richFOAText</code></b></summary>
|
|
1327
1134
|
|
|
1328
1135
|
```js
|
|
1329
1136
|
await sock.sendMessage(jid, {
|
|
1330
|
-
|
|
1331
|
-
|
|
1137
|
+
items: [
|
|
1138
|
+
build.richFOAText('Halo dari FOA Rich Text')
|
|
1139
|
+
]
|
|
1140
|
+
})
|
|
1332
1141
|
```
|
|
1142
|
+
|
|
1333
1143
|
</details>
|
|
1334
1144
|
|
|
1335
1145
|
<details>
|
|
1336
|
-
<summary><b
|
|
1146
|
+
<summary><b>๐งฑ Rich Widget โ <code>richWidget</code></b></summary>
|
|
1337
1147
|
|
|
1338
1148
|
```js
|
|
1339
1149
|
await sock.sendMessage(jid, {
|
|
1340
|
-
|
|
1341
|
-
|
|
1150
|
+
items: [
|
|
1151
|
+
build.richWidget({
|
|
1152
|
+
/* widget payload */
|
|
1153
|
+
})
|
|
1154
|
+
]
|
|
1155
|
+
})
|
|
1342
1156
|
```
|
|
1157
|
+
|
|
1343
1158
|
</details>
|
|
1344
1159
|
|
|
1345
1160
|
<details>
|
|
1346
|
-
<summary><b
|
|
1161
|
+
<summary><b>๐ Mixed Rich โ <code>items</code></b></summary>
|
|
1162
|
+
|
|
1163
|
+
Semua Rich item dapat dicampur dalam satu `items`. Urutan array menjadi urutan tampilan.
|
|
1347
1164
|
|
|
1348
1165
|
```js
|
|
1349
|
-
// items
|
|
1350
1166
|
await sock.sendMessage(jid, {
|
|
1351
1167
|
items: [
|
|
1352
|
-
{ text: '
|
|
1353
|
-
{
|
|
1354
|
-
|
|
1355
|
-
|
|
1168
|
+
{ text: '*Laporan Harian Bot*' },
|
|
1169
|
+
{ table: {
|
|
1170
|
+
headers: ['Metric', 'Value'],
|
|
1171
|
+
rows: [
|
|
1172
|
+
['Uptime', '99.9%'],
|
|
1173
|
+
['Messages', '1.2K']
|
|
1174
|
+
]
|
|
1175
|
+
}},
|
|
1176
|
+
build.richCode('SELECT COUNT(*) FROM messages;', 'sql'),
|
|
1177
|
+
build.richHtml('<h2>Dashboard</h2>'),
|
|
1178
|
+
build.richSuggest('Refresh'),
|
|
1179
|
+
build.richFooter('Auto-generated ยท PontaLabs')
|
|
1356
1180
|
]
|
|
1357
1181
|
}, { quoted: message })
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
**Item shorthand yang tersedia:**
|
|
1185
|
+
|
|
1186
|
+
<details>
|
|
1187
|
+
<summary><b>๐ Lihat semua key <code>items</code></b></summary>
|
|
1188
|
+
|
|
1189
|
+
- `{ text, inlineEntities? }` โ Rich text
|
|
1190
|
+
- `{ code, language }` โ Code block
|
|
1191
|
+
- `{ table }` โ Table
|
|
1192
|
+
- `{ images }` โ Image grid
|
|
1193
|
+
- `{ videoUrl, mimeType?, duration? }` โ Video
|
|
1194
|
+
- `{ suggestions }` โ Suggestion pills
|
|
1195
|
+
- `{ latexUrl, latexText?, latexWidth?, latexHeight? }` โ LaTeX
|
|
1196
|
+
- `{ product }` โ Product card
|
|
1197
|
+
- `{ post }` โ Post card
|
|
1198
|
+
- `{ reels }` โ Reels
|
|
1199
|
+
- `{ sources }` โ Sources
|
|
1200
|
+
- `{ tip }` โ Tip
|
|
1201
|
+
- `{ footer }` โ Footer
|
|
1202
|
+
|
|
1203
|
+
</details>
|
|
1358
1204
|
|
|
1359
|
-
|
|
1205
|
+
</details>
|
|
1206
|
+
|
|
1207
|
+
<details>
|
|
1208
|
+
<summary><b>๐ Rich Response โ <code>richResponse</code></b></summary>
|
|
1209
|
+
|
|
1210
|
+
`richResponse` adalah full array mode untuk menyusun Rich primitive secara manual, termasuk inline citation melalui `inlineEntities`.
|
|
1211
|
+
|
|
1212
|
+
**Basic:**
|
|
1213
|
+
|
|
1214
|
+
```js
|
|
1360
1215
|
await sock.sendMessage(jid, {
|
|
1361
1216
|
richResponse: [
|
|
1362
|
-
{ text: '
|
|
1363
|
-
{
|
|
1217
|
+
{ text: '*Hasil:* Node.js adalah runtime JavaScript.' },
|
|
1218
|
+
{ code: 'node --version', language: 'bash' },
|
|
1219
|
+
{ suggestions: ['Lihat docs', 'Install'] },
|
|
1220
|
+
{ footer: 'PontaLabs' }
|
|
1364
1221
|
]
|
|
1365
1222
|
}, { quoted: message })
|
|
1366
1223
|
```
|
|
1367
|
-
</details>
|
|
1368
1224
|
|
|
1369
|
-
|
|
1225
|
+
**Inline citation:**
|
|
1370
1226
|
|
|
1371
|
-
|
|
1227
|
+
```js
|
|
1228
|
+
await sock.sendMessage(jid, {
|
|
1229
|
+
richResponse: [{
|
|
1230
|
+
text: 'Node.js {{SS_0}}ยน{{/SS_0}} adalah runtime JavaScript.',
|
|
1231
|
+
inlineEntities: [{
|
|
1232
|
+
key: 'SS_0',
|
|
1233
|
+
metadata: {
|
|
1234
|
+
reference_id: 1,
|
|
1235
|
+
reference_url: 'https://nodejs.org',
|
|
1236
|
+
reference_title: 'Node.js Official',
|
|
1237
|
+
reference_display_name: 'nodejs.org',
|
|
1238
|
+
sources: [{
|
|
1239
|
+
source_type: 'THIRD_PARTY',
|
|
1240
|
+
source_display_name: 'nodejs.org',
|
|
1241
|
+
source_subtitle: 'nodejs.org',
|
|
1242
|
+
source_url: 'https://nodejs.org'
|
|
1243
|
+
}],
|
|
1244
|
+
__typename: 'GenAISearchCitationItem'
|
|
1245
|
+
}
|
|
1246
|
+
}]
|
|
1247
|
+
}]
|
|
1248
|
+
}, { quoted: message })
|
|
1249
|
+
```
|
|
1372
1250
|
|
|
1373
|
-
|
|
1251
|
+
**Table di `richResponse`:**
|
|
1374
1252
|
|
|
1375
|
-
|
|
1253
|
+
```js
|
|
1254
|
+
await sock.sendMessage(jid, {
|
|
1255
|
+
richResponse: [{
|
|
1256
|
+
table: [
|
|
1257
|
+
{ items: ['Version', 'LTS', 'Release'], isHeading: true },
|
|
1258
|
+
{ items: ['22.x', 'Yes', '2024'], isHeading: false }
|
|
1259
|
+
]
|
|
1260
|
+
}]
|
|
1261
|
+
})
|
|
1262
|
+
```
|
|
1376
1263
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
| `{ code, language }` | Code block |
|
|
1381
|
-
| `{ table }` | Table |
|
|
1382
|
-
| `{ images }` | Image grid |
|
|
1383
|
-
| `{ videoUrl, mimeType?, duration? }` | Video embed |
|
|
1384
|
-
| `{ suggestions }` | Suggestion pills |
|
|
1385
|
-
| `{ latexUrl, latexText?, latexWidth?, latexHeight? }` | LaTeX formula |
|
|
1386
|
-
| `{ product }` | Product card(s) |
|
|
1387
|
-
| `{ post }` | Post card(s) |
|
|
1388
|
-
| `{ reels }` | Reels carousel |
|
|
1389
|
-
| `{ sources }` | Search sources |
|
|
1390
|
-
| `{ tip }` | Tip metadata |
|
|
1391
|
-
| `{ footer }` | Footer metadata |
|
|
1264
|
+
> Berbeda dari `table` top-level / `items`, format table di `richResponse` harus berupa array row siap-pakai.
|
|
1265
|
+
|
|
1266
|
+
</details>
|
|
1392
1267
|
|
|
1393
1268
|
<details>
|
|
1394
|
-
<summary><b
|
|
1269
|
+
<summary><b>๐๏ธ Interactive Rich Builder โ Button, ButtonV2 & Carousel</b></summary>
|
|
1270
|
+
|
|
1271
|
+
Builder interactive juga berada di namespace `build` dan dikirim melalui `sock.sendMessage()`.
|
|
1272
|
+
|
|
1273
|
+
**Native Flow Button:**
|
|
1395
1274
|
|
|
1396
1275
|
```js
|
|
1276
|
+
const button = build.button()
|
|
1277
|
+
.setTitle('Menu')
|
|
1278
|
+
.setBody('Pilih salah satu')
|
|
1279
|
+
.setFooter('PontaLabs')
|
|
1280
|
+
.addReply('Halo', 'hello')
|
|
1281
|
+
.addUrl('Website', 'https://example.com')
|
|
1282
|
+
.addCopy('Copy ID', 'ABC123')
|
|
1283
|
+
|
|
1397
1284
|
await sock.sendMessage(jid, {
|
|
1398
|
-
items: [
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
]
|
|
1413
|
-
}
|
|
1285
|
+
items: [button]
|
|
1286
|
+
})
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
**ButtonV2:**
|
|
1290
|
+
|
|
1291
|
+
```js
|
|
1292
|
+
const buttons = build.buttonV2()
|
|
1293
|
+
.setBody('Pilih aksi')
|
|
1294
|
+
.setFooter('PontaLabs')
|
|
1295
|
+
.addButton('Yes')
|
|
1296
|
+
.addButton('No')
|
|
1297
|
+
|
|
1298
|
+
await sock.sendMessage(jid, {
|
|
1299
|
+
items: [buttons]
|
|
1300
|
+
})
|
|
1301
|
+
```
|
|
1302
|
+
|
|
1303
|
+
**Carousel:**
|
|
1304
|
+
|
|
1305
|
+
```js
|
|
1306
|
+
const carousel = build.carousel()
|
|
1307
|
+
.setBody('Pilih produk')
|
|
1308
|
+
.setFooter('PontaLabs')
|
|
1309
|
+
.addCard(card)
|
|
1310
|
+
|
|
1311
|
+
await sock.sendMessage(jid, {
|
|
1312
|
+
items: [carousel]
|
|
1313
|
+
})
|
|
1414
1314
|
```
|
|
1315
|
+
|
|
1316
|
+
> `build.button()`, `build.buttonV2()`, dan `build.carousel()` tidak membutuhkan `sock` saat dibuat. Builder hanya menghasilkan payload.
|
|
1317
|
+
|
|
1415
1318
|
</details>
|
|
1416
1319
|
|
|
1417
1320
|
<details>
|
|
1418
|
-
<summary><b
|
|
1321
|
+
<summary><b>โฑ๏ธ Rich Build Delay โ <code>buildDelay</code></b></summary>
|
|
1322
|
+
|
|
1323
|
+
`buildDelay` digunakan bersama `items` untuk melakukan progressive update pada target message yang sama.
|
|
1419
1324
|
|
|
1420
1325
|
```js
|
|
1421
1326
|
await sock.sendMessage(jid, {
|
|
1422
1327
|
items: [
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
}
|
|
1328
|
+
build.richText('โณ Memproses...'),
|
|
1329
|
+
build.richText('๐ Mencari data...'),
|
|
1330
|
+
build.richText('โ
Selesai!')
|
|
1331
|
+
],
|
|
1332
|
+
buildDelay: 1000
|
|
1333
|
+
})
|
|
1429
1334
|
```
|
|
1430
|
-
</details>
|
|
1431
1335
|
|
|
1432
|
-
|
|
1433
|
-
|
|
1336
|
+
Dengan `buildDelay: 1000`, item berikutnya diproses setiap 1 detik dan update tetap menggunakan message ID target yang sama.
|
|
1337
|
+
|
|
1338
|
+
**Custom message ID:**
|
|
1434
1339
|
|
|
1435
1340
|
```js
|
|
1436
1341
|
await sock.sendMessage(jid, {
|
|
1342
|
+
messageId: 'MY_MESSAGE_ID',
|
|
1437
1343
|
items: [
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
latexUrl: 'https://latex.codecogs.com/png.latex?U%3D%5Cfrac%7Bt_u%7D%7Bt_t%7D%5Ctimes100',
|
|
1444
|
-
latexText: 'U = (tu/tt) ร 100'
|
|
1445
|
-
},
|
|
1446
|
-
{ sources: [['https://example.com/fav.ico', 'https://example.com', 'Dashboard']] },
|
|
1447
|
-
{ suggestions: ['Refresh', 'Export PDF'] },
|
|
1448
|
-
{ footer: 'Auto-generated ยท PontaCT' }
|
|
1449
|
-
]
|
|
1450
|
-
}, { quoted: message })
|
|
1344
|
+
build.richText('Build 1'),
|
|
1345
|
+
build.richText('Build 2')
|
|
1346
|
+
],
|
|
1347
|
+
buildDelay: 1000
|
|
1348
|
+
})
|
|
1451
1349
|
```
|
|
1350
|
+
|
|
1351
|
+
> `buildDelay` hanya berlaku untuk `items` dan nilainya harus lebih besar dari `0`.
|
|
1352
|
+
|
|
1452
1353
|
</details>
|
|
1453
1354
|
|
|
1454
|
-
|
|
1355
|
+
<details>
|
|
1356
|
+
<summary><b>๐ ๏ธ Advanced Rich Builder โ <code>build.AIRich(sock)</code></b></summary>
|
|
1455
1357
|
|
|
1456
|
-
|
|
1358
|
+
Untuk state, node ID, replace, insert, delete, dan edit message gunakan `build.AIRich(sock)`.
|
|
1457
1359
|
|
|
1458
|
-
|
|
1360
|
+
```js
|
|
1361
|
+
const ai = build.AIRich(sock)
|
|
1459
1362
|
|
|
1460
|
-
|
|
1363
|
+
ai.addText('โณ Loading...', { id: 'status' })
|
|
1364
|
+
ai.addTip('Mohon tunggu')
|
|
1461
1365
|
|
|
1462
|
-
|
|
1463
|
-
|:---|:---|
|
|
1464
|
-
| `{ text, inlineEntities? }` | Text + optional citation/hyperlink |
|
|
1465
|
-
| `{ code, language }` | Code block |
|
|
1466
|
-
| `{ table, title? }` | Table โ โ ๏ธ format beda dari `items`/top-level: `table` di sini harus array baris siap-pakai `[{ items: [...], isHeading }]`, **bukan** `{ headers, rows }` |
|
|
1467
|
-
| `{ images }` | Image grid |
|
|
1468
|
-
| `{ video }` | Video embed |
|
|
1469
|
-
| `{ suggestions }` | Suggestion pills |
|
|
1470
|
-
| `{ latex }` | LaTeX formula |
|
|
1471
|
-
| `{ product }` | Product card(s) |
|
|
1472
|
-
| `{ post }` | Post card(s) |
|
|
1473
|
-
| `{ reels }` | Reels carousel |
|
|
1474
|
-
| `{ sources }` | Search sources |
|
|
1475
|
-
| `{ tip }` | Tip metadata |
|
|
1476
|
-
| `{ footer }` | Footer metadata |
|
|
1366
|
+
await ai.send(jid)
|
|
1477
1367
|
|
|
1478
|
-
|
|
1479
|
-
|
|
1368
|
+
ai.addText('โ
Selesai!', { replace: 'status' })
|
|
1369
|
+
ai.delete('status')
|
|
1370
|
+
ai.addTip('Tambahan', { insertAt: 'status' })
|
|
1371
|
+
```
|
|
1372
|
+
|
|
1373
|
+
**Contoh edit:**
|
|
1480
1374
|
|
|
1481
1375
|
```js
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
reference_display_name: 'nodejs.org',
|
|
1494
|
-
sources: [{
|
|
1495
|
-
source_type: 'THIRD_PARTY',
|
|
1496
|
-
source_display_name: 'nodejs.org',
|
|
1497
|
-
source_subtitle: 'nodejs.org',
|
|
1498
|
-
source_url: 'https://nodejs.org'
|
|
1499
|
-
}],
|
|
1500
|
-
__typename: 'GenAISearchCitationItem'
|
|
1501
|
-
}
|
|
1502
|
-
},
|
|
1503
|
-
{
|
|
1504
|
-
key: 'SS_1',
|
|
1505
|
-
metadata: {
|
|
1506
|
-
reference_id: 2,
|
|
1507
|
-
reference_url: 'https://wikipedia.org/wiki/Ryan_Dahl',
|
|
1508
|
-
reference_title: 'Ryan Dahl - Wikipedia',
|
|
1509
|
-
reference_display_name: 'Wikipedia',
|
|
1510
|
-
sources: [{
|
|
1511
|
-
source_type: 'THIRD_PARTY',
|
|
1512
|
-
source_display_name: 'Wikipedia',
|
|
1513
|
-
source_subtitle: 'wikipedia.org',
|
|
1514
|
-
source_url: 'https://wikipedia.org/wiki/Ryan_Dahl'
|
|
1515
|
-
}],
|
|
1516
|
-
__typename: 'GenAISearchCitationItem'
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
]
|
|
1520
|
-
}
|
|
1521
|
-
]
|
|
1522
|
-
}, { quoted: message })
|
|
1376
|
+
const ai = build.AIRich(sock)
|
|
1377
|
+
|
|
1378
|
+
ai.addText('โณ Memproses...', { id: 'answer' })
|
|
1379
|
+
await ai.send(jid)
|
|
1380
|
+
|
|
1381
|
+
const result = await getAIResponse()
|
|
1382
|
+
|
|
1383
|
+
ai.addText(result, { replace: 'answer' })
|
|
1384
|
+
ai.addTip('Generated by AI')
|
|
1385
|
+
|
|
1386
|
+
await ai.sendEdit(jid)
|
|
1523
1387
|
```
|
|
1388
|
+
|
|
1389
|
+
> `replace` dan `insertAt` adalah options pada `add*()`, bukan method `ai.replace()` atau `ai.insertAt()`.
|
|
1390
|
+
|
|
1524
1391
|
</details>
|
|
1525
1392
|
|
|
1526
1393
|
<details>
|
|
1527
|
-
<summary><b
|
|
1394
|
+
<summary><b>โ๏ธ Rich Options โ <code>aiForwarded</code></b></summary>
|
|
1395
|
+
|
|
1396
|
+
`aiForwarded` menambahkan label forwarded-from-AI-bot pada `contextInfo`.
|
|
1528
1397
|
|
|
1529
1398
|
```js
|
|
1530
1399
|
await sock.sendMessage(jid, {
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
{ images: ['https://example.com/nodejs.png'] },
|
|
1534
|
-
{ text: 'Cara install:' },
|
|
1535
|
-
{ code: 'npm install node', language: 'bash' },
|
|
1536
|
-
{
|
|
1537
|
-
table: [
|
|
1538
|
-
{ items: ['Version', 'LTS', 'Release'], isHeading: true },
|
|
1539
|
-
{ items: ['22.x', 'Yes', '2024'], isHeading: false },
|
|
1540
|
-
{ items: ['21.x', 'No', '2023'], isHeading: false }
|
|
1541
|
-
]
|
|
1542
|
-
},
|
|
1543
|
-
{ sources: [['https://nodejs.org/fav.ico', 'https://nodejs.org', 'Node.js']] },
|
|
1544
|
-
{ suggestions: ['Lihat changelog', 'Download', 'Docs'] },
|
|
1545
|
-
{ footer: 'PontaCT ยท pontalabs' }
|
|
1546
|
-
]
|
|
1400
|
+
richText: 'Pesan dengan label AI bot',
|
|
1401
|
+
aiForwarded: true
|
|
1547
1402
|
}, { quoted: message })
|
|
1548
1403
|
```
|
|
1549
|
-
</details>
|
|
1550
1404
|
|
|
1551
|
-
|
|
1405
|
+
Bisa digunakan bersama `richText`, `items`, `richResponse`, `richHtml`, dan key Rich lainnya.
|
|
1552
1406
|
|
|
1553
|
-
|
|
1407
|
+
</details>
|
|
1554
1408
|
|
|
1555
1409
|
<details>
|
|
1556
|
-
<summary><b
|
|
1410
|
+
<summary><b>๐ Legacy Compatibility</b></summary>
|
|
1557
1411
|
|
|
1558
|
-
|
|
1412
|
+
API Rich lama tetap kompatibel:
|
|
1559
1413
|
|
|
1560
1414
|
```js
|
|
1561
1415
|
await sock.sendMessage(jid, {
|
|
1562
|
-
richText: '
|
|
1563
|
-
|
|
1564
|
-
|
|
1416
|
+
richText: 'Halo'
|
|
1417
|
+
})
|
|
1418
|
+
|
|
1419
|
+
await sock.sendMessage(jid, {
|
|
1420
|
+
items: [
|
|
1421
|
+
{ richText: 'Halo' },
|
|
1422
|
+
{ richTip: 'Testing' }
|
|
1423
|
+
]
|
|
1424
|
+
})
|
|
1565
1425
|
```
|
|
1426
|
+
|
|
1427
|
+
Kamu juga dapat mencampur object Rich lama dengan `build.*`:
|
|
1428
|
+
|
|
1429
|
+
```js
|
|
1430
|
+
await sock.sendMessage(jid, {
|
|
1431
|
+
items: [
|
|
1432
|
+
{ richText: 'Shortcut lama' },
|
|
1433
|
+
build.richText('Builder baru'),
|
|
1434
|
+
{ richTip: 'Shortcut lama' },
|
|
1435
|
+
build.richTip('Builder baru')
|
|
1436
|
+
]
|
|
1437
|
+
})
|
|
1438
|
+
```
|
|
1439
|
+
|
|
1566
1440
|
</details>
|
|
1567
1441
|
|
|
1568
1442
|
---
|