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