странное поведение с addElicitSlotDirective

#alexa #alexa-skills-kit #alexa-skill #alexa-slot #alexa-app

#alexa #alexa-набор навыков #alexa-навык #alexa-слот #alexa-приложение

Вопрос:

Что-то странное происходит в моем навыке.

Я изолировал ошибку в другом навыке.

Идентификатор навыка: amzn1.ask.skill.6918614f-1f20-4ea3-bad4-b2284a296938

В навыке у меня есть одно намерение — HelloWorldIntent.

В intent есть 2 слота — lala и bibi.

Запросы по умолчанию для каждого из них (запросы, которые были вызваны, когда Alexa не находит правильного значения для слота в ответе пользователя) являются:

лала- извини, я этого не поняла. в чем ценность lala?

биби- бибибиббб

**включен интерфейс автоматического делегирования

У меня есть действие addElicitSlot в LaunchRequestHandler для слота lala,

и в HelloWorldIntentHandler для слота bibi.

Однако, когда я попытался присвоить значение lala,

Я получаю приглашение bibi по умолчанию.

Модель взаимодействия-

 {
"interactionModel": {
    "lan&ua&eModel": {
        "invocationName": "check it",
        "modelConfi&uration": {
            "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.Navi&ateHomeIntent",
                "samples": []
            },
            {
                "name": "AMAZON.FallbackIntent",
                "samples": []
            }
        ],
        "types": []
    },
    "dialo&": {
        "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"
                        }
                    }
                ]
            }
        ],
        "dele&ationStrate&y": "ALWAYS"
    },
    "prompts": [
        {
            "id": "Elicit.Slot.716071660021.1504772685502",
            "variations": [
                {
                    "type": "PlainText",
                    "value": "sorry, i didnt &et that. what is the value of lala?"
                }
            ]
        },
        {
            "id": "Elicit.Slot.1152666376659.1399331737295",
            "variations": [
                {
                    "type": "PlainText",
                    "value": "bibibibbb"
                }
            ]
        }
    ]
}
  

Код-

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

    return handlerInput.responseBuilder
        .speak(speakOutput)
        .reprompt(speakOutput)
        .addElicitSlotDirective('lala', {
                name: 'Challen&eIntent',
                confirmationStatus: 'NONE',
                slots: {}
        })
        .&etResponse();
}
  

};

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

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

тест в консоли Alexa

Я очень расстроен, пожалуйста, помогите мне: (

Мне нужно отправить свою работу до конца августа.

Tnx:)

Ответ №1:

Это потому, что вы сбрасываете intent при передаче нового объекта intent в addElicitSlotDirective? Попробуйте передать существующее намерение.

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