Using the Messages API Custom Object for Advanced Templates with WhatsApp Using the Messages API Custom Object for Advanced Templates with WhatsApp

Using the Messages API Custom Object for Advanced Templates with WhatsApp

Nexmo Support

Objective

Sending messages using advanced templates with the Messages API custom object.

Applies To

  • WhatsApp
  • Messages API
  • Custom Object

Procedure

To send using more advanced WhatsApp Templates, like WhatsApp Media Message Templates or templates using a link style button, you will need to use the Messages API custom object. The custom object takes a partial section of the original WhatsApp API request and sends it directly through to WhatsApp. In our developer documentation, we provide examples of how you can do this. Something to be aware of is that WhatsApp has slightly different parameter validation than the native Vonage API. Therefore, your parameter variables may have to be different. This can cause message failures. To prevent this, we're keeping a list of the differences which may be missed below.

When stating the language code for a template in a request body in our native API you would use a hyphen to link the language and country ("en-GB" for example). However, when using the custom object, an underscore should be used instead of a hyphen to link the language and country. Therefore, in your request "en-GB" would instead be "en_GB".

"whatsapp": { "policy": "deterministic", "locale": "en-GB" }

So the above example would become the following when using the custom object.

"language": { "policy": "deterministic", "code": "en_GB" }

Also, URL is changed to link.

"image": { "url": "'$IMAGE_URL'", "caption": "'$IMAGE_CAPTION'" }

So the above example would become the following when using the custom object.

"image": { "link": "'$HEADER_IMAGE_URL'" }

Additional Information

For more information, see our developer documentation on sending a WhatsApp Media Message Template.