Referensi Template Tombol

Template tombol memungkinkan Anda mengirim pesan terstruktur yang menyertakan teks dan tombol. Untuk detail penerapan lengkap, lihat Template Tombol.

Konten

URI Permintaan

https://graph.facebook.com/v19.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>

Contoh Permintaan

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"button",
        "text":"What do you want to do next?",
        "buttons":[
          {
            "type":"web_url",
            "url":"https://www.messenger.com",
            "title":"Visit Messenger"
          },
          {
            ...
          },
          {...}
        ]
      }
    }
  }
}' "https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Contoh Tanggapan

{
  "recipient_id": "1254477777772919",
  "message_id": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P"
}  

Properti

recipient

Keterangan penerima pesan. Semua permintaan harus menyertakan salah satu dari id, phone_number, atau user_ref.

PropertiJenisKeterangan

recipient.id

String

Baik PSID, phone_number, maupun user_ref penerima pesan.

recipient.phone_number

String

Opsional. Nomor ponsel penerima dengan format +1(212)555-2368.


Bot Anda harus disetujui untuk Pencocokan Pelanggan untuk mengirim pesan dengan cara ini.

recipient.user_ref

String

Opsional.user_ref dari plugin kotak centang.

recipient.name

Objek

Opsional. Digunakan hanya jika phone_number diatur. Tentukan nama orang dalam format:


{"first_name":"John", "last_name":"Doe"}

Memberikan nama akan meningkatkan peluang kecocokan.

message

Description of the message to be sent.
Property Type Description

message.attachment

Object

An object describing attachments to the message.

message.attachment

Property Type Description

type

String

Value must be template

payload

Object

payload template.

message.attachment.payload

Properti Jenis Deskripsi

template_type

String

Nilai harus berupa button

text

String

Teks berenkode UTF-8 hingga 640 karakter. Teks akan muncul di atas tombol.

buttons

Array<button>

Set 1-3 tombol yang muncul sebagai tombol ajakan bertindak.