0
Follow
2
View

How to send the components in whatsapp cloud api?

dzfu123 注册会员
2023-01-13 08:45

First of all, the template is a pre-defined template, created by the Whatsapp business API team. If you need to send parameters, you have to create a template with variables in its body like

URL - {{1}}

Then pass parameter like this,

 var data = JSON.stringify({
"messaging_product": "whatsapp",
"to": number,
"type": "template",
"template": {
  "name": "template_name",
  "language": {
    "code": "language_code"
  },
  "components": [
    {
        "type": "body",
        "parameters": [{
            "type": "text",
            "text":"https://www.whatsapp.com"
        }]
    }],
}});

Your output message will be URL - https://www.whatsapp.com

dzkhswz 注册会员
2023-01-13 08:45

From "Sarkar's Answer above,

{
  "messaging_product": "whatsapp",
  "to": 123456789,
  "type": "template",
  "template": {
    "name": "random name",
    "language": {
      "code": "en_Us"
    },
    "components": [
      {
        "type": "body",
        "parameters": [
          {
            "type": "text"
          },
          {
            "type": "text"
          },
          {
            "type": "text",
            "text": 123456789
          }
        ]
      }
    ]
  }
}