我试图通过使用不同的路由来指定在出局呼叫中收集了键盘上的用户输入之后要执行的操作,但是在twiml说出第一个路由的内容之后,它说应用程序崩溃了并结束通话。
app.post('/getCalls', (req, res) => {
const twiml = new VoiceResponse();
const gather = twiml.gather({
numDigits: '1',
action: '/for-1',
});
gather.say('Hey, this is my small twilio app, press 1 for sales. Press 2 for
support.');
twiml.redirect('/getCalls');
res.type('text/xml');
res.send(twiml.toString());
});
app.post('/for-1', (req, res) => {
const twiml = new VoiceResponse();
if(req.body.Digits) {
switch(req.body.Digits){
case '1':
twiml.say('You selected sales. Good for you!');
break;
case '2':
twiml.say('You need support. We will help!');
break;
default:
twiml.say("Sorry, I don't understand that choice.").pause();
twiml.redirect('/getCalls');
break;
}
} else{
twiml.redirect('/getCalls');
}
res.type('text/xml');
res.send(twiml.toString());
});
请问,关于用户选择选项时twiml说路线内容需要做什么的任何想法?