Alexa Skills Kit:在意图中间询问用户,然后根据用户响应在同一意图的范围内继续?



我知道标题可能令人困惑,所以我举个例子。

'GetDataIntent': function(){
var body = "";
var url = "someAPI.com";
https.get(url, (response) =>{
response.on('data', (chunk) => {
body+=chunk;
});
response.on('end', (chunk) => {
var data = JSON.parse(body);
/* Do Some Stuff */

this.emit(":ask", "Would you like more info?");
//The Concept I am trying to describe
Alexa.registerHandlers(innerHandlers);
var innerHandlers = {
'AMAZON.YesIntent': function(){
this.emit(":tell", "More info");
/* then destroy the temp handlers */
},
'AMAZON.NoIntent': function(){
this.emit(":tell", "Goodbye!");
/* Destroy the temp handlers */
}
};
}); 
});
}

从我读到的有关 ASK 的文档来看,您似乎必须在程序开始时注册处理程序,但由于显而易见的原因,我不能这样做。我希望能够制作临时处理程序,类似于我展示的方式,这样它就不会跳转到任何随机意图,而是根据用户响应保持在当前意图的范围内。

您应该在终结点处理程序中处理此问题,并在会话对象上保留状态

最新更新