ข้อความ

/v1/messages

ใช้โหนด messages ในการส่งข้อความ SMS, สื่อ, ผู้ติดต่อ, ตำแหน่ง และข้อความอินเทอร์แอคทีฟ รวมถึงเทมเพลตข้อความให้แก่ลูกค้าของคุณ

โปรดดูข้อมูลเกี่ยวกับประเภทข้อความที่เฉพาะเจาะจงซึ่งคุณสามารถส่งได้ในคำแนะนำต่างๆ ได้แก่ ข้อความ SMS, ข้อความสื่อ, ข้อความแสดงผู้ติดต่อและตำแหน่ง, ข้อความอินเทอร์แอคทีฟ, เทมเพลตข้อความ, เทมเพลตข้อความสื่อ และเทมเพลตข้อความอินเทอร์แอคทีฟ

ก่อนเริ่มต้น

คุณจำเป็นต้องดำเนินการดังต่อไปนี้

ตั้งแต่เวอร์ชั่น 2.39 ขึ้นไป คุณไม่ต้องเรียกใช้โหนดผู้ติดต่อก่อนส่งข้อความ

ข้อจำกัด

  • ระบบรองรับประเภทข้อความต่างๆ ได้แก่ ข้อความ SMS, เทมเพลตข้อความ, รูปภาพ, เอกสาร และเสียง
  • ข้อความ SMS มีจำนวนอักขระได้สูงสุด 4,096 ตัว

การสร้าง

คุณส่งข้อความได้โดยเรียก POST ไปยังโหนด /messages ไม่ว่าจะเป็นข้อความประเภทใดก็ตาม เนื้อหาของข้อความ JSON จะแตกต่างกันไปตามข้อความแต่ละประเภท (ข้อความ รูปภาพ ฯลฯ)

พารามิเตอร์

พารามิเตอร์ต่อไปนี้เป็นพารามิเตอร์หลักที่ใช้ในการส่งคำขอ POST /messages

ชื่อคำอธิบาย (คลิกที่ลูกศรในคอลัมน์ด้านซ้ายเพื่อดูตัวเลือกที่รองรับ)

audio

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=audio

อ็อบเจ็กต์ media ที่มีเสียง

biz_opaque_callback_data

สตริง

ระบุหรือไม่ก็ได้

สตริงแบบกำหนดเองซึ่งมีประโยชน์สำหรับการติดตาม


ตัวอย่างเช่น คุณสามารถส่ง ID เทมเพลตข้อความในช่องนี้เพื่อติดตามเส้นทางการคอนเวอร์ชั่นของลูกค้าโดยเริ่มจากข้อความแรกที่คุณส่ง จากนั้น คุณจะสามารถติดตาม ROI ของเทมเพลตข้อความประเภทต่างๆ เพื่อระบุประเภทที่มีประสิทธิภาพสูงสุด


แอพที่สมัครรับข้อมูลจากช่อง Webhook messages ในบัญชี WhatsApp Business สามารถรับสตริงนี้ได้ เนื่องจากรวมอยู่ในอ็อบเจ็กต์ statuses ภายในเพย์โหลดของ Webhook


API ระบบคลาวด์ไม่ได้ประมวลผลช่องนี้ เพียงแต่จะส่งคืนช่องโดยเป็นส่วนหนึ่งของ Webhooks ข้อความที่ส่ง/ได้รับ/อ่านแล้ว


สูงสุด 512 อักขระ


เฉพาะ API ระบบคลาวด์

contacts

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=contacts

อ็อบเจ็กต์ contacts

context

อ็อบเจ็กต์

จำเป็นต้องระบุหากตอบกลับข้อความในการสนทนา

อ็อบเจ็กต์ที่มี ID ของข้อความก่อนหน้าที่คุณกำลังตอบกลับ ตัวอย่างเช่น:


{"message_id":"MESSAGE_ID"}


เฉพาะ API ระบบคลาวด์

document

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=document

อ็อบเจ็กต์ media ที่มีเอกสาร

hsm

อ็อบเจ็กต์

ประกอบด้วยอ็อบเจ็กต์ hsm ตัวเลือกนี้ถูกเลิกใช้งานแล้วใน v2.39 ของ API ภายในองค์กร ให้ใช้อ็อบเจ็กต์ template แทน


เฉพาะ API ภายในองค์กร

image

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=image

อ็อบเจ็กต์ media ที่มีรูปภาพ

interactive

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=interactive

อ็อบเจ็กต์ interactive โดยทั่วไปแล้ว องค์ประกอบของอ็อบเจ็กต์ interactive แต่ละรายการจะมีรูปแบบที่สอดคล้องกัน ได้แก่ header, body, footer และ action

location

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=location

อ็อบเจ็กต์ location

messaging_product

สตริง

จำเป็นต้องระบุ

บริการส่งข้อความที่ใช้สำหรับคำขอ ให้ใช้ "whatsapp"


เฉพาะ API ระบบคลาวด์

preview_url

บูลีน

จำเป็นต้องระบุหาก type=text

อนุญาตให้แสดงตัวอย่าง URL ในข้อความตัวอักษร โปรดดูการส่ง URL ในข้อความตัวอักษร ช่องนี้เป็นช่องที่จะระบุหรือไม่ก็ได้ หากไม่มี URL ในข้อความของคุณ ค่า:false (ค่าเริ่มต้น), true


เฉพาะ API ภายในองค์กร ผู้ใช้ API ระบบคลาวด์สามารถใช้ฟังก์ชั่นเดียวกันนี้กับช่อง preview_url ภายในอ็อบเจ็กต์ข้อความได้

recipient_type

สตริง

ระบุหรือไม่ก็ได้

ขณะนี้คุณสามารถส่งข้อความถึงบุคคลได้เท่านั้น ตั้งค่าเป็น individual


ค่าเริ่มต้น: individual

status

สตริง

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


sticker

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=sticker

อ็อบเจ็กต์ media ที่มีสติกเกอร์


API ระบบคลาวด์: ระบบรองรับสติกเกอร์ขาออกของบุคคลที่สามแบบภาพนิ่งและแบบเคลื่อนไหว นอกเหนือจากสติกเกอร์ขาเข้าทุกประเภท สติกเกอร์แบบภาพนิ่งจะต้องมีความละเอียด 512x512 พิกเซล และต้องมีขนาดไม่เกิน 100 KB สติกเกอร์แบบเคลื่อนไหวจะต้องมีความละเอียด 512x512 พิกเซล และต้องมีขนาดไม่เกิน 500 KB


API ภายในองค์กร: ระบบรองรับเฉพาะสติกเกอร์ขาออกของบุคคลที่สามแบบภาพนิ่ง นอกเหนือจากสติกเกอร์ขาเข้าทุกประเภท สติกเกอร์แบบภาพนิ่งจะต้องมีความละเอียด 512x512 พิกเซล และต้องมีขนาดไม่เกิน 100 KB ระบบไม่รองรับสติกเกอร์แบบเคลื่อนไหว

template

อ็อบเจ็กต์

จำเป็นต้องระบุเมื่อ type=template

อ็อบเจ็กต์ template

text

อ็อบเจ็กต์

จำเป็นต้องระบุสำหรับข้อความตัวอักษร

อ็อบเจ็กต์ text

to

สตริง

จำเป็นต้องระบุ

WhatsApp ID หรือหมายเลขโทรศัพท์ของลูกค้าที่คุณต้องการจะส่งข้อความไปหา โปรดดูรูปแบบหมายเลขโทรศัพท์


หากจำเป็น ผู้ใช้ API ภายในองค์กรสามารถรับหมายเลขนี้ได้โดยการเรียกใช้ตำแหน่งข้อมูล contacts

type

สตริง

ระบุหรือไม่ก็ได้

ประเภทของข้อความที่คุณต้องการส่ง หากละไว้ ค่าเริ่มต้นจะเป็น text

อ็อบเจ็กต์ข้อความ

ชื่อคำอธิบาย

body

จำเป็นต้องระบุ

ประกอบด้วยเนื้อความของข้อความ ซึ่งสามารถมี URL และการจัดรูปแบบรวมอยู่ด้วย

อ็อบเจ็กต์สื่อ

สำหรับ API ภายในองค์กร ระบบจะส่งคืน ID อ็อบเจ็กต์สื่อเมื่ออัพโหลดสื่อไปยังไคลเอ็นต์ภายในองค์กร/อ้างอิงของ WhatsApp Business ผ่านตำแหน่งข้อมูล media สำเร็จแล้ว

NameDescription

id

string

Required when type is audio, document, image, sticker, or video and you are not using a link.


The media object ID. Do not use this field when message type is set to text.

link

string

Required when type is audio, document, image, sticker, or video and you are not using an uploaded media ID (i.e. you are hosting the media asset on your public server).

The protocol and URL of the media to be sent. Use only with HTTP/HTTPS URLs.


Do not use this field when message type is set to text.


Cloud API users only:


  • See Media HTTP Caching if you would like us to cache the media asset for future messages.
  • When we request the media asset from your server you must indicate the media's MIME type by including the Content-Type HTTP header. For example: Content-Type: video/mp4. See Supported Media Types for a list of supported media and their MIME types.

caption

string

Optional.


Media asset caption. Do not use with audio or sticker media.


On-Premises API users:

  • For v2.41.2 or newer, this field is is limited to 1024 characters.
  • Captions are currently not supported for document media.

filename

string

Optional.


Describes the filename for the specific document. Use only with document media.


The extension of the filename will specify what format the document is displayed as in WhatsApp.

provider

string

Optional. On-Premises API only.

This path is optionally used with a link when the HTTP/HTTPS link is not directly accessible and requires additional configurations like a bearer token. For information on configuring providers, see the Media Providers documentation.

อ็อบเจ็กต์ผู้ติดต่อ

คุณสามารถวางอ็อบเจ็กต์ต่างๆ ได้แก่ addresses, emails, name, org, phone และ urls ซ้อนกันไว้ภายใน contacts ได้ ระบบจะรวมอ็อบเจ็กต์แบบ Pluralized ไว้ในอาร์เรย์ดังที่แสดงในตัวอย่างด้านล่าง

NameDescription

addresses

object

Optional.

Full contact address(es) formatted as an addresses object. The object can contain the following fields:

streetstringOptional. Street number and name.

citystringOptional. City name.

statestringOptional. State abbreviation.

zipstringOptional. ZIP code.

countrystringOptional. Full country name.

country_codestringOptional. Two-letter country abbreviation.

typestringOptional. Standard values are HOME and WORK.

birthday

Optional.

YYYY-MM-DD formatted string.

emails

object

Optional.

Contact email address(es) formatted as an emails object. The object can contain the following fields:

emailstringOptional. Email address.

typestringOptional. Standard values are HOME and WORK.

name

object

Required.

Full contact name formatted as a name object. The object can contain the following fields:

formatted_namestringRequired. Full name, as it normally appears.

first_namestringOptional*. First name.

last_namestringOptional*. Last name.

middle_namestringOptional*. Middle name.

suffixstringOptional*. Name suffix.

prefixstringOptional*. Name prefix.


*At least one of the optional parameters needs to be included along with the formatted_name parameter.

org

object

Optional.

Contact organization information formatted as an org object. The object can contain the following fields:

companystringOptional. Name of the contact's company.

departmentstringOptional. Name of the contact's department.

titlestringOptional. Contact's business title.

phones

object

Optional.

Contact phone number(s) formatted as a phone object. The object can contain the following fields:

phonestringOptional. Automatically populated with the `wa_id` value as a formatted phone number.

typestringOptional. Standard Values are CELL, MAIN, IPHONE, HOME, and WORK.

wa_idstringOptional. WhatsApp ID.

urls

object

Optional.

Contact URL(s) formatted as a urls object. The object can contain the following fields:

urlstringOptional. URL.

typestringOptional. Standard values are HOME and WORK.

ตัวอย่างอ็อบเจ็กต์ contacts ซึ่งมีอ็อบเจ็กต์แบบ Pluralized วางซ้อนกันอยู่ภายใน

"contacts": [
    {
        "addresses": [
            {
                "city": "city name",
                "country": "country name",
                "country_code": "code",
                "state": "Contact's State",
                "street": "Contact's Street",
                "type": "Contact's Address Type",
                "zip": "Contact's Zip Code"
            }
        ],
        "birthday": "birthday",
        "emails": [
            {
                "email": "email",
                "type": "HOME"
            },
            {
                "email": "email",
                "type": "WORK"
            }
        ],
        "name": {
            "first_name": "first name value",
            "formatted_name": "formatted name value",
            "last_name": "last name value",
            "suffix": "suffix value"
        },
        "org": {
            "company": "company name",
            "department": "dep name",
            "title": "title"
        },
        "phones": [
            {
                "phone": "Phone number",
                "wa-id": "WA-ID value",
                "type": "MAIN"
            },
            {
                "phone": "Phone number",
                "type": "HOME"
            },
            {
                "phone": "Phone number",
                "type": "WORK"
            }
        ],
        "urls": [{
            "url": "some url",
            "type": "WORK"
        }]
    }
]

อ็อบเจ็กต์ตำแหน่ง

NameDescription

latitude

Required.

Location latitude in decimal degrees.

longitude

Required.

Location longitude in decimal degrees.

name

Required.

Name of the location.

address

Required.

Address of the location.

อ็อบเจ็กต์เทมเพลต

คุณสามารถวางอ็อบเจ็กต์ components และ language ซ้อนกันไว้ภายใน template ได้

ตั้งแต่ v2.27.8namespace ของเทมเพลตต้องเป็นเนมสเปซที่เชื่อมโยงกับ WABA ซึ่งเป็นเจ้าของหมายเลขโทรศัพท์ในไคลเอ็นต์ภายในองค์กรของ WhatsApp Business ปัจจุบัน มิฉะนั้นจะไม่สามารถส่งข้อความได้

นอกจากนี้ ตั้งแต่ v2.41 ขึ้นไป namespace จะเป็นช่องที่ระบุหรือไม่ก็ได้

ชื่อคำอธิบาย

namespace

ต้องระบุ

เนมสเปซของเทมเพลต


นับตั้งแต่ v2.27.8 เนมสเปซนี้จะต้องสัมพันธ์กับบัญชี WhatsApp Business ที่เป็นเจ้าของหมายเลขโทรศัพท์ที่สัมพันธ์กับไคลเอ็นต์ WhatsApp Business API ปัจจุบัน มิฉะนั้น ข้อความจะส่งออกไปไม่ได้

name

ต้องระบุ

ชื่อของเทมเพลต

language

ต้องระบุ

ระบุภาษาที่เทมเพลตสามารถแสดงผลได้ นโยบายภาษาแบบ deterministic เท่านั้นที่ใช้งานได้กับข้อความเทมเพลตสื่อ ดูข้อมูลเพิ่มเติมได้ในส่วนภาษา

components

ระบุหรือไม่ก็ได้

อาร์เรย์ที่มีพารามิเตอร์ของข้อความ

อ็อบเจ็กต์องค์ประกอบ

คุณสามารถวางซ้อนอ็อบเจ็กต์ parameters ภายใน components ได้ และสามารถตั้งค่า type เป็น button ได้ด้วย

ชื่อคำอธิบาย

type

ต้องระบุ

อธิบายประเภท component
ค่า:header, body, footer

parameters

ระบุหรือไม่ก็ได้

อาร์เรย์ที่มีเนื้อหาของข้อความ

อ็อบเจ็กต์พารามิเตอร์

ชื่อคำอธิบาย

type

ต้องระบุ

อธิบายประเภท parameter
ค่า:text, currency, date_time, image, document, video


ประเภทสื่อ (image, document และ video) ใช้รูปแบบเดียวกับที่ใช้ในข้อความสื่อมาตรฐาน โปรดดูข้อมูลเพิ่มเติมที่เอกสารประกอบสื่อ ขณะนี้รองรับเฉพาะเอกสาร PDF สำหรับเทมเพลตข้อความสื่อเท่านั้น


โปรดดูข้อมูลเพิ่มเติมเกี่ยวกับ currency และ date_time ที่ส่วนพารามิเตอร์ที่สามารถแปลได้ พารามิเตอร์ currency และ date_time สำหรับข้อความ template ใช้ fallback_value แทน default ดูตัวอย่างคำขอด้านบนนี้เพื่อเป็นตัวอย่าง

ประเภทปุ่ม

คุณสามารถตั้งค่า type เป็น button ภายในอ็อบเจ็กต์ components ได้ พารามิเตอร์ปุ่มมีดังต่อไปนี้

ชื่อคำอธิบาย

sub_type

จำเป็นต้องระบุ

ประเภทของปุ่มที่สร้างขึ้น
ค่า:quick_reply, url, copy_code (available from 2.49 and onwards)

index

จำเป็นต้องระบุ

ดัชนีตำแหน่งของปุ่ม คุณสามารถมีได้สูงสุด 10 ปุ่มโดยใช้ค่าดัชนี 0-2

parameters

จำเป็นต้องระบุ

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

  • type (จำเป็นต้องระบุ): ระบุประเภทพารามิเตอร์ของปุ่ม ค่าที่รองรับ ได้แก่ payload, text และ coupon_code
  • payload (จำเป็นต้องระบุสำหรับปุ่ม quick_reply): ระบบจะส่งคืนเพย์โหลดที่ผู้พัฒนากำหนดเมื่อมีการคลิกปุ่ม นอกเหนือจากข้อความที่แสดงบนปุ่ม
  • text (จำเป็นต้องระบุสำหรับปุ่ม url): ผู้พัฒนาได้ให้คำต่อท้ายที่จะพ่วงท้ายไปกับปุ่ม URL แบบไดนามิกที่สร้างไว้ก่อนหน้านี้
  • coupon_code (จำเป็นต้องระบุสำหรับปุ่ม copy_code ใช้ได้ตั้งแต่เวอร์ชั่น 2.49 เป็นต้นไป): ผู้พัฒนาได้ระบุรหัสคูปองที่จะได้รับการคัดลอกเมื่อคลิกปุ่มคัดลอกรหัส

ตัวอย่างการกำหนด type เป็น button โดยมี sub_type เป็น quick_reply

 {
    "type": "button",
    "sub_type": "quick_reply",
    "index": 0,
    "parameters": 
     [{
    	"type": "payload",
    	"payload": "Yes-Button-Payload"
     }]
 } 

ตัวอย่างการกำหนด type เป็น button โดยมี sub_type เป็น copy_code

    
 { 
    "type": "button", 
    "sub_type": "copy_code", 
    "index": 0, 
    "parameters": 
    [{ 
     "type": "coupon_code", 
     "coupon_code": "DISCOUNT20" 
    }] 
 }

อ็อบเจ็กต์ Hsm

เราได้เลิกใช้อ็อบเจ็กต์ hsm แล้วในไคลเอ็นต์ภายในองค์กร/อ้างอิงของ WhatsApp Business v2.39 โปรดใช้อ็อบเจ็กต์ template แทน

ชื่อ คำอธิบาย

namespace

จำเป็นต้องระบุ

เนมสเปซที่จะใช้ เมื่อขึ้นต้นด้วย v2.2.7 หากเนมสเปซไม่ตรงกับ element_name จะส่งข้อความไม่สำเร็จ

element_name

จำเป็นต้องระบุ

ชื่อองค์ประกอบซึ่งระบุว่าจะใช้เทมเพลตใดภายในเนมสเปซ เมื่อขึ้นต้นด้วย v2.2.7 หาก element_name ไม่ตรงกับเนมสเปซ จะส่งข้อความไม่สำเร็จ

language

จำเป็นต้องระบุ

อนุญาตสำหรับข้อมูลจำเพาะของภาษาเชิงกำหนด โปรดดูข้อมูลเพิ่มเติมในส่วนภาษา


ช่องนี้เคยใช้เพื่ออนุญาตสำหรับตัวเลือก fallback แต่ถูกเลิกใช้แล้วด้วย v2.27.8

localizable_params

จำเป็นต้องระบุ

ช่องนี้เป็นอาร์เรย์ของค่าที่จะใช้กับตัวแปรต่างๆ ในเทมเพลต โปรดดูข้อมูลเพิ่มเติมในส่วนพารามิเตอร์ที่สามารถแปลได้

อ็อบเจ็กต์แบบอินเทอร์แอคทีฟ

The interactive object generally contains 4 main components: header, body, footer, and action. Additionally, some of those components can contain one or more different objects:

  • Inside header, you can nest media objects.
  • Inside action, you can nest section and button objects.
NameDescription

type

string

Required.

The type of interactive message you want to send. Supported values:

  • list: Use it for List Messages.
  • button: Use it for Reply Buttons.
  • product: Use it for Single-Product Messages.
  • product_list: Use it for Multi-Product Messages.
  • catalog_message: Use it for Catalog Messages.
  • flow: Use it for Flows Messages.

header

object

Required for type product_list. Optional for other types.

Header content displayed on top of a message. You cannot set a header if your interactive object is of product type.


The header object contains the following fields:

documentobjectRequired if type is set to document. Contains the media object with the document.

imageobjectRequired if type is set to image. Contains the media object with the image.

videoobjectRequired if type is set to video. Contains the media object with the video.

textstringRequired if type is set to text. Text for the header. Formatting allows emojis, but not markdown. Maximum length: 60 characters.

typestringRequired. The header type you would like to use. Supported values are:

text – for List Messages, Reply Buttons, and Multi-Product Messages.

video – for Reply Buttons.

image – for Reply Buttons.

document – for Reply Buttons.

body

object

Optional for type product. Required for other message types.

An object with the body of the message.


The body object contains the following field:

textstringRequired if body is present. The content of the message. Emojis and markdown are supported. Maximum length: 1024 characters.

footer

object

Optional.

An object with the footer of the message.


The footer object contains the following field:

textstringRequired if footer is present. The footer content. Emojis, markdown, and links are supported. Maximum length: 60 characters.

action

object

Required.

An action object with what you want the user to perform after reading the message. See action object for full information.

อ็อบเจ็กต์การดำเนินการ

NameDescription

button

string

Required for List Messages.

Button content. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 characters.

buttons

object

Required for Reply Button Messages.

A button object. The object can contain the following parameters:

type – The only supported option is reply for Reply Button Messages.

title – Button title. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. Maximum length: 20 characters.

id – Unique identifier for your button. This ID is returned in the webhook when the button is clicked by the user. Maximum length: 256 characters.


คุณจะตั้งค่า ID โดยขึ้นต้นหรือลงท้ายด้วยการเว้นวรรคไม่ได้

sections

array of objects

Required for List Messages and Multi-Product Messages.

Array of section objects. There is a minimum of 1 and maximum of 10. See section object.

catalog_id

string

Required for Single-Product Messages and Multi-Product Messages.

Unique identifier of the Facebook catalog linked to your WhatsApp Business Account. This ID can be retrieved via Commerce Manager.

product_retailer_id

string

Required for Single-Product Messages and Multi-Product Messages.

Unique identifier of the product in a catalog. Maximum 100 characters for both Single-Product and Multi-Product messages.


To get this ID, go to Commerce Manager, select your Facebook Business account, and you will see a list of shops connected to your account. Click the shop you want to use. On the left-side panel, click Catalog > Items, and find the item you want to mention. The ID for that item is displayed under the item's name.

mode

string

Optional for Flows Messages.

The current mode of the Flow, either draft or published.


Default: published

flow_message_version

string

Required for Flows Messages.

Must be 3.

flow_token

string

Required for Flows Messages.

A token that is generated by the business to serve as an identifier.

flow_id

string

Required for Flows Messages.

Unique identifier of the Flow provided by WhatsApp.

flow_cta

string

Required for Flows Messages.

Text on the CTA button, eg. "Signup".


Maximum length: 20 characters (no emoji).

flow_action

string

Optional for Flows Messages.

navigate or data_exchange. Use navigate to predefine the first screen as part of the message. Use data_exchange for advanced use-cases where the first screen is provided by your endpoint.


Default: navigate

flow_action_payload

object

Optional for Flows Messages.

Required only if flow_action is navigate. The object can contain the following parameters:

screenstringRequired. The id of the first screen of the Flow.

dataobjectOptional. The input data for the first screen of the Flow. Must be a non-empty object.

Section Object

NameDescription

title

string

Required if the message has more than one section.

Title of the section. Maximum length: 24 characters.

rows

array of objects

Required for List Messages.

Contains a list of row objects. Limited to 10 rows across all sections.


Each row object contains the following fields:

titlestringRequired. Maximum length: 24 characters.

IDstringRequired. Maximum length: 200 characters.

descriptionstringOptional. Maximum length: 72 characters.

product_items

array of objects

Required for Multi-Product Messages.

Array of product objects. There is a minimum of 1 product per section and a maximum of 30 products across all sections.


Each product object contains the following field:

product_retailer_idstringRequired for Multi-Product Messages. Unique identifier of the product in a catalog. To get this ID, go to Commerce Manager, select your account and the shop you want to use. Then, click Catalog > Items, and find the item you want to mention. The ID for that item is displayed under the item's name.

ตัวอย่าง

ข้อความเสียง:

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "audio",
  "audio": {
      "id": "your-media-id",
  }
}

ข้อความที่เป็นเอกสาร โดยใช้ filename:

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "document",
  "document": {
      "id": "your-media-id",
      "filename": "your-document-filename"
  }
}

ข้อความที่เป็นเอกสาร โดยใช้ link:

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "document",
  "document": {
      "link": "http(s)://the-url"
      "provider": {
          "name" : "provider-name"
      }     
    }
}

ข้อความที่เป็นวิดีโอ โดยใช้ link:

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "video",  
  "video": {
      "link": "http(s)://the-url"
      "provider": {
          "name" : "provider-name"
      }
    }
  }
}

ข้อความ SMS:

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "text",
  "text": {
      "body": "your-message-content"
  }
}

ข้อความแบบอินเทอร์แอคทีฟ (รายการ):

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "interactive",
  "interactive":{
    "type": "list",
    "header": {
      "type": "text",
      "text": "your-header-content-here"
    },
    "body": {
      "text": "your-text-message-content-here"
    },
    "footer": {
      "text": "your-footer-content-here"
    },
    "action": {
      "button": "cta-button-content-here",
      "sections":[
        {
          "title":"your-section-title-content-here",
          "rows": [
            {
              "id":"unique-row-identifier-here",
              "title": "row-title-content-here",
              "description": "row-description-content-here",           
            }
          ]
        },
        {
          "title":"your-section-title-content-here",
          "rows": [
            {
              "id":"unique-row-identifier-here",
              "title": "row-title-content-here",
              "description": "row-description-content-here",           
            }
          ]
        },
        ...
      ]
    }
  }

}

ข้อความแบบอินเทอร์แอคทีฟ (ปุ่มตอบกลับ):

POST /v1/messages
{
  "recipient_type": "individual",
  "to": "whatsapp-id",
  "type": "interactive",
  "interactive": {
    "type": "button",
    "header": { # optional
      "type": "text" | "image" | "video" | "document",
      "text": "your text"
      # OR
      "document": {
        "id": "your-media-id",
        "filename": "some-file-name"
      }
      # OR
      "document": {
        "link": "the-provider-name/protocol://the-url",
        "provider": {
          "name": "provider-name",
        },
        "filename": "some-file-name"
      },
      # OR
      "video": {
        "id": "your-media-id"
      }
      # OR
      "video": {
        "link": "the-provider-name/protocol://the-url",
        "provider": {
          "name": "provider-name"
        }
      }
      # OR
      "image": {
        "id": "your-media-id"
      }
      # OR
      "image": {
        "link": "http(s)://the-url",
        "provider": {
          "name": "provider-name"
        }
      }
    }, # end header
    "body": {
      "text": "your-text-body-content"
    },
    "footer": { # optional
      "text": "your-text-footer-content"
    },
    "action": {
      "buttons": [
        {
          "type": "reply",
          "reply": {
            "id": "unique-postback-id",
            "title": "First Button’s Title" 
          }
        },
        {
          "type": "reply",
          "reply": {
            "id": "unique-postback-id",
            "title": "Second Button’s Title" 
          }
        }
      ] 
    } # end action   
  } # end interactive

}

ข้อความแบบอินเทอร์แอคทีฟ (ข้อความที่มีผลิตภัณฑ์รายการเดียวและหลายรายการ):

{ 
  "recipient_type": "individual",
  "to" : "{{Recipient-WA-ID}}",
  "type": "interactive",
  "interactive": {
    "type": "product",
    "body": {
      "text": "body text"
    },
    "footer": {
      "text": "footer text"
    },
    "action": {
      "
      
      _id": "catalog-ID",
      "product_retailer_id": "product-ID"
    }
  }
}

ข้อความแบบอินเทอร์แอคทีฟ (ข้อความที่มีผลิตภัณฑ์หลายรายการ):

{ 
  "recipient_type": "individual",
  "to" : "whatsapp-id",
  "type": "interactive",
  "interactive": 
    {
    "type": "product_list",
    "Header":{
       "type": "text",
        "text": "text-header-content"
     },
     "body":{
        "text": "text-body-content"
      },
     "footer":{
        "text":"text-footer-content"
     },
     "action":{
        "catalog_id":"catalog-id",
        "sections": [
             {
             "title": "section-title",             
             "product_items": [
                  { "product_retailer_id": "product-SKU-in-catalog" },
                  { "product_retailer_id": "product-SKU-in-catalog" },
                            ...
              ]},
              {
              "title": "the-section-title",
              "product_items": [
                 { "product_retailer_id": "product-SKU-in-catalog" }
                           ...
              ]},
               ...
       ]
     },  
    }
}

ข้อความแบบอินเทอร์แอคทีฟ (ข้อความที่มีแค็ตตาล็อก):

{ 
  "recipient_type": "individual",
  "to" : "whatsapp-id",
  "type": "interactive",
  "interactive": 
    {
    "type": "catalog_message",
     "body":{
        "text": "text-body-content"
      },
     "footer":{
        "text":"text-footer-content"
     },
     "action":{
        "name": "catalog_message",
      	"parameters":{ 
      	  "thumbnail_product_retailer_id": "product-SKU-in-catalog"
      	}
     },  
    }
}

ข้อความแบบอินเทอร์แอคทีฟ (ขั้นตอน):

{
  "recipient_type": "individual",
  "to": "{{Recipient-WA-ID}}",
  "type": "interactive",
  "interactive": {
    "type": "flow",
    "header": {
      "type": "text",
      "text": "Flow message header"
    },
    "body": {
      "text": "Flow message body"
    },
    "footer": {
      "text": "Flow message footer"
    },
    "action": {
      "name": "flow",
      "parameters": {
        "flow_message_version": "3",
        "flow_token": "AQAAAAACS5FpgQ_cAAAAAD0QI3s",
        "flow_id": "<FLOW_ID>",
        "flow_cta": "Book!",
        "flow_action": "navigate",
        "flow_action_payload": {
          "screen": "<SCREEN_ID>",
          "data": { # optional
            "user_name": "name",
            "user_age": 25
          }
        }
      }
    }
  }
}

โค้ดต่อไปนี้แสดงตัวอย่างของ payload ในการตอบกลับ โดยจะละอ็อบเจ็กต์ meta และ error ไว้เพื่อความกระชับ

{
  "messages": [{ 
    "id": "message-id" 
  }]    
}

หากคำขอสำเร็จ คุณจะได้รับการตอบกลับพร้อม ID ข้อความ หากคำขอส่งคืนส่วนของ errors โปรดตรวจสอบข้อความตั้งต้น และแก้ไขข้อผิดพลาดก่อนที่จะส่งคำขออีกครั้ง โปรดดูข้อมูลเพิ่มเติมเกี่ยวกับข้อผิดพลาดในรหัสข้อผิดพลาดของไคลเอ็นต์ภายในองค์กร/อ้างอิงของ WhatsApp Business และรหัสสถานะ HTTP

มีผลกับธุรกิจในบราซิล โคลอมเบีย และสิงคโปร์ตั้งแต่วันที่ 12 กันยายน 2023 มีผลกับธุรกิจทั้งหมดตั้งแต่วันที่ 12 ตุลาคม 2023

หากคำขอถูกระงับเพื่อประเมินคุณภาพ การตอบกลับจะมีพร็อพเพอร์ตี้ message_status พร้อมข้อความที่ระบุว่าไม่ได้ส่งข้อความในทันทีและจะส่งหรือปล่อยหลังได้รับการตรวจสอบคุณภาพ พร็อพเพอร์ตี้นี้จะปรากฏต่อเมื่อข้อความถูกระงับเท่านั้น

    {
      "messages": [{ 
        "id": "message-id",
        "message_status": "Message has been held because quality assessment is pending",
      }]    
    }
    

การจัดรูปแบบในข้อความ SMS

WhatsApp อนุญาตการจัดรูปแบบบางรูปแบบในข้อความ หากต้องการจัดรูปแบบข้อความบางส่วนหรือทั้งหมด ให้ใช้สัญลักษณ์การจัดรูปแบบเหล่านี้:

การจัดรูปแบบสัญลักษณ์ตัวอย่าง

Bold

ดอกจัน (*)

ยอดรวมของคุณคือ *10.50 ดอลลาร์*

ตัวเอียง

เส้นใต้ (_)

ยินดีต้อนรับสู่ _WhatsApp_!

ขีดทับ

ตัวหนอน (~)

นี่~ยิ่งกว่า~ดีที่สุด!

Code

เครื่องหมายแบ็กทิกสามตัว (```)

```พิมพ์ 'สวัสดีทุกคน';```

ประสิทธิภาพ

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

การตั้งค่าไคลเอ็นต์ข้อความ SMS ที่รองรับต่อวินาที

ชาร์ดเดียว

70

หลายชาร์ด (32 ชาร์ด)

250

คำถามที่พบบ่อย

หมายเหตุ: โปรดอย่าส่งข้อความเดิมถึงผู้รับคนเดิมซ้ำๆ โดยใช้ WhatsApp Business API

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

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

ข้อความอาจยังคงไม่ได้ส่ง เพราะโทรศัพท์ของผู้ใช้อาจเสียหรือแบตเตอรี่หมด หรือสูญหายและกำลังจะได้เครื่องใหม่ และได้ปิดใช้งาน SIM เอาไว้ เป็นไปได้หรือไม่ที่ลูกค้าธุรกิจะมีข้อผิดพลาดในการเชื่อมต่อกับเครือข่าย นอกจากนี้ ยังเป็นไปได้ที่การเรียกกลับ (Webhooks) ไม่ได้ถูกส่งไป คุณสามารถติดตามสถานการณ์เหล่านี้ได้โดยใช้โหนด health คุณสามารถเปิดการเรียกกลับการรับของเซิร์ฟเวอร์เพื่อให้ทราบว่าข้อความได้ไปถึงคลาวด์ของเซิร์ฟเวอร์ WhatsApp แล้ว

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

หากคุณส่งข้อความและได้รับ ID ข้อความจาก API แสดงว่าคุณได้ทำสิ่งที่สามารถทำได้เพื่อส่งข้อความนี้แล้ว อย่าส่งเนื้อหาเดิมซ้ำถึงผู้รับคนเดิม

หากคุณประสบปัญหาอัตราการนำส่งต่ำติดต่อกันเป็นเวลานาน โปรดส่งบัตรคำร้องขอรับความช่วยเหลือกับ ฝ่ายความช่วยเหลือโดยตรง

เมื่อคุณส่งข้อความ ในทันทีที่คุณได้รับ ID ข้อความ แสดงว่าคำขอข้อความถูกจัดเก็บไว้ในฐานข้อมูลแล้ว ไคลเอ็นต์ WhatsApp Business API จะพยายามส่งข้อความนั้นจนกว่าเซิร์ฟเวอร์ WhatsApp จะรับทราบ กระบวนการนี้ไม่มีเวลาสิ้นสุด จากนั้น เซิร์ฟเวอร์ WhatsApp จะพยายามส่งข้อความนั้นไปยังโทรศัพท์ของผู้ใช้ ถ้าโทรศัพท์ของผู้ใช้ไม่ได้ออนไลน์ ข้อความจะถูกจัดเก็บเป็นเวลา 30 วันก่อนที่เซิร์ฟเวอร์ WhatsApp จะทิ้งไป

ได้ WhatsApp อนุญาตให้คุณจัดรูปแบบตัวอักษรที่เลือกภายในข้อความเป็นแบบตัวหนา ตัวเอียง ขีดทับ หรือระยะห่างเท่ากัน

ขณะนี้ยังไม่มีวิธีใดในการดูว่ามีผู้ใช้กี่รายหรือรายใดบล็อกธุรกิจของคุณ ตัวบ่งชี้ที่ดีที่สุดคือการรอติดต่อการเรียกกลับสถานะ และถ้าคุณไม่ได้รับสถานะ delivered แสดงว่ามีผู้ใช้บล็อกธุรกิจของคุณ หรือไม่ก็ไม่มีการเชื่อมต่อเครือข่าย ดูรายละเอียดเพิ่มเติมได้ในเอกสารประกอบ Webhook

ถ้ามีผู้ใช้บล็อกธุรกิจของคุณ API ผู้ติดต่อจะยังคงส่งคืนหมายเลขโทรศัพท์นั้นเป็นผู้ใช้ WhatsApp ที่ถูกต้อง อย่างไรก็ตาม เมื่อคุณส่งข้อความ จะไม่มีวันถูกส่งถึง ถ้าเป็นข้อความที่มาจากโฆษณา คุณจะไม่ถูกเรียกเก็บค่าบริการ

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

เมื่อใช้โหนด messages คุณจำเป็นต้องตั้งค่าส่วนหัว Content-Type เป็น application/json เพื่อให้ไคลเอ็นต์ WhatsApp Business API แยกวิเคราะห์เนื้อหาข้อความได้อย่างถูกต้อง นอกจากนี้ยังมีส่วนหัว Authorization ที่จำเป็นต้องตั้งค่า และต้องมีโทเค็นการเข้าถึงที่ยังไม่หมดอายุ ดูข้อมูลเกี่ยวกับวิธีรับโทเค็นและเวลาหมดอายุได้ในเอกสารประกอบการเข้าสู่ระบบและการยืนยันตัวตน

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

  • ส่งผลลัพธ์ให้แก่ผู้ใช้ หรือ
  • ขึ้นข้อความแจ้งให้ผู้ใช้ตอบกลับ เพื่อเปิดใช้งานหน้าต่างการบริการลูกค้า

ในทั้งสองกรณี คุณต้องระบุบริบทสำหรับเทมเพลตข้อความให้มากที่สุดเท่าที่เป็นไปได้ ตัวอย่างเช่น:

  • "เรียน {{1}} ในส่วนของปัญหาที่ท่านแจ้งไปก่อนหน้านี้ เราเสียใจที่จะแจ้งให้ท่านทราบว่า {{2}} ขออภัยในความไม่สะดวกที่เกิดขึ้น"
  • เรามีอัพเดตเกี่ยวกับบัตรขอรับความช่วยเหลือของท่าน โปรดตอบกลับ หากท่านยังต้องการความช่วยเหลือ"