ข้อมูลอ้างอิงเกี่ยวกับเทมเพลตปุ่ม

เทมเพลตปุ่มช่วยให้คุณส่งข้อความที่มีการจัดโครงสร้างซึ่งมีทั้งข้อความและปุ่มได้ โปรดดูรายละเอียดการนำไปใช้ที่ครบถ้วนสมบูรณ์ที่เทมเพลตปุ่ม

เนื้อหา

URI คำขอ

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

ตัวอย่างคำขอ

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>"

ตัวอย่างการตอบกลับ

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

คุณสมบัติ

recipient

คำอธิบายของผู้รับข้อความ คำขอทั้งหมดต้องรวม “id” “phone_number” หรือ “user_ref” อย่างใดอย่างหนึ่ง

คุณสมบัติประเภทคำอธิบาย

recipient.id

สตริง

PSID, phone_number หรือ user_ref ของผู้รับข้อความอย่างใดอย่างหนึ่ง

recipient.phone_number

สตริง

ระบุหรือไม่ก็ได้ หมายเลขโทรศัพท์มือถือของผู้รับที่อยู่ในรูปแบบ +1(212)555-2368


บอทของคุณต้องได้รับการอนุมัติสำหรับการจับคู่ลูกค้าเพื่อส่งข้อความด้วยวิธีนี้

recipient.user_ref

สตริง

ระบุหรือไม่ก็ได้user_ref จากปลั๊กอินกล่องกาเครื่องหมาย

recipient.name

อ็อบเจ็กต์

ระบุหรือไม่ก็ได้ ต้องใช้หากตั้งค่า phone_number เท่านั้น ระบุชื่อของบุคคลในรูปแบบ:


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

การใส่ชื่อจะเพิ่มโอกาสที่จะจับคู่สำเร็จ

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 ของเทมเพลต

message.attachment.payload

คุณสมบัติ ประเภท คำอธิบาย

template_type

สตริง

ค่าต้องเป็น button

text

สตริง

ข้อความในรูปแบบ UTF-8-encoded ที่มีอักขระไม่เกิน 640 ตัว ข้อความจะปรากฏเหนือปุ่ม

buttons

อาร์เรย์ <button>

ชุดปุ่ม 1-3 ปุ่มที่ปรากฏเป็นการกระตุ้นให้ดำเนินการ