Se actualizó este documento.
La traducción en español no está disponible todavía.
Actualización del documento en inglés: 14 de nov.
Actualización del documento en español: 15 de ene.

We are making changes to the WhatsApp Business Platform pricing model. See Pricing Updates on the WhatsApp Business Platform.

Sending Multi-Product Template Messages

This document explains how to send multi-product message (MPM) templates in template messages.

Components

MPM template messages must have:

  • a header component (only required if template uses a header variable)
  • a body component (only required if template uses a body variable)
  • a single MPM button component

Use the MPM button component to define sections and their titles that will appear when the customer taps the View items button, and to designate which products appear in each of those sections.

Request

To send an approved MPM template in a template message, send a POST request to the WhatsApp Business Phone Number > Messages endpoint. Use the POST body to define the contents of the message and to describe any variables to inject into the template itself.

Syntax

POST /<BUSINESS_PHONE_NUMBER_ID>/messages

Post Body

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "<TO>",
  "type": "template",
  "template": {
    "name": "<NAME>",
    "language": {
      "code": "<CODE>"
    },
    "components": [

      /* Header component required if template uses a header variable, otherwise omit */
      {
        "type": "header",
        "parameters": [
          {
            "type": "text",
            "text": "<HEADER_TEXT>"
          }
        ]
      },

      /* Body component required if template uses a body variable, otherwise omit */
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "<BODY_TEXT>"
          }
        ]
      },

      /* MPM button component always required */
      {
        "type": "button",
        "sub_type": "mpm",
        "index": 0,
        "parameters": [
          {
            "type": "action",
            "action": {
              "thumbnail_product_retailer_id": "<THUMBNAIL_PRODUCT_RETAILER_ID>",
              "sections": [
                {
                  "title": "<TITLE>",
                  "product_items": [
                    {
                      "product_retailer_id": "<PRODUCT_RETAILER_ID>"
                    },
                    ... // Additional item objects (up to 30)
                  ]
                },
                ... // Add section objects (up to 10)
              ]
            }
          }
        ]
      }
    ]
  }
}

Properties

PlaceholderDescriptionSample Value

<BODY_TEXT>

Required if template uses variables.


String or array of strings. Text to replace body variable(s) defined in the template.

10OFF

<CODE>

Template language and locale code.

en_US

<HEADER_TEXT>

Required if template uses a variable.


Text to replace header variable defined in the template.

Pablo

<NAME>

Template name.

abandoned_cart

<PRODUCT_RETAILER_ID>

SKU number of the item you want to appear in the section.


SKU numbers are labeled as Content ID in the Commerce Manager.


Supports up to 30 products total, across all sections.

2lc20305pt

<THUMBNAIL_PRODUCT_RETAILER_ID>

Item SKU number. Labeled as Content ID in the Commerce Manager.


The thumbnail of this item will be used as the template message's header image.

2lc20305pt

<TITLE>

Section title text.


You can define up to 10 sections.


Maximum 24 characters. Markdown is not supported.

Popular Bundles

<TO>

Customer phone number.

16505551234

Response

Upon success, the API will respond with:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "<INPUT>",
      "wa_id": "<WA_ID>"
    }
  ],
  "messages": [
    {
      "id": "<ID>"
    }
  ]
}

Response Contents

PlaceholderDescriptionSample Value

<ID>

WhatsApp message ID.

wamid.HBgLMTY1MDM4Nzk0MzkVAgARGBJDOEI3ODgxNzQzMjJBQTdEQTcA

<INPUT>

Customer WhatsApp phone number.

16505551234

<WA_ID>

Customer WhatsApp ID.

16505551234

Example

Example Request

This example sends an approved template named "abandoned_cart" and injects a variable (the customer's first name) into the template header and a discount code into the template body. It also defines two sections ("Popular Bundles" and "Premium Packages") and identifies the products (a total of 3) that should be injected into those sections.

curl 'https://graph.facebook.com/v21.0/106540352242922/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "16505551234",
  "type": "template",
  "template": {
    "name": "abandoned_cart",
    "language": {
      "code": "en_US"
    },
    "components": [
      {
        "type": "header",
        "parameters": [
          {
            "type": "text",
            "text": "Pablo"
          }
        ]
      },
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "10OFF"
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "mpm",
        "index": 0,
        "parameters": [
          {
            "type": "action",
            "action": {
              "thumbnail_product_retailer_id": "2lc20305pt",
              "sections": [
                {
                  "title": "Popular Bundles",
                  "product_items": [
                    {
                      "product_retailer_id": "2lc20305pt"
                    },
                    {
                      "product_retailer_id": "nseiw1x3ch"
                    }
                  ]
                },
                {
                  "title": "Premium Packages",
                  "product_items": [
                    {
                      "product_retailer_id": "n6k6x0y7oe"
                    }
                  ]
                }
              ]
            }
          }
        ]
      }
    ]
  }
}'

Example Response

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "16505551234",
      "wa_id": "16505551234"
    }
  ],
  "messages": [
    {
      "id": "wamid.HBgLMTY1MDM4Nzk0MzkVAgARGBJDOEI3ODgxNzQzMjJBQTdEQTcA"
    }
  ]
}