เรากำลังเลิกใช้งาน API ภายในองค์กร และหากต้องการรายละเอียดเพิ่มเติมและเรียนรู้วิธีย้ายไปใช้ API ระบบคลาวด์รุ่นใหม่ของเรา โปรดดูเอกสารการเลิกใช้งาน API ภายในองค์กรของเรา
เทมเพลตข้อความแบบอินเทอร์แอคทีฟจะช่วยให้คุณส่งเนื้อหาให้ผู้รับได้ครอบคลุมยิ่งกว่าเทมเพลตข้อความประเภทมาตรฐานและประเภทสื่อ ด้วยการใส่ปุ่มแบบอินเทอร์แอคทีฟเอาไว้โดยใช้อ็อบเจ็กต์ components
ปุ่มที่กำหนดไว้ล่วงหน้ามี 2 ประเภทดังนี้
คุณสามารถแนบปุ่มเหล่านี้ไปกับข้อความตัวอักษรหรือข้อความสื่อได้ เมื่อคุณสร้างและอนุมัติเทมเพลตข้อความแบบอินเทอร์แอคทีฟแล้ว คุณจะสามารถใช้เทมเพลตดังกล่าวในข้อความแจ้งเตือน รวมถึงในข้อความเกี่ยวกับการบริการ/การดูแลลูกค้าได้
คุณต้องดำเนินการต่อไปนี้
เมื่อเทมเพลตข้อความได้รับอนุมัติแล้ว คุณสามารถใช้ API เพื่อส่งข้อความได้
POST ไปยัง /messages
POST /v1/messages
{
"to": "recipient_wa_id",
"type": "template",
"template": {
"namespace": "your-namespace",
"language": {
"policy": "deterministic",
"code": "your-language-and-locale-code"
},
"name": "your-template-name",
"components": [
{
"type" : "header",
"parameters": [
{
"type": "text",
"text": "replacement_text"
}
]
# end header
},
{
"type" : "body",
"parameters": [
{
"type": "text",
"text": "replacement_text"
},
{
"type": "currency",
"currency" : {
"fallback_value": "$100.99",
"code": "USD",
"amount_1000": 100990
}
},
{
"type": "date_time",
"date_time" : {
"fallback_value": "February 25, 1977",
"day_of_week": 5,
"day_of_month": 25,
"year": 1977,
"month": 2,
"hour": 15,
"minute": 33, #OR
"timestamp": 1485470276
}
},
{
...
# Any additional template parameters
}
]
# end body
},
# The following part of this code example includes several possible button types,
# not all are required for an interactive message template API call.
{
"type": "button",
"sub_type" : "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
# Business Developer-defined payload
"payload":"aGlzIHRoaXMgaXMgY29vZHNhc2phZHdpcXdlMGZoIGFTIEZISUQgV1FEV0RT"
}
]
},
{
"type": "button",
"sub_type" : "url",
"index": "1",
"parameters": [
{
"type": "text",
# Business Developer-defined dynamic URL suffix
"text": "9rwnB8RbYmPF5t2Mn09x4h"
}
]
},
{
"type": "button",
"sub_type" : "url",
"index": "2",
"parameters": [
{
"type": "text",
# Business Developer-defined dynamic URL suffix
"text": "ticket.pdf"
}
]
}
]
}
}
การตอบกลับที่สำเร็จจะมีอ็อบเจ็กต์ messages ที่มี id
{
"messages": [{
"id": "gBEGkYiEB1VXAglK1ZEqA1YKPrU"
}]
}
การตอบกลับที่ไม่สำเร็จจะมีอ็อบเจ็กต์ข้อผิดพลาดพร้อมสตริงข้อผิดพลาด รหัสข้อผิดพลาด และข้อมูลอื่นๆ
หากมีการส่งเทมเพลตไปยังบัญชีที่ไม่สามารถรับเทมเพลตได้ ระบบจะส่งข้อผิดพลาด 1026 (ReceiverIncapable) ในอ็อบเจ็กต์ข้อผิดพลาดไปยังเซิร์ฟเวอร์ Webhook ที่กำหนดค่าไว้
โปรดดูข้อมูลเพิ่มเติมเกี่ยวกับข้อผิดพลาดที่รหัสข้อผิดพลาดและรหัสสถานะ
เมื่อผู้ใช้คลิกปุ่มตอบกลับด่วน ระบบจะส่งการตอบกลับคืนกลับไปให้ธุรกิจ โปรดดูข้อมูลที่การเรียกกลับจากการคลิกปุ่มตอบกลับด่วน นอกจากนี้ ผู้ใช้ยังเลือกที่จะไม่คลิกปุ่มและทำเพียงส่งข้อความรูปแบบอิสระถึงคุณได้ด้วย
{
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "16505551234"
}
],
"messages": [
{
"button": {
"payload": "No-Button-Payload",
"text": "No"
},
"context": {
"from": "16315558007",
"id": "gBGGFmkiWVVPAgkgQkwi7IORac0"
},
"from": "16505551234",
"id": "ABGGFmkiWVVPAgo-sKD87hgxPHdF",
"timestamp": "1591210827",
"type": "button"
}
]
# If there are any errors, an errors field (array) will be present
"errors": [ { ... } ]
}
ตัวอย่างเหล่านี้แสดงขั้นตอนการตั้งค่าเทมเพลตข้อความแบบอินเทอร์แอคทีฟ โดยเริ่มจากการสร้างเทมเพลตในตัวจัดการธุรกิจของคุณ และส่งเทมเพลตข้อความด้วยการเรียกใช้ API ไปยังตำแหน่งข้อมูล messages
ตัวอย่างนี้แสดงการสร้างเทมเพลตข้อความสื่อแบบอินเทอร์แอคทีฟพร้อมปุ่มตอบกลับด่วน

messages จะเพิ่มลงในข้อมูลพารามิเตอร์
POST /v1/messages
{
"to": "your-test-recipient-wa-id",
"recipient_type": "individual",
"type": "template",
"template": {
"namespace": "88b39973_f0d5_54e1_29cf_e80f1e3da4f2",
"name": "upcoming_trip_reminder",
"language": {
"code": "en",
"policy": "deterministic"
},
"components": [
{
"type": "header",
"parameters": [
{
"type": "text",
"text": "12/26"
}
]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "*Ski Trip*"
},
{
"type": "date_time",
"date_time" : {
"fallback_value": "29th July 2019, 8:00am",
"day_of_month": "29",
"year": "2019",
"month": "7",
"hour": "8",
"minute": "00"
}
},
{
"type": "text",
"text": "*Squaw Valley Ski Resort, Tahoe*"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": 0,
"parameters": [
{
"type": "payload",
"payload": "Yes-Button-Payload"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": 1,
"parameters": [
{
"type": "payload",
"payload": "No-Button-Payload"
}
]
}
]
}
}

ตัวอย่างนี้แสดงการสร้างเทมเพลตข้อความสื่อแบบอินเทอร์แอคทีฟพร้อมปุ่ม URL และปุ่มหมายเลขโทรศัพท์
messages จะเพิ่มลงในข้อมูลพารามิเตอร์
POST /v1/messages
{
"to": "your-test-recipient-wa-id",
"recipient_type": "individual",
"type": "template",
"template": {
"namespace": "88b39973_f0d5_54e1_29cf_e80f1e3da4f2",
"name": "oculus_shipment_update",
"language": {
"code": "en",
"policy": "deterministic"
},
"components": [
{
"type": "header",
"parameters": [{
"type": "image",
"image": {
"link": "link-to-your-image"
}
}]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Anand"
},
{
"type": "text",
"text": "Quest"
},
{
"type": "text",
"text": "113-0921387"
},
{
"type": "date_time",
"date_time" : {
"fallback_value": "23rd Nov 2019",
"day_of_month": "20",
"year": "2019",
"month": "9"
}
}
]
},
{
"type": "button",
"index": "0",
"sub_type": "url",
"parameters": [
{
"type": "text",
"text": "1Z999AA10123456784"
}
]
}
]
}
}
