使用node.js后如何再次收集
我是新来的。我创建了一个简单的程序来收集一些输入,然后说些什么,我在node.js中编写了我的程序。我可以知道在执行完“/命令”后如何再次请求音频输入(目前电话将被转接): 要保持呼叫(持续的客户对话框),请使用Twilio标记语言(TwiML)继续响应。最好的通用文档是 您可以处理使用node.js后如何再次收集,node.js,twilio,Node.js,Twilio,我是新来的。我创建了一个简单的程序来收集一些输入,然后说些什么,我在node.js中编写了我的程序。我可以知道在执行完“/命令”后如何再次请求音频输入(目前电话将被转接): 要保持呼叫(持续的客户对话框),请使用Twilio标记语言(TwiML)继续响应。最好的通用文档是 您可以处理的结果,然后将处理到更多TwiML。目前,您只是通过动词读取SpeechResult,然后不再提供TwiML,因此通话结束。要保持通话(持续的客户对话),请继续使用Twilio标记语言(TwiML)进行响应。最好的通
的结果,然后将
处理到更多TwiML。目前,您只是通过
动词读取SpeechResult,然后不再提供TwiML,因此通话结束。要保持通话(持续的客户对话),请继续使用Twilio标记语言(TwiML)进行响应。最好的通用文档是
您可以处理
的结果,然后将
处理到更多TwiML。目前,您只是通过
动词读取SpeechResult,然后不再提供TwiML,因此通话结束
// 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());
});