在 Twilio 通话中记录多个用户回答 [英] Recording multiple user answers in Twilio call

查看:26
本文介绍了在 Twilio 通话中记录多个用户回答的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Twilio 构建交互式语音助手.我的目标是录制部分对话,处理录制的音频和

I am building an Interactive Voice Assistant using Twilio. My goal is to record parts of the conversation, process the recorded audio and

这是/voice webhook 的答案(将收到 Twilio 的电话)

This is the answer to the /voice webhook (the one will receive Twilio's call)

<Response>
    <Play>./welcome</Play>
    <Record maxLength="10" action="/processing" recordingStatusCallback="/getRecording"></Record>
</Response>

处理音频并提供答案可能需要很长时间,所以我在/processing 的末尾添加了一个暂停:

Processing the audio and providing an answer may take a long time, so I added a Pause at the end of /processing:

<Response>
    <Play>./ok</Play>
    <Pause length="10"></Pause>
</Response>

这是完成/getRecording 后的答案

This is the answer when finished with /getRecording

<Response>
    <Play>./answer</Play>
    <Record maxLength="10" action="/processing" recordingStatusCallback="/getRecording "></Record>
</Response>

/welcome、/ok 和/answer 指向相应的音频文件.

/welcome, /ok and /answer lead to corresponding audio files.

所以我能够执行所有步骤,我可以在我的日志中检查/getRecording 实际上执行到最后并且 twiml 再次发回,但是/getRecording 之后的/answer 从来没有被 Twilio 执行(和调用刚刚结束).

So I was able to execute all steps, I can check in my logs that /getRecording is actually executed to the end and the twiml sent back again, but the /answer after /getRecording is never executed by Twilio (and the call just ends).

你有什么指导吗?Twilio 是否接受同一通话中的多个录音?

Do you have any guidance for it? Does Twilio accept multiple recordings on the same call?

注意:出于某种原因,如果我使用/getrecording 作为 'action' 而不是使用recordingStatusCallback",它确实有效……但是我们不确定我们正在使用的录音是否真的生成,对吗?

Note: For some reason, if instead of using the 'recordingStatusCallback' I use /getrecording as 'action' it does work... but then we wouldn't be sure the recording we are using is really generated, right?

感谢您的帮助!

推荐答案

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

Twilio developer evangelist here.

您的 /getRecording 端点被调用,但是在调用上下文中这是一个异步 webhook.将 TwiML 返回到 recordingStatusCallback 不会影响当前调用.

Your /getRecording endpoint is called, however that is an asynchronous webhook in the context of the call. Returning TwiML to the recordingStatusCallback will not affect the current call.

相反,您应该使用 REST API 来修改调用 通过根据对记录文件的响应将其重定向到您要执行的下一个 TwiML.

Instead, you should use the REST API to modify the call by redirecting it to the next TwiML you want to execute based on the response to the recording file.

希望录音的暂停时间少于您正在使用的 10 秒,但您可能希望在 /processing 端点中添加一个循环,以便呼叫不会在您的终端上挂断呼叫者.您可以通过重定向调用者重新回到起点来做到这一点:

Hopefully the recording does take less than the 10 second pause that you are using, but you may want to add a loop into your /processing endpoint so that the call won't hang up on your caller. You can do this by redirecting the caller back to the start again:

<Response>
    <Play>./ok</Play>
    <Pause length="10"></Pause>
    <Redirect>./processing</Redirect>
</Response>

然后,当您获得录音回调时,您将呼叫者重定向到此循环之外.

Then, when you get the recording callback you redirect your caller out of this loop.

让我知道这是否有帮助.

Let me know if that helps at all.

这篇关于在 Twilio 通话中记录多个用户回答的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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