Twilio Flow 使用内容模板 SID 发送并等待回复:deliveryFailure

问题描述 投票:0回答:1

我一直在 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 twilio-studio
1个回答
0
投票

联系出色的 Twilio 支持团队后,他们指出了我的流程的问题。当通过 REST API 触发 Flow 的执行时,我这边最终犯了一个错误。为了使发送并等待回复小部件正常工作,您需要:

  1. 与号码及其 ID 关联的消息服务:
    MG32xxxxxxxxxxxxx

  1. 在消息服务的集成区域下的传入消息部分中,选择发送 Webhook 并粘贴流的 Webhook URL(您可以从流的触发器小组件中获取此 URL):

  1. 在发送并等待回复小组件中,您需要将 Send message from 参数更改为 MessagingServiceSID:

因此,在通过 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 中使用相同小部件的人有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.