Twilio send&等待回复小部件

发布于 2025-02-11 06:05:59 字数 267 浏览 1 评论 0原文

我正在使用一个开始呼叫记录的传入呼叫流,在呼叫结束时询问一堆问题,收集回答:停止录制,并使用send/等待回复widget将SMS发送给呼叫者。可以预期响应,并基于传入呼叫的​​正文,它称为功能。 除了我没有收到呼叫者的回复,所有这些都可以。

  1. 我的并发呼叫设置= OFF
  2. 传入触发=传入调用

该流量与电话号码(语音)绑定在一起,

我不确定如何将答复重新回到相同的流程中。我需要将某些内容附加到电话号码的消息部分吗? 任何指导将不胜感激

I'm using an incoming call flow that starts call recording, asks a bunch of questions, gathers responses, at the end of the call: stops recording and sends a sms to caller using send/wait for reply widget. A response is expected and based on what's in the body of the incoming call, it calls a function.
All this works, except, I am not receiving a response back from the caller.

  1. My concurrent call setting =off
  2. incoming trigger = incoming call

the flow is tied to a phone number (voice)

I'm not sure how to get a reply back into the same flow. Do I need to attach something to the message section of the phone number?
Any guidance would be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野心澎湃 2025-02-18 06:05:59

工作室流程执行代表一个呼叫,一个SMS或来自其余触发器的来电触发器。当呼叫启动您的流程时,呼叫结束时将终止。

但是,您可以通过使用完成录制后调用的函数来解决此问题。然后,此功能可以使用Twilio API从呼叫中获取上下文信息,并触发相同流的REST API接口(但带有不同的触发器)。

我创建了一个类似的事情的小示例:

  1. 流是由调用触发,启动录制的,然后收集数据 “在此处输入映像”

  2. 有一个录音回调URL指向我的函数

// This is your new function. To start, set the name and path on the left.

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

  console.log(`Recording ${event.RecordingSid} state changed to ${event.RecordingStatus}.`)

  if (event.RecordingStatus === "completed") {

    const client = context.getTwilioClient();

    return client.calls(event.CallSid).fetch()
      .then(call => {
        client.studio.v2.flows(<Flow ID>)
          .executions
          .create({
            to: call.from,
            from: <YOUR NUMBER>,
            parameters: {
              RecordingUrl: event.RecordingUrl,
            }
          })
          .then(execution => {
            console.log(`Triggered execution ${execution.sid}`)
            return callback(null, "OK");
          });
      })
      .catch(callback)
  }

  return callback(null, "OK");
};

您可以在控制台中找到流的ID(或者单击根元素并检查Flow配置):

  1. REST API触发第二个流程执行,该操作读取参数并使用它们发送短信: “

A Studio flow execution represents one call, one SMS, or the incoming call trigger from the REST Trigger. As the call initiates your flow, it will terminate when the call ends.

But you can work around this by using a function that gets invoked when the recording is done. This function can then use the Twilio APIs to fetch contextual information from the call and trigger the REST API interface of the same flow (but with a different trigger).

I created a small example that does something similar:

  1. The flow is triggered by a call, starts a recording, and gathers dataenter image description here

  2. There is a recording callback URL that points to my function

// This is your new function. To start, set the name and path on the left.

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

  console.log(`Recording ${event.RecordingSid} state changed to ${event.RecordingStatus}.`)

  if (event.RecordingStatus === "completed") {

    const client = context.getTwilioClient();

    return client.calls(event.CallSid).fetch()
      .then(call => {
        client.studio.v2.flows(<Flow ID>)
          .executions
          .create({
            to: call.from,
            from: <YOUR NUMBER>,
            parameters: {
              RecordingUrl: event.RecordingUrl,
            }
          })
          .then(execution => {
            console.log(`Triggered execution ${execution.sid}`)
            return callback(null, "OK");
          });
      })
      .catch(callback)
  }

  return callback(null, "OK");
};

You can find the ID of your flow in the console (or when you click on the root element and check the Flow Configuration):
enter image description here

  1. The REST API triggers a second flow execution that reads the parameter and uses them to send a text message: enter image description here
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文