【问题标题】:Support of Interactive Messages and Location Messages in Twilio Studio在 Twilio Studio 中支持交互式消息和位置消息
【发布时间】:2023-01-17 16:58:14
【问题描述】:

我搜索了 Twilio Studio 的文档,但没有找到有关发送 Interactive Messages 或从位置消息接收纬度和经度的任何信息。对于后者,我发现非官方提到了 Twilio Studio 不支持位置信息。

Twilio Studio 当前是否支持交互式消息和位置信息?如果没有,是否有实施支持他们的计划?当前是否有解决方法,特别是关于获取位置信息?

非常感谢。

我尝试过哪些解决方法

在位置信息的情况下:

我尝试在 Studio 中运行调用 Twilio 函数,该函数接收位置并在回复中回显坐标。连接到 Whatsapp 沙盒的函数本身有效,但在 Twilio Flow 内部调用时无效。

我假设函数在从 Studio Flow 调用时无法访问事件参数。


exports.handler = function(context, event, callback) {
  let twiml = new Twilio.twiml.MessagingResponse();

  if (!event.Latitude || !event.Longitude) {
    twiml.message("Send a location.");
    callback(null, twiml);
  } else {
    const location = {
      lat: event.Latitude,
      lon: event.Longitude
    };
    twiml.message(
      `${location.lat}, ${location.lon}`
    );
    callback(null, twiml);
  }
};

(代码最初取自this教程。)

编辑:

这很尴尬,但我想出了如何访问纬度和经度信息。

只需访问以下 Liquid 变量

    {{widgets.send_and_reply_1.inbound.Longitude}} 
    {{widgets.send_and_reply_1.inbound.Latitude}}

(通过正确节点的名称更改 send_and_reply。)

【问题讨论】:

    标签: javascript twilio twilio-studio


    【解决方案1】:

    您已经在上面回答了您的问题,但为了完成,我也想加两分钱。

    是的,可以通过 Twilio 平台在 WhatsApp 中发送位置、格式化和交互式消息。这是指向包含所有功能的相应 docs page 的链接。请注意,这是“WhatsApp Business API with Twilio”的文档页面,而不是 Studio,但当 Studio 处理 WhatsApp 消息流时内容仍然适用。

    const accountSid = process.env.TWILIO_ACCOUNT_SID;
    const authToken = process.env.TWILIO_AUTH_TOKEN;
    const client = require('twilio')(accountSid, authToken);
    
    client.messages
          .create({
             messagingServiceSid: 'MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
             body: 'This is one of the Twilio office locations',
             persistentAction: ['geo:37.787890,-122.391664|375 Beale St'],
             to: 'whatsapp:+15005550006'
           })
          .then(message => console.log(message.sid));
    

    还有这个关于using buttons in WhatsApp 的文档页面,其中提到了当前支持哪些消息类型。诀窍是您使用按钮创建消息模板,然后您将使用 Studio 中的普通消息正文来引用该模板。

    【讨论】:

      猜你喜欢
      • 2021-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多