首页 > 解决方案 > addElicitSlotDirective 的奇怪行为

问题描述

我的技能发生了一些奇怪的事情。

我将错误隔离为不同的技能。

技能ID: amzn1.ask.skill.6918614f-1f20-4ea3-bad4-b2284a296938

在技​​能中,我有一个意图——HelloWorldIntent。

意图有 2 个插槽 - lala 和 bibi。

它们中的每一个的默认提示(当 Alexa 在用户回复中找不到合适的槽值时调用的提示)是:

lala-对不起,我没听懂。lala的价值是什么?

比比比比比

***自动委托界面开启

我在 Lala 插槽的 LaunchRequestHandler 中有一个 addElicitSlot 操作,

并在 HelloWorldIntentHandler 中用于 bibi 插槽。

然而,当我试图给拉拉一个价值时,

我得到了 bibi 的默认提示。

交互模型——

{
"interactionModel": {
    "languageModel": {
        "invocationName": "check it",
        "modelConfiguration": {
            "fallbackIntentSensitivity": {
                "level": "LOW"
            }
        },
        "intents": [
            {
                "name": "AMAZON.CancelIntent",
                "samples": []
            },
            {
                "name": "AMAZON.HelpIntent",
                "samples": []
            },
            {
                "name": "AMAZON.StopIntent",
                "samples": []
            },
            {
                "name": "HelloWorldIntent",
                "slots": [
                    {
                        "name": "lala",
                        "type": "AMAZON.SearchQuery"
                    },
                    {
                        "name": "bibi",
                        "type": "AMAZON.SearchQuery"
                    }
                ],
                "samples": [
                    "hello {lala}",
                    "ya {bibi}"
                ]
            },
            {
                "name": "AMAZON.NavigateHomeIntent",
                "samples": []
            },
            {
                "name": "AMAZON.FallbackIntent",
                "samples": []
            }
        ],
        "types": []
    },
    "dialog": {
        "intents": [
            {
                "name": "HelloWorldIntent",
                "confirmationRequired": false,
                "prompts": {},
                "slots": [
                    {
                        "name": "lala",
                        "type": "AMAZON.SearchQuery",
                        "confirmationRequired": false,
                        "elicitationRequired": true,
                        "prompts": {
                            "elicitation": "Elicit.Slot.716071660021.1504772685502"
                        }
                    },
                    {
                        "name": "bibi",
                        "type": "AMAZON.SearchQuery",
                        "confirmationRequired": false,
                        "elicitationRequired": true,
                        "prompts": {
                            "elicitation": "Elicit.Slot.1152666376659.1399331737295"
                        }
                    }
                ]
            }
        ],
        "delegationStrategy": "ALWAYS"
    },
    "prompts": [
        {
            "id": "Elicit.Slot.716071660021.1504772685502",
            "variations": [
                {
                    "type": "PlainText",
                    "value": "sorry, i didnt get that. what is the value of lala?"
                }
            ]
        },
        {
            "id": "Elicit.Slot.1152666376659.1399331737295",
            "variations": [
                {
                    "type": "PlainText",
                    "value": "bibibibbb"
                }
            ]
        }
    ]
}

编码-

const LaunchRequestHandler = {
canHandle(handlerInput) {
    return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
},
handle(handlerInput) {
    const speakOutput = handlerInput.t('WELCOME_MSG');

    return handlerInput.responseBuilder
        .speak(speakOutput)
        .reprompt(speakOutput)
        .addElicitSlotDirective('lala', {
                name: 'ChallengeIntent',
                confirmationStatus: 'NONE',
                slots: {}
        })
        .getResponse();
}

};

const HelloWorldIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
    },
    handle(handlerInput) {
        const lala=Alexa.getSlotValue(handlerInput.requestEnvelope, 'lala')
        const speakOutput =`yay the value is ${lala}`;

        return handlerInput.responseBuilder
            .speak(speakOutput)
            .addElicitSlotDirective('bibi', {
                name: 'ChallengeIntent',
                confirmationStatus: 'NONE',
                slots: {}
        })
            //.reprompt('add a reprompt if you want to keep the session open for the user to respond')
            .getResponse();
    }
};

Alexa 控制台中的测试

我很沮丧,请帮助我:(

我需要在八月底之前提交我的工作。

Tnx:)

标签: alexaalexa-skills-kitalexa-skillalexa-slotalexa-app

解决方案


是因为您在将新的意图对象传递给 addElicitSlotDirective 时正在重置意图吗?尝试传递现有意图。

handlerInput.requestEnvelope.request.intent
        .speak(speakOutput)
        .addElicitSlotDirective('bibi', handlerInput.requestEnvelope.request.intent)

推荐阅读