Pesan Interaktif
Pesan interaktif menggunakan type: "interactive" dan mendukung beberapa jenis action. Pesan ini hanya bisa dikirim di dalam window 24 jam (penerima sudah pernah mengirim pesan ke nomor Anda).
Tipe Interactive
Section titled “Tipe Interactive”Tipe action | Keterangan | Maks Item |
|---|---|---|
button | Tombol quick reply (hingga 3 tombol) | 3 tombol |
list | Menu daftar pilihan | 10 section, 10 row per section |
cta_url | Tombol yang mengarahkan ke URL | 1 tombol |
flow | Tombol yang membuka WhatsApp Flow | 1 tombol |
send_location | Meminta penerima mengirim lokasi | - |
1. Tombol Quick Reply (button)
Section titled “1. Tombol Quick Reply (button)”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "interactive", "interactive": { "type": "button", "body": { "text": "Apakah Anda ingin melanjutkan?" }, "action": { "buttons": [ { "type": "reply", "reply": { "id": "btn_yes", "title": "Ya" } }, { "type": "reply", "reply": { "id": "btn_no", "title": "Tidak" } } ] } }}Field interactive
Section titled “Field interactive”| Field | Tipe | Wajib | Keterangan |
|---|---|---|---|
type | string | Ya | "button" untuk quick reply |
header | object | Tidak | Header teks, gambar, video, atau dokumen |
body | object | Ya | Body pesan, field text wajib |
footer | object | Tidak | Footer, field text |
action | object | Ya | Objek action dengan array buttons |
Field action.buttons[]
Section titled “Field action.buttons[]”| Field | Tipe | Keterangan |
|---|---|---|
type | string | Selalu "reply" |
reply.id | string | ID tombol (dikirim balik di webhook saat diklik) |
reply.title | string | Label tombol, maks 20 karakter |
2. List Menu (list)
Section titled “2. List Menu (list)”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "interactive", "interactive": { "type": "list", "body": { "text": "Pilih layanan yang Anda butuhkan:" }, "footer": { "text": "Ketuk untuk melihat pilihan" }, "action": { "button": "Pilih Layanan", "sections": [ { "title": "Perbankan", "rows": [ { "id": "svc_check_balance", "title": "Cek Saldo", "description": "Lihat saldo rekening Anda" }, { "id": "svc_transfer", "title": "Transfer", "description": "Kirim uang ke rekening lain" } ] }, { "title": "Informasi", "rows": [ { "id": "svc_promo", "title": "Promo", "description": "Lihat promo terbaru" } ] } ] } }}Field action untuk List
Section titled “Field action untuk List”| Field | Tipe | Keterangan |
|---|---|---|
button | string | Label tombol pembuka list, maks 20 karakter |
sections[] | array | Array section |
sections[].title | string | Judul section |
sections[].rows[] | array | Daftar pilihan dalam section |
sections[].rows[].id | string | ID row (dikirim balik saat dipilih) |
sections[].rows[].title | string | Judul row, maks 24 karakter |
sections[].rows[].description | string | Deskripsi opsional, maks 72 karakter |
3. CTA URL (cta_url)
Section titled “3. CTA URL (cta_url)”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "interactive", "interactive": { "type": "cta_url", "body": { "text": "Selesaikan pembayaran Anda sekarang." }, "action": { "name": "cta_url", "parameters": { "display_text": "Bayar Sekarang", "url": "https://pay.example.com/checkout/abc123" } } }}4. WhatsApp Flow (flow)
Section titled “4. WhatsApp Flow (flow)”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "interactive", "interactive": { "type": "flow", "body": { "text": "Silakan isi formulir pendaftaran." }, "action": { "name": "flow", "parameters": { "flow_message_version": "3", "flow_token": "tx_abc123", "flow_id": "1234567890", "flow_cta": "Mulai", "flow_action": "navigate", "flow_action_payload": { "screen": "WELCOME", "data": { "user_name": "Budi" } } } } }}Field action.parameters untuk Flow
Section titled “Field action.parameters untuk Flow”| Field | Tipe | Keterangan |
|---|---|---|
flow_message_version | string | Selalu "3" |
flow_token | string | Token korelasi untuk mencocokkan dengan nfm_reply |
flow_id | string | ID Flow yang sudah dipublikasikan di Meta |
flow_cta | string | Label tombol CTA |
flow_action | string | "navigate" (buka layar awal) atau "data_exchange" |
flow_action_payload | object | Payload untuk flow_action="navigate" |
5. Location Request (send_location)
Section titled “5. Location Request (send_location)”{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "interactive", "interactive": { "type": "button", "body": { "text": "Kirim lokasi Anda untuk menemukan cabang terdekat." }, "action": { "name": "send_location" } }}Contoh Lengkap (Quick Reply)
Section titled “Contoh Lengkap (Quick Reply)”curl -X POST https://messaging.mahadata.io/v1/YOUR_PHONE_NUMBER_ID/messages \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "messaging_product": "whatsapp", "to": "6281234567890", "type": "interactive", "interactive": { "type": "button", "body": { "text": "Konfirmasi pesanan Anda?" }, "action": { "buttons": [ { "type": "reply", "reply": { "id": "confirm", "title": "Ya, konfirmasi" } }, { "type": "reply", "reply": { "id": "cancel", "title": "Batalkan" } } ] } } }'import requests
url = "https://messaging.mahadata.io/v1/YOUR_PHONE_NUMBER_ID/messages"headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}payload = { "messaging_product": "whatsapp", "to": "6281234567890", "type": "interactive", "interactive": { "type": "button", "body": {"text": "Konfirmasi pesanan Anda?"}, "action": { "buttons": [ {"type": "reply", "reply": {"id": "confirm", "title": "Ya, konfirmasi"}}, {"type": "reply", "reply": {"id": "cancel", "title": "Batalkan"}} ] } }}
response = requests.post(url, json=payload, headers=headers)print(response.json())const response = await fetch( 'https://messaging.mahadata.io/v1/YOUR_PHONE_NUMBER_ID/messages', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ messaging_product: 'whatsapp', to: '6281234567890', type: 'interactive', interactive: { type: 'button', body: { text: 'Konfirmasi pesanan Anda?' }, action: { buttons: [ { type: 'reply', reply: { id: 'confirm', title: 'Ya, konfirmasi' } }, { type: 'reply', reply: { id: 'cancel', title: 'Batalkan' } }, ], }, }, }), });const data = await response.json();console.log(data);Response
Section titled “Response”{ "messaging_product": "whatsapp", "messages": [ { "id": "msg_f7a816e2-8397-11f0-8e34-010203040506" } ]}Webhook Status yang Akan Anda Terima
Section titled “Webhook Status yang Akan Anda Terima”message.status.sent— Pesan interaktif berhasil dikirimmessage.status.delivered— Pesan sampai ke perangkat penerimamessage.status.read— Pesan dibaca oleh penerima
Jika gagal, Anda menerima message.status.failed.
Ketika penerima menekan tombol atau memilih item dari list, Anda akan menerima webhook message.inbound berisi button_reply atau list_reply dengan ID yang Anda tentukan.
Lihat halaman Webhook untuk detail format payload setiap event.