Pesan interaktif
POST /messages/interactiveContent-Type: multipart/form-dataBody dikirim sebagai multipart/form-data dengan dua field:
payload— string JSON berisi pesan (wajib).file— media header (opsional, hanya untukquick-replydantemplateyang memakaiheaderMedia).
Field payload
Section titled “Field payload”| Field | Tipe | Untuk | Keterangan |
|---|---|---|---|
deviceId |
string | semua | ID akun pengirim. |
phoneNumber |
string | semua | Nomor tujuan. |
kind |
string | semua | url-button, quick-reply, list, copy-code, atau template. |
body |
string | semua | Teks utama. Maks 1.024 karakter (4.096 untuk list). |
header |
string | semua | Judul di atas body, maks 60 karakter. |
footer |
string | semua | Teks kecil di bawah, maks 60 karakter. |
buttonLabel |
string | url-button, list, copy-code |
Label tombol, maks 20 karakter. |
url |
string | url-button |
Wajib https://. |
copyCode |
string | copy-code |
Teks yang disalin, maks 15 karakter. |
buttons |
array | quick-reply |
1–3 tombol { id, label }; label maks 20 karakter. |
sections |
array | list |
1–10 bagian { title, rows: [{ id, title, description? }] }; total maks 10 baris. |
templateButtons |
array | template |
1–10 tombol { type, label, value }. Lihat aturan di bawah. |
headerMedia |
string | quick-reply, template |
image, video, atau document. Wajib disertai file. |
replyToId |
string | semua | ID pesan yang dibalas. |
Contoh
Section titled “Contoh”curl -X POST "$NUSAWAP_URL/messages/interactive" \ -H "X-API-Key: $NUSAWAP_KEY" \ -F 'payload={ "deviceId": "<id akun>", "phoneNumber": "6281234567890", "kind": "quick-reply", "body": "Pesanan #2381 siap dikirim. Konfirmasi alamat?", "buttons": [ { "id": "alamat_ok", "label": "Alamat benar" }, { "id": "alamat_ubah", "label": "Ubah alamat" } ] }'curl -X POST "$NUSAWAP_URL/messages/interactive" \ -H "X-API-Key: $NUSAWAP_KEY" \ -F 'payload={ "deviceId": "<id akun>", "phoneNumber": "6281234567890", "kind": "list", "body": "Pilih cabang terdekat:", "buttonLabel": "Lihat cabang", "sections": [{ "title": "Bandung", "rows": [ { "id": "bdg_dago", "title": "Dago", "description": "Buka 09.00–21.00" }, { "id": "bdg_btc", "title": "Buah Batu" } ] }] }'curl -X POST "$NUSAWAP_URL/messages/interactive" \ -H "X-API-Key: $NUSAWAP_KEY" \ -F 'payload={ "deviceId": "<id akun>", "phoneNumber": "6281234567890", "kind": "url-button", "body": "Lacak paket Anda di sini.", "buttonLabel": "Lacak paket", "url": "https://contoh.id/lacak/2381" }'curl -X POST "$NUSAWAP_URL/messages/interactive" \ -H "X-API-Key: $NUSAWAP_KEY" \ -F 'payload={ "deviceId": "<id akun>", "phoneNumber": "6281234567890", "kind": "copy-code", "body": "Kode promo Oktober untuk Anda:", "buttonLabel": "Salin kode", "copyCode": "OKT25" }'Aturan templateButtons
Section titled “Aturan templateButtons”Setiap tombol berbentuk { "type": "url" | "copy" | "phone" | "reply", "label": "...", "value": "..." }. Label maks 25 karakter.
type |
value berisi |
|---|---|
url |
URL tujuan |
copy |
Kode yang disalin (maks 15 karakter) |
phone |
Nomor telepon |
reply |
ID tombol |
- Maksimal 10 tombol: paling banyak 2
url, 1phone, dan 1copy. - Tombol
replyharus berurutan dalam satu kelompok, tidak boleh diselingi tombol lain.