[英]Alexa Skills Kit: Asking the user in the middle of an intent, and then continuing within the scope of the same intent, based on user response?
I know the title might be confusing, so I'll give an example. 我知道标题可能会造成混淆,因此我举一个例子。
'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 */
}
};
});
});
}
From the documentation I have read about ASK, it seems that you would have to register handlers at the beginning of the program, but for obvious reasons I cant do this. 从我阅读的有关ASK的文档中,您似乎必须在程序开始时注册处理程序,但是出于明显的原因,我不能这样做。 I want to be able to make temporary handlers, similar to the way I have shown, so it does not jump to any random intent, but stays within the scope of the current intent, based on user response. 我希望能够像我展示的那样制作临时处理程序,因此它不会跳转到任何随机意图,而是基于用户响应而处于当前意图的范围之内。
您应该在端点处理程序中进行处理,并在会话对象上保持状态
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.