转发“发送并等待回复"到不同的电话号码 [英] Forward the "Send and Wait for Reply" to a different phone number

查看:27
本文介绍了转发“发送并等待回复"到不同的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个名为Google LA"的工作室流程;这是通过 Rest API 触发的.这个流有一个发送和等待回复,所以我们把这个流挂到当有消息进来时"因此,当客户对服务评分 1 到 5 星时,它将遵循其余流程.现在,在发送和等待回复中,我们希望将客户的回复转发到我们的主要业务电话号码以进行跟踪/记录,这样我们就可以解决他们的问题,将我们评为 1 到 3 星.这是我们的设置:

We have a studio flow called "Google LA" that's triggered via Rest API. This flow has a Send and Wait for Reply so we hook this flow to "When a message comes in" so it will follow the rest of the flow when customer rates the service 1 to 5 stars. Now, within the Send and Wait for Reply, we want the customer's reply be forwarded to our main business phone number for tracking/recording purposes and so we can address their issues for rating us 1 to 3 stars. Here's our setup:

这就是我们想要的:

为 philnash 建议而

Edited for philnash suggestion:

我使用以下代码在 Twilio 中创建了一个函数:

I created a function in Twilio with this code:

exports.handler = function(context, event, callback) {

    const accountSid = context.ACCOUNT_SID;
    const authToken = context.AUTH_TOKEN;
    const client = require('twilio')(accountSid, authToken);

client.messages
  .create({
     body: widgets.negative1_3.inbound.Body,
     from: '+12132779513',
     to: '+12133885256'
   })
  .then(message => console.log(message.sid));
  

};

但是,它没有发送任何内容或客户回复.我将negative1-3 小部件重命名为negative1_3 并发布了工作室流程.

However, it did not send anything or the customer response. I renamed the negative1-3 widget to negative1_3 and published the studio flow.

我尝试更改 body: 'Hello' 以确保我的函数正常工作,是的.在到达 first_question 后,我收到了你好"短信到我验证的来电显示电话号码 ->check_response ->否定1_3.

I tried changing the body: 'Hello' to make sure that my function works, and yes. I received the 'Hello' sms to my verified caller ID phone number after it reaches the first_question -> check_response -> negative1_3.

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

您不一定需要在此处转发消息.您可以使用消息中所需的所有数据对您自己的服务进行 API 调用,这样您就可以以这种方式存储信息并对其做出反应.

You don't necessarily need to forward the message here. You can make an API call to your own service with all the data you need from the message, so you can store and react to the information that way.

为此,您需要添加一个 HTTP 请求小部件运行函数小部件 在发送之后和等待回复小部件.在这些小部件中,您可以使用 液体标签.您可以在 文档中了解如何调用变量发送和等待回复小部件.对于您的小部件,您应该能够通过参考:

To do so you will want to add either an HTTP Request widget or a Run Function widget after the Send and Wait For Reply widget. Within those widgets, you can access the reply from the Send And Wait For Reply widget using liquid tags. You can see how to call on the variables in the docs for the Send and Wait For Reply widget. In the case of your widget, you should be able to get the body of the reply by referring to:

widgets.negative1-3.inbound.Body

(虽然我不确定negative1-3"这个名字是如何工作的,所以你可以试试widgets[negative1-3"],或者用下划线重命名这个widget.)

(Although I am not sure how the name "negative1-3" will work, so you might try widgets["negative1-3"] instead, or rename the widget with underscores.)

使用入站消息的正文以及发件人编号,您可以使用 HTTP 请求小部件或运行功能小部件将数据发送到您自己的应用程序.

Using the body of the inbound message, as well as the from number, you can send the data to your own application with the HTTP request widget or with a Run Function widget.

编辑

您的函数只能访问您在函数小部件配置中设置的参数.然后您可以在 event 对象中访问这些参数.您还需要在使用 callback 函数成功发送消息后返回.另一个提示,您不需要实例化您自己的客户端,您可以从 context 中获取它.像这样:

Your function can only access parameters that you set in the function widget config. You can then access those parameters in the event object. You also need to return once the message is sent successfully using the callback function. One other tip, you don't need to instantiate your own client, you can get it from the context. Like so:

exports.handler = function(context, event, callback) {

  const client = context.getTwilioClient();

  client.messages
    .create({
       body: event.Body,
       from: '+12132779513',
       to: '+12133885256'
     })
    .then(message => {
      console.log(message.sid);
      callback(null, "OK");
    })
    .catch(error => callback(error));
};

这篇关于转发“发送并等待回复"到不同的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆