Twilio Flow Send and Wait for Reply using a Content template SID: deliveryFailure

182 views Asked by At

I've been working on a simple appointment reminder flow in Twilio Studio and it has worked great, until I decided to use a content template specifying the Template SID:

enter image description here

The specified content template has been approved already, and the flow was working through whatsapp properly before using a custom message rather than with the content template.

In the flow log there's a deliveryFailure error when launching the flow with the following output:

To: whatsapp:+57xxxxx
From: whatsapp:+14xxxxx
Content Sid: HX9f1xxxxxxxxxxxxxxxxxxxx
Content Variables: {"1":xxxx, "2": xxxxxxxx}
Failure sending message: A text message body or media urls must be specified.

It's worth to mention again that the content template has been already sent to Meta and it's approved to be used:

enter image description here

Any guidance on this matter will be appreciated, since the error is quite ambiguous.

1

There are 1 answers

0
Carlos Delgado On BEST ANSWER

After contacting the awesome Twilio Support Team, they pointed out the issue with my flow. It ended up being a mistake on my side when triggering the execution of the Flow via a REST API. For the Send and Wait for Reply widget to work properly you need:

  1. A Messaging Service associated with a Number and its ID: MG32xxxxxxxxxxxxx:

enter image description here

  1. In the Messaging Service, under the integration area, in the incoming messages section, select Send a Webhook and paste the webhook URL of your Flow (you can obtain this from the Trigger Widget of the Flow):

enter image description here

  1. In the Send and Wait For Reply widget you need to change the Send message from parameter to the MessagingServiceSID:

enter image description here

So after triggering the flow execution via API REST and changing the From parameter to use the Messaging Service SID instead of the number, it worked perfectly. I'm using PHP to trigger the Flow, so my code looks like this:

<?php

$to = 'whatsapp:+57xxxxxxxxx';

// Important: the $from number below should be changed to be MESSAGING_SERVICE_SID
// instead of the number that is being used in the messaging service.
// This was causing the issue!
// $from = 'whatsapp:+1xxxxxx';
$from = 'MG32xxxxxxxxxxxxxxxxxxxxxxx';

$messageData = array(
    'To' => $to,
    'From' => $from,
    'Parameters' => json_encode(array(
        'parameter1' => 'value1',
        'parameter2' => 'value2',
        'parameter3' => 'value3'
    ))
);

$flow = "FWfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

triggerFlowExecution("https://studio.twilio.com/v2/Flows/$flow/Executions");

It's not easy to deduct this, specially when you're new with the Twilio Tools, but hope this helps someone using the same widget in Twilio Studio.