Skip to content

Unable to send Templates with Buttons #188

@ashuio

Description

@ashuio

When making a template request api cll to facebook the following json is used

{
  "messaging_product": "whatsapp",
  "to": "911234567890",
  "type": "template",
  "template": {
    "name": "template_name",
    "language": {
      "code": "en"
    },
    "components": [
      {
        "type": "header",
        "parameters": [
          {
            "type": "image",
            "image": {
              "link": "http://example.com/files/cover.jpg"
            }
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "phone_number",
        "index": "0",
        "parameters": [
          {
            "type": "text",
            "text": "+919876543210"
          }
        ]
      },
      {
        "type": "button",
        "sub_type": "url",
        "index": "1",
        "parameters": [
          {
            "type": "text",
            "text": "http://example.com/about"
          }
        ]
      }
    ]
  }
}

But Meta gives the following error

"(#100) Param template['components'][1]['sub_type'] must be one of {BOOKING_CONFIRMATION, CATALOG, COPY_CODE, FLOW, MPM, ORDER_DETAILS, QUICK_REPLY, REMINDER, URL, VOICE_CALL} - got \"phone_number\"."

The following JSON Works though
(Tested With Graph explorer v24.0)

{
  "messaging_product": "whatsapp",
  "to": "919876543210",
  "type": "template",
  "template": {
    "name": "template_name,
    "language": {
      "code": "en"
    },
    "components": [
      {
        "type": "header",
        "parameters": [
          {
            "type": "image",
            "image": {
              "link": "http://example.comfiles/cover.jpg"
            }
          }
        ]
      }
    ]
  }
}

@pu-raihan Thanks for the PR to add support for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions