Phiên bản API Đồ thị

Messenger Business Template

Đọc

Messenger schema for business message templates used for business messaging

Ví dụ

Graph API Explorer
GET /v25.0/{messenger-business-template-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{messenger-business-template-id}',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{messenger-business-template-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{messenger-business-template-id}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{messenger-business-template-id}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
Nếu bạn muốn tìm hiểu cách sử dụng API Đồ thị, hãy đọc Hướng dẫn sử dụng API Đồ thị của chúng tôi.

Thông số

Điểm cuối này không có bất kỳ thông số nào.

Trường

Trường thông tinMô tả
id
numeric string

The ID for the business template

category
enum

The business template category

components
list<MessengerBusinessTemplateWhatsAppHSMComponentGet>

The components included in this template

creation_time
integer

Creation time of the template

language
string

The languages in which this template is available

language_count
integer

The number of languages this template

last_updated_time
datetime

The time at which this template was last updated

library_template_name
string

The name of the template library that this template belongs

name
string

The name of this template

parameter_format
enum

parameter_format

rejected_reason
enum

The reason this template was rejected

rejection_reasons
MessengerBusinessTemplateWhatsAppBusinessHSMRejectionReasons

The reasons this template was rejected

specific_rejection_reasons
MessengerBusinessTemplateWhatsAppBusinessHSMSpecificRejectionReasons

The specific reasons this template was rejected

status
enum

The status of this template

Mã lỗi

LỗiMô tả
100Invalid parameter

Tạo

Bạn có thể tạo yêu cầu POST đến cạnh message_templates từ các đường dẫn sau:
Khi đăng lên cạnh này, hệ thống sẽ tạo a MessengerBusinessTemplate.

Thông số

Thông sốMô tả
category
enum {UTILITY}

Required. The category of the template.

Bắt buộc
components
array<JSON object>

An array of objects to be included in the message. Can include the header, body, and buttons (phone number, postback, URL).

type
enum {HEADER, BODY, BUTTONS}

Component type.

Bắt buộc
format
enum {TEXT, IMAGE}

Component format.

text
string

Required for components with type HEADER,BODY


Component text.

buttons
array<JSON object>

Button components to be used in the template.

type
enum {QUICK_REPLY, URL, PHONE_NUMBER, OTP, MPM, CATALOG, FLOW, VOICE_CALL, VIDEO_CALL, POSTBACK, BOOKING_STATUS, PAYMENT_REQUEST, REQUEST_CONTACT_INFO}

type

Bắt buộc
text
string

text

url
URI

url

phone_number
phone number string

phone_number

example
array<string>

example

payload
string

payload

example
JSON object

Placeholder examples. Templates will not be approved without examples.

header_text
array<string>

header_text

body_text
array<array<string>>

body_text

header_handle
array<string>

header_handle

header_text_named_params
array<JSON object>

header_text_named_params

param_name
string

param_name

Bắt buộc
example
string

example

Bắt buộc
body_text_named_params
array<JSON object>

body_text_named_params

param_name
string

param_name

Bắt buộc
example
string

example

Bắt buộc
language
string

The language of the message. For example, en_US.

Bắt buộc
library_template_button_inputs
array<JSON object>

An array of objects that define the type of button and it's contents and actions.

type
enum {QUICK_REPLY, URL, PHONE_NUMBER, OTP, MPM, CATALOG, FLOW, VOICE_CALL, VIDEO_CALL, POSTBACK, BOOKING_STATUS, PAYMENT_REQUEST, REQUEST_CONTACT_INFO}

type

Bắt buộc
phone_number
string

phone_number

url
JSON object

url

base_url
string

base_url

Bắt buộc
url_suffix_example
string

url_suffix_example

library_template_name
string

The name of the library the template belongs to.

name
string

The name of the template.

Bắt buộc

Kiểu trả về

Điểm cuối này hỗ trợ đọc sau khi ghi và sẽ đọc nút mà bạn đã đăng vào đó.
Struct {
id: numeric string,
status: enum,
category: enum,
rejection_reason: enum,
specific_rejection_reason: enum,
}

Mã lỗi

LỗiMô tả
200Permissions error
100Invalid parameter

Cập nhật

Bạn có thể cập nhật a MessengerBusinessTemplate bằng cách thực hiện yêu cầu POST đến /{messenger_business_template_id}.

Thông số

Thông sốMô tả
components
array<JSON object>

Update the components in this template

type
enum {HEADER, BODY, BUTTONS}

Component type.

Bắt buộc
format
enum {TEXT, IMAGE}

Component format.

text
string

Required for components with type HEADER,BODY


Component text.

buttons
array<JSON object>

Button components to be used in the template.

type
enum {QUICK_REPLY, URL, PHONE_NUMBER, OTP, MPM, CATALOG, FLOW, VOICE_CALL, VIDEO_CALL, POSTBACK, BOOKING_STATUS, PAYMENT_REQUEST, REQUEST_CONTACT_INFO}

type

Bắt buộc
text
string

text

url
URI

url

phone_number
phone number string

phone_number

example
array<string>

example

payload
string

payload

example
JSON object

Placeholder examples. Templates will not be approved without examples.

header_text
array<string>

header_text

body_text
array<array<string>>

body_text

header_handle
array<string>

header_handle

header_text_named_params
array<JSON object>

header_text_named_params

param_name
string

param_name

Bắt buộc
example
string

example

Bắt buộc
body_text_named_params
array<JSON object>

body_text_named_params

param_name
string

param_name

Bắt buộc
example
string

example

Bắt buộc

Kiểu trả về

Điểm cuối này hỗ trợ đọc sau khi ghi và sẽ đọc nút mà bạn đã đăng vào đó.
Struct {
success: bool,
status: enum,
rejection_reason: enum,
specific_rejection_reason: enum,
}

Mã lỗi

LỗiMô tả
100Invalid parameter

Xóa

Bạn có thể hủy liên kết a MessengerBusinessTemplate khỏi a Page bằng cách thực hiện yêu cầu DELETE đến /{page_id}/message_templates.

Thông số

Thông sốMô tả
name
string

The name of the template to be deleted in all languages, if no template_id is provided.

Bắt buộc
template_id
numeric string

Optional. Limits the deletion of template to the template_id provided.

Kiểu trả về

Struct {
success: bool,
}

Mã lỗi

LỗiMô tả
200Permissions error