AMAZON.FallbackIntent无法正常工作Ask-SDK:2.0.10

时间:2019-02-18 12:10:38

标签: node.js amazon-web-services alexa fallback ask-cli

我正在尝试使用Amazon内置功能对我的Custom Alexa技能进行越界查询。 Alexa可以使用“ AMAZON.FallbackIntent”来实现,我在这里找到了基本设置: https://developer.amazon.com/it/blogs/alexa/post/f6bb7c54-de0d-4abe-98c3-cf3fc75c32f8/how-to-add-fallbackintent-handling-to-your-alexa-skill

此功能现已在所有“ en”语言环境中可用,无论如何,经过无数次尝试,我已经按照以下相同的结构设置了“ en-GB.json”和“ en-US.json”:

HINSTANCE

除了回退之一,所有内置意图都可以正常工作。 这是index.js片段中的示例技巧:

"intents": [
            {
                "name": "AMAZON.FallbackIntent",
                "samples": []
            },
            {
                "name": "AMAZON.CancelIntent",
                "samples": []
            },
            {
                "name": "AMAZON.HelpIntent",
                "samples": [
                    "I don't know",
                    "What can you do",
                    "What are you capable of",
                    "What is this",
                    "help"
                ]
            },
            {
                "name": "AMAZON.StopIntent",
                "samples": []
            },

启动该技能后,该技能将执行:

  

speechText

我尝试说的是什么天气,该技能会忽略该输入,而只是执行以下操作:

  

repromptText

然后如果我再次询问天气,就会关闭技能...

我该如何针对两种英语模型进行这项工作?

1 个答案:

答案 0 :(得分:0)

在LanunchRequest处理程序中发送SpeechText之后,您的会话即将结束。在会话结束时,Alexa不知道您是在说“天气如何?”来激发自己的技能。因此不会调用您的后备处理程序。

使用withShouldEndSession(false),它将使会话保持打开状态,并且任何不正确的输入都将落入后备处理程序中。

下面的代码应该可以工作。

const LaunchRequestHandler = 
{ 
    canHandle(handlerInput) {
        const request = handlerInput.requestEnvelope.request;
        return request.type === 'LaunchRequest';
    },
    handle(handlerInput) {
        const speechText = 'Welcome to the X ' + '&' + 'Y Customer Service, my name is Natalia, how may I help you today?';
        const repromptText = 'What would you like to do? You can say HELP to get available options';

        return handlerInput.responseBuilder
        .speak(speechText)
        .withShouldEndSession(false) 
        .reprompt(repromptText)
        .getResponse();
    }
};