Receipt Template Reference

The receipt template allows you to send an order confirmation as a structured message. For implementation details, see Receipt Template.

Request URI

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

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"receipt",
        "recipient_name":"Stephane Crozatier",
        "order_number":"12345678902",
        "currency":"USD",
        "payment_method":"Visa 2345",        
        "order_url":"http://petersapparel.parseapp.com/order?order_id=123456",
        "timestamp":"1428444852",         
        "address":{
          "street_1":"1 Hacker Way",
          "street_2":"",
          "city":"Menlo Park",
          "postal_code":"94025",
          "state":"CA",
          "country":"US"
        },
        "summary":{
          "subtotal":75.00,
          "shipping_cost":4.95,
          "total_tax":6.19,
          "total_cost":56.14
        },
        "adjustments":[
          {
            "name":"New Customer Discount",
            "amount":20
          },
          {
            "name":"$10 Off Coupon",
            "amount":10
          }
        ],
        "elements":[
          {
            "title":"Classic White T-Shirt",
            "subtitle":"100% Soft and Luxurious Cotton",
            "quantity":2,
            "price":50,
            "currency":"USD",
            "image_url":"http://petersapparel.parseapp.com/img/whiteshirt.png"
          },
          {
            "title":"Classic Gray T-Shirt",
            "subtitle":"100% Soft and Luxurious Cotton",
            "quantity":1,
            "price":25,
            "currency":"USD",
            "image_url":"http://petersapparel.parseapp.com/img/grayshirt.png"
          }
        ]
      }
    }
  }
}' "https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Example Response

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

Properties

recipient

訊息收件人的說明。所有的要求都必須包含 idphone_numberuser_ref

屬性型別說明

recipient.id

字串

訊息收件人的 PSIDphone_numberuser_ref

recipient.phone_number

字串

選用。 收件人的電話號碼(格式為 +1(212)555-2368)。


您的 Bot 必須獲准使用顧客配對功能,才能透過此方式傳送訊息。

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

Property Type Description

template_type

String

Value must be receipt.

sharable

Boolean

Optional. Set to true to enable the native share button in Messenger for the template message. Defaults to false.

recipient_name

String

The recipient's name.

merchant_name

String

Optional. The merchant's name. If present this is shown as logo text.

order_number

String

The order number. Must be unique.

currency

String

The currency of the payment.

payment_method

String

The payment method used. Providing enough information for the customer to decipher which payment method and account they used is recommended. This can be a custom string, such as, "Visa 1234".

timestamp

String

Optional. Timestamp of the order in seconds.

elements

Array<element>

Optional. Array of a maximum of 100 element objects that describe items in the order. Sort order of the elements is not guaranteed.

address

address object

Optional. The shipping address of the order.

summary

Object

The payment summary. See summary.

adjustments

Array<adjustment>

Optional. An array of payment objects that describe payment adjustments, such as discounts.

message.attachment.payload.address

Property Type Description

street_1

String

The street address, line 1.

street_2

String

Optional. The street address, line 2.

city

String

The city name of the address.

postal_code

String

The postal code of the address.

state

String

The state abbreviation for U.S. addresses, or the region/province for non-U.S. addresses.

country

String

The two-letter country abbreviation of the address.

message.attachment.payload.summary

The property values of the summary object should be valid, well-formatted decimal numbers, using '.' (dot) as the decimal separator. Please note that most currencies only accept up to 2 decimal places.

Property Type Description

subtotal

Number

Optional. The sub-total of the order.

shipping_cost

Number

Optional. The shipping cost of the order.

total_tax

Number

Optional. The tax of the order.

total_cost

Number

The total cost of the order, including sub-total, shipping, and tax.

message.attachment.payload.adjustments

Property Type Description

name

String

Required if the adjustments array is set. Name of the adjustment.

amount

Number

Required if the adjustments array is set. The amount of the adjustment.

message.attachment.payload.elements

Property Type Description

title

String

The name to display for the item.

subtitle

String

Optional. The subtitle for the item, usually a brief item description.

quantity

Number

Optional. The quantity of the item purchased.

price

Number

The price of the item. For free items, '0' is allowed.

currency

String

Optional. The currency of the item price.

image_url

String

Optional. The URL of an image to be displayed with the item.