简体   繁体   中英

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. 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.

您应该在端点处理程序中进行处理,并在会话对象上保持状态

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM