Product Template

Product template is only available on Graph API v8.0+

The product template is a structured message that can be used to render products that have been uploaded to Facebook catalog. Product details (image, title, price) will automatically be pulled from the product catalog.

Contents

Template Payload

"payload": {
  "template_type":"product",
  "elements":[
     {
        "id":<PRODUCT_ID>
      },
    ]
  }

product_ids can be obtained via Catalog API or via Facebook Commerce Manager. Product template only supports product_ids owned by the same page.

The Messenger Platform supports the sending of a horizontally scrollable carousel of product templates.

To create a scrollable carousel, include up to 10 products in the elements array of the payload.

"payload": {
  "template_type":"product",
  "elements":[
    {
        "id":<PRODUCT_ID_1>
    },
    {
        "id":<PRODUCT_ID_2>
    }
    ...
  ]
}

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "message":{
    "attachment":{
      "type":"template",
        "payload": {
          "template_type": "product",
          "elements": [
            {
              "id": "<PRODUCT_ID_1>"
            },
            {
              "id": "<PRODUCT_ID_2>"
            }
         ]
      }
    }
  }
}' "https://graph.facebook.com/v8.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Example Response

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

Error Codes

Code Subcode Message

100

2018320

Invalid product id. See Product Template

100

2018328

Product template is not supported below version 8. Use api version 8 or higher to use product templates. See Product Template

For other errors returned by the Send API, see error code