Search code examples
phpurlbuttondynamicwhatsapp

whatsapp api , dynamic url button ,parameter missing


I'm trying to use a template containing a dynamic URL button, but I keep getting the following error:

{
    "error":{
        "message":"(#131008) Required parameter is missing",
        "type":"OAuthException",
        "code":131008,
        "error_data":{
            "messaging_product":"whatsapp",
            "details":"buttons:utton at index 0 of type Url requires aparameter"
        },
        "fbtrace_id":"A5zKyCl8YbQvpCIT7mgmgtC"
    }
}

What am I missing? I'm using PHP curl to send the message. Sending the hello_world default template with no parameters works fine.

This is the query I use:

{
  "messaging_product": "whatsapp",
  "to": "001555444555",
  "type": "template",
  "template": {
    "name": "invitation",
    "language": {
      "code": "he"
    }
  },
  "components": [
    {
      "type": "body"
    },
    {
      "type": "button",
      "sub_type": "url",
      "index": 0,
      "parameters": [
        {
          "type": "text",
          "text": "1234567"
        }
      ]
    }
  ]
}


Solution

  • It looks like you have not read the documentation properly, I can see you have not prepared the proper request object,

    https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#template-object

    I don't know your template sections, but this is just a predicted request as per your request,

    • the components property should be inside the template property
    • If you don't have any parameters in the body text then no need to pass the body in the request
    {
      "messaging_product": "whatsapp",
      "to": "001555444555",
      "type": "template",
      "template": {
        "name": "invitation",
        "language": {
          "code": "he"
        },
        "components": [
          {
            "type": "button",
            "sub_type": "url",
            "index": 0,
            "parameters": [
              {
                "type": "text",
                "text": "1234567"
              }
            ]
          }
        ]
      }
    }