最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

网站源码admin25浏览0评论

我如何在说出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,因此通话结束。

发布评论

评论列表(0)

  1. 暂无评论