0
這裏是我的代碼,試圖在test1中通過test2時添加更多問題,它不會重定向,它仍然會去test1,因爲event.digits
存在。如何區分數字以呼叫新功能?Twilio調用函數 - 多用戶輸入
const got = require('got');
exports.handler = function(context, event, callback) {
console.log(context);
// We can set up our initial TwiML here
let twiml = new Twilio.twiml.VoiceResponse();
let gather = twiml.gather({
input: 'dtmf',
finishOnKey: '#'
});
if (event.Digits) {
var requestPayload = event;
// The user has entered some digits to answer the question so we post to
// your API and only callback when we get the results
got.post('http://test.com/test.php?test=' + JSON.stringify(requestPayload), {
body: JSON.stringify(event),
headers: {
'accept': 'application/json'
},
json: true
})
.then(function(response) {
test(context,event,callback,twiml,gather);
})
.catch(function(error) {
// Boo, there was an error.
callback(error)
});
} else {
// The user hasn't entered anything yet, so we ask for user ID
gather.play('Please enter user ID');
callback(null, twiml);
}
};
function test2(context,event,callback,twiml,gather){
twiml.say("start recording");
callback(null, twiml);
}
function test(context,event,callback,twiml,gather){
// Check the response and ask your second question here
gather.say("Please enter your case ID and then press star to continue.");
callback(null, twiml);
var requestPayload = event;
// The user has entered some digits to answer the question so we post to
// your API and only callback when we get the results
got.post('http://test.com/test.php?test=' + JSON.stringify(requestPayload), {
body: JSON.stringify(event),
headers: {
'accept': 'application/json'
},
json: true
})
.then(function(response) {
test2(context,event,callback,twiml,gather);
})
.catch(function(error) {
// Boo, there was an error.
callback(error)
});
}
它不會重定向到test2()
函數。我的代碼有問題嗎?我需要知道如何使用函數。有什麼方法可以在單個呼叫中查找多少個用戶輸入?
謝謝... ...將檢查並讓你知道烏拉圭回合時間:)謝謝 –
錯誤說:「很抱歉,出現未知錯誤」,在回答第一個問題 –
好吧,我打碎了什麼東西,然後。我沒有自己運行這些代碼,所以恐怕要進行調試了。我給你足夠的玩嗎? – philnash