twiliowhatsapptwilio-apitwilio-programmable-chat

Migrating from whatsApp Template to Content Builder


I am migrating Twilio's WhatsApp template to their Content Builder, and after moving all the templates to the Content Template. I am not able to receive the Call to Action buttons.

For example, This is my content

template ID: HX5fc0f957dc40af96ce9ef7055a2c7b22 with the following template details

You entered: {{1}}

Do you confirm?

and body:

You entered: 789660****3871

Do you confirm?`

I am using the following code after following this doc

await twilioClient.messages.create({
  contentSid: "HX5fc0f957dc40af96ce9ef7055a2c7b22",
  body: messageBody,
  from: TWILIO_PHONE_NUMBER,
  contentVariables: JSON.stringify({
    1: '789660****3871'
  }),
  to: to,
});

In the logs, I am seeing: ## Warning - 12200 ### Schema validation warning The provided XML does not conform to the Twilio Markup XML schema. Please refer to the specific error and correct the problem.

I am not able to understand what I am doing wrong here. I am aalso sending the contentSid and contentVariables both of which were not required previously.

Any hint or possible solution to work around?


Solution

  • I believe you may be facing difficulties due to misunderstandings about the Content API's capabilities. Notably, the Content API does not support a body parameter.

    This could be the cause for not being able to send the message. Also note that you need to specify a messaging service as a sender (see section "Before Starting") when using the Content API.

    await twilioClient.messages.create({
      contentSid: "HX5fc0f957dc40af96ce9ef7055a2c7b22",
      from: TWILIO_MESSAGING_SERVICE_SID,
      contentVariables: JSON.stringify({
        1: '789660****3871'
      }),
      to: to,
    });
    

    Also, it would be worth verifying the nature of the content template you've chosen - specifically, does it inherently incorporate a Call to Action button as per your requirements? Content Editor