我一直在 Twilio Studio 中开发一个简单的约会提醒流程,效果非常好,直到我决定使用指定模板 SID 的内容模板:
指定的内容模板已获得批准,并且在使用自定义消息而不是使用内容模板之前,流程可以通过 Whatsapp 正确运行。
在流日志中,启动具有以下输出的流时出现了 DeliveryFailure 错误:
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.
值得再次提及的是,内容模板已经发送到Meta并批准使用:
有关此事的任何指导将不胜感激,因为该错误相当模糊。
联系出色的 Twilio 支持团队后,他们指出了我的流程的问题。当通过 REST API 触发 Flow 的执行时,我这边最终犯了一个错误。为了使发送并等待回复小部件正常工作,您需要:
MG32xxxxxxxxxxxxx
:因此,在通过 API REST 触发流程执行并更改
From
参数以使用消息服务 SID 而不是数字后,它运行得非常好。我使用 PHP 来触发 Flow,所以我的代码如下所示:
<?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");
推断这一点并不容易,特别是当您刚使用 Twilio Tools 时,但希望这对在 Twilio Studio 中使用相同小部件的人有所帮助。