我如何在说出node.js之后再次收集

编程入门 行业动态 更新时间:2024-10-17 18:26:15

我<a href=https://www.elefans.com/category/jswz/34/1771448.html style=如何在说出node.js之后再次收集"/>

我如何在说出node.js之后再次收集

我是Twilio的新手。我创建了一个简单的程序来收集一些输入,然后说些什么,然后我在node.js中编写了程序。我可以知道在执行完'/ command'之后如何再次请求音频输入(当前调用将被交出):

// Create a route that will handle Twilio webhook requests, sent as an
// HTTP POST to /voice in our application
app.post('/voice', (request, response) => {
  // Use the Twilio Node.js SDK to build an XML response
  const twiml = new VoiceResponse();

  const gather = twiml.gather({
    input: 'speech',
    speechTimeout: 'auto',
    action: '/command'
});

  gather.say({
    voice: 'alice',
}, 'How can I help');
  // Render the response as XML in reply to the webhook request
  response.type('text/xml');
  response.send(twiml.toString());
});

app.post('/command', (request, response) => {
  // Use the Twilio Node.js SDK to build an XML response
  const twiml = new VoiceResponse();
  twiml.say({
    voice: 'alice'
},request.body.SpeechResult);
  // Render the response as XML in reply to the webhook request
  response.type('text/xml');
  response.send(twiml.toString());

});
回答如下:

要保持呼叫状态(正在进行的客户对话),请继续使用Twilio标记语言(TwiML)进行响应。最好的常规文档是TwiML™ for Programmable Voice。

您可以处理<Gather>的结果,然后处理<Redirect>以处理更多的TwiML。当前,您只是通过<Say>动词阅读SpeechResult,然后不再提供TwiML,因此通话结束。

更多推荐

我如何在说出node.js之后再次收集

本文发布于:2024-05-07 16:07:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1757056.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   node   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!