facebook graph api - WhatsApp Template Carousel: How to render a variable number of cards? - Stack Overflow

admin2025-04-18  2

I'm trying to implement a template with a carousel to send and render a variable number of cards (from 2 to 10) depending on the available information. According to Meta’s documentation (link): "It is only necessary to define two product cards upon template creation. An approved template with two product cards can be used to send up to 10 cards in a template message."

However, when defining the template with 2 cards and sending more than 2 in the message, only the initially defined 2 cards are rendered, and the additional ones are not displayed.


Steps followed to test this:

Step 1 - Defined Template

I created a basic carousel template with two cards.

{
  "name": "carousel_test_v3",
  "language": "es_AR",
  "category": "MARKETING",
  "components": [
    {
      "type": "BODY",
      "text": "Template para probar cantidad dinámica de cards"
    },
    {
      "type": "CAROUSEL",
      "cards": [
        {
          "components": [
            {
              "type": "HEADER",
              "format": "IMAGE",
              "example": {
                "header_handle": [
                  ";
                ]
              }
            },
            {
              "type": "BODY",
              "text": "{{1}} Este es el body del template",
              "example": {
                "body_text": [
                  [
                    "$1.905.062"
                  ]
                ]
              }
            },
            {
              "type": "BUTTONS",
              "buttons": [
                {
                  "type": "QUICK_REPLY",
                  "text": "Ver más"
                }
              ]
            }
          ]
        },
        {
          "components": [
            {
              "type": "HEADER",
              "format": "IMAGE",
              "example": {
                "header_handle": [
                  ";
                ]
              }
            },
            {
              "type": "BODY",
              "text": "{{1}} Este es el body del template",
              "example": {
                "body_text": [
                  [
                    "$2.305.012"
                  ]
                ]
              }
            },
            {
              "type": "BUTTONS",
              "buttons": [
                {
                  "type": "QUICK_REPLY",
                  "text": "Ver más"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Step 2 - Approved Template

Verified that the template is approved in business.facebook.

Step 3 - Sending a Message with 3 Cards

Sent a template message defining 3 cards in the carousel using facebook Graph API .0//messages

{
  "messaging_product": "whatsapp",
  "to": "+*************",
  "type": "template",
  "template": {
    "name": "carousel_test_v3",
    "language": {
      "code": "es_AR"
    },
        "components": [
            {
                "type": "BODY",
                "parameters": []
            },
            {
                "type": "CAROUSEL",
                "index": 1,
                "cards": [
                    {
                        "card_index": 0,
                        "components": [
                            ...
                        ]
                    },
                    {
                        "card_index": 1,
                        "components": [
                            ...
                        ]
                    },
                    {
                        "card_index": 2,
                        "components": [
                            ...
                        ]
                    }
                ]
            }
        ]
    }
}

Step 4 - Result

Verified that we are only receiving 2 cards, even though the message we sent contained 3. Result image

I'm trying to implement a template with a carousel to send and render a variable number of cards (from 2 to 10) depending on the available information. According to Meta’s documentation (link): "It is only necessary to define two product cards upon template creation. An approved template with two product cards can be used to send up to 10 cards in a template message."

However, when defining the template with 2 cards and sending more than 2 in the message, only the initially defined 2 cards are rendered, and the additional ones are not displayed.


Steps followed to test this:

Step 1 - Defined Template

I created a basic carousel template with two cards.

{
  "name": "carousel_test_v3",
  "language": "es_AR",
  "category": "MARKETING",
  "components": [
    {
      "type": "BODY",
      "text": "Template para probar cantidad dinámica de cards"
    },
    {
      "type": "CAROUSEL",
      "cards": [
        {
          "components": [
            {
              "type": "HEADER",
              "format": "IMAGE",
              "example": {
                "header_handle": [
                  "https://img.com"
                ]
              }
            },
            {
              "type": "BODY",
              "text": "{{1}} Este es el body del template",
              "example": {
                "body_text": [
                  [
                    "$1.905.062"
                  ]
                ]
              }
            },
            {
              "type": "BUTTONS",
              "buttons": [
                {
                  "type": "QUICK_REPLY",
                  "text": "Ver más"
                }
              ]
            }
          ]
        },
        {
          "components": [
            {
              "type": "HEADER",
              "format": "IMAGE",
              "example": {
                "header_handle": [
                  "https://img.com"
                ]
              }
            },
            {
              "type": "BODY",
              "text": "{{1}} Este es el body del template",
              "example": {
                "body_text": [
                  [
                    "$2.305.012"
                  ]
                ]
              }
            },
            {
              "type": "BUTTONS",
              "buttons": [
                {
                  "type": "QUICK_REPLY",
                  "text": "Ver más"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Step 2 - Approved Template

Verified that the template is approved in business.facebook.com.

Step 3 - Sending a Message with 3 Cards

Sent a template message defining 3 cards in the carousel using facebook Graph API https://graph.facebook.com/v21.0//messages

{
  "messaging_product": "whatsapp",
  "to": "+*************",
  "type": "template",
  "template": {
    "name": "carousel_test_v3",
    "language": {
      "code": "es_AR"
    },
        "components": [
            {
                "type": "BODY",
                "parameters": []
            },
            {
                "type": "CAROUSEL",
                "index": 1,
                "cards": [
                    {
                        "card_index": 0,
                        "components": [
                            ...
                        ]
                    },
                    {
                        "card_index": 1,
                        "components": [
                            ...
                        ]
                    },
                    {
                        "card_index": 2,
                        "components": [
                            ...
                        ]
                    }
                ]
            }
        ]
    }
}

Step 4 - Result

Verified that we are only receiving 2 cards, even though the message we sent contained 3. Result image

Share Improve this question asked Jan 29 at 14:46 Candela RouauxCandela Rouaux 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

according to the documentation, you can send up to 10 product carousel cards not media carousel cards

转载请注明原文地址:http://anycun.com/QandA/1744959231a90045.html