我正在尝试使以下流程起作用:
我遇到的问题是对主webhook处理程序和脚本处理程序的调用分离。
我有主呼叫处理程序响应第一个问题,如下所示:
<!-- [/ handler] initial response, with the first question -->
<Response>
<Say voice="alice">What is your favorite color? Press any key when done.</Say>
<Record transcribe="true" transcribeCallback="/transcript" maxLength="60"/>
</Response>
录制完成后,我们会收到对主调用处理程序的第二个请求。我还无法回答另一个问题(业务需求),因此我们以模糊的确认回答:
<!-- [/ handler] vague confirmation response
<Response>
<Say voice="alice">Got it. Give me a couple seconds to write that down.</Say>
</Response>
然后,我收到/transcript
该成绩单上的处理程序的点击,对此我做出回应:
<!-- [/transcript handler] Second question -->
<Response>
<Say voice="alice">What is the air-speed velocity of an unladen swallow? Press any key when done.</Say>
<Record transcribe="true" transcribeCallback="/transcription" maxLength="60"/>
</Response>
但是显然您不能用TWiML响应该处理程序吗?/
处理程序的第二次响应后,呼叫者被挂断。
关于如何实现这一点的任何想法?我认为我真的不能让用户在等待第二个/
处理程序请求之前默默等待...
当您收到点击时,您/transcript handler
将在请求中加上callSid
(CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
)及其他参数。
这样,callSid
您可以修改“进行中的呼叫”,以向Twilio发送请求并传递新的TwiML。
不确定您在服务器端使用哪种语言,但是在Node.js中看起来像这样:
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
client.calls('CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.update({twiml: '<Response>
<Say voice="alice">What is the air-speed velocity of an unladen swallow? Press any key when done.</Say>
<Record transcribe="true" transcribeCallback="/transcription" maxLength="60"/>
</Response>'})
.then(call => console.log(call.to));
文件:(https://www.twilio.com/docs/voice/tutorials/how-to-modify-calls-in-progress-node-js)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句