Alexa结束时没有响应.listen()NodeJS

问题描述 投票:0回答:1

我的技能超时错误,“请求技能的响应存在问题。”

enter image description here

如果用户在初始提示和重新提示时都没有说任何内容,我正试图以静默方式结束会话。

目前,如果用户第一次没有说什么,它就会重新启动。

如果他们在责备之后没有说什么,Alexa会说错误信息:“请求的技能响应存在问题。”

enter image description here

Lambda函数:

'use strict';
const Alexa = require('alexa-sdk');
const APP_ID = undefined; 

const handlers = {
    'LaunchRequest': function () {
        const launchMsg = "How can I help you?";
        const reprompt = "You can say, give me the weather.";

        this.response.speak( launchMsg )
            .listen( reprompt );
            // errors out here on .listen if no input
        this.emit(':responseReady');
    },
    'WeatherIntent': function () {
        this.response.speak( 'It is 100 degrees Kelvin' )
        this.emit(':responseReady');  
    }
}

exports.handler = function (event, context, callback) {
    const alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    alexa.resources = languageStrings;
    alexa.registerHandlers(handlers);
    alexa.execute();
};

尝试失败:

// this.response.speak( launchMsg ).listen( reprompt, function(){this.emit('SessionEndedRequest')} );
// this.response.speak( launchMsg ).listen( reprompt, this.emit('SessionEndedRequest') );

// this.response.speak( launchMsg ).listen( reprompt, this.response.shouldEndSession(true) );
// this.response.shouldEndSession(true).speak( launchMsg ).listen( reprompt );
// this.response..speak( launchMsg ).listen( reprompt ).shouldEndSession(true);
// this.response.speak( 'goodbye' ).listen( reprompt ).speak( launchMsg );
// this.response.speak( launchMsg ).listen( reprompt ).speak( 'goodbye' );
// this.response.speak( launchMsg ).listen( reprompt, this.emit(":tell", "goodbye") );
// this.response.speak( launchMsg ).listen( reprompt).speak('goodbye');
// this.response.speak( launchMsg ).listen( reprompt, true );
// this.response.speak.listen( reprompt, false );
// this.response.speak.listen( true, reprompt );
// this.response.speak.listen( false, reprompt );

// this.emit(':responseReady', function(){this.emit('SessionEndedRequest')});
// this.emit(':responseReady', this.emit('SessionEndedRequest') );
// this.emit(':responseReady', this.response.shouldEndSession(true));
// this.emit(':responseReady', function(){this.response.shouldEndSession(true)} );
node.js alexa alexa-skills-kit alexa-skill alexa-app
1个回答
0
投票

只需将SessionEndedRequest添加到您的处理程序对象即可。

'SessionEndedRequest': function() {
        console.log("No response from user.");
 }

请注意您的技能无法返回对SessionEndedRequest的响应。

Reference from Alexa Skills Kit Docs

© www.soinside.com 2019 - 2024. All rights reserved.