预定义的插槽如何返回分辨率?

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

我正在为Alexa构建一个简单的Guess Who技能游戏。我现在有两个意图:GenderIntent和HairColorIntent。

GenderIntent有一个自定义插槽,用于处理性别和相关的同义词,例如将“ boy”和“ man”映射到“ Male”。这很好。它返回插槽内的分辨率。正是我需要的。

HairColorIntent具有预定义的Amazon插槽AMAZON.Color。这不起作用,因为无论提供什么颜色,它都永远不会返回分辨率。

这是我的GenderIntent和HairColorIntent模型:

{
    "name": "GenderIntent",
    "samples": [
        "are you a {Gender}"
    ],
    "slots": [
        {
            "name": "Gender",
            "type": "GENDER_TYPES",
            "samples": []
        }
    ]
},
{
    "name": "HairColorIntent",
    "samples": [
        "is your hair {HairColor}",
        "do you have {HairColor} hair"
    ],
    "slots": [
        {
            "name": "HairColor",
            "type": "AMAZON.Color"
        }
    ]
}

GenderIntent返回具有分辨率的以下广告位:

{
    "Gender": {
        "name": "Gender",
        "value": "male",
        "resolutions": {
            "resolutionsPerAuthority": [
                {
                    "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.2ed972f4-1c5a-4cc1-8fd7-3f440f5b8968.GENDER_TYPES",
                    "status": {
                        "code": "ER_SUCCESS_MATCH"
                    },
                    "values": [
                        {
                            "value": {
                                "name": "Male",
                                "id": "63889cfb9d3cbe05d1bd2be5cc9953fd"
                            }
                        }
                    ]
                }
            ]
        },
        "confirmationStatus": "NONE",
        "source": "USER"
    }
}

[HairColorIntent返回以下值,没有分辨率:

{
    "HairColor": {
        "name": "HairColor",
        "value": "brown",
        "confirmationStatus": "NONE",
        "source": "USER"
    }
}

我希望HairColorIntent的HairColor插槽返回分辨率。我在做什么错?

alexa alexa-skills-kit alexa-skill alexa-slot
1个回答
1
投票

仅当您在广告位类型中使用同义词时,才会返回解决方案。

不完全确定如何在代码中处理它,例如Node.js将是:handlerInput.requestEnvelope.request.intent.slots.Gender.resolutions.resolutionPerAuthority[0].values[0].value.name

如果您不使用同义词(例如对于HairColor插槽),则只需通过handlerInput.requestEnvelope.request.intent.slots.HairColor.value即可获取值>

使用预定义的广告位类型,该代码可以很好地与您的代码配合使用。如果您希望自定义插槽类型也返回分辨率,而不管您是否实际使用同义词,则始终可以简单地将值作为同义词给出,它应该返回完整的分辨率树。

希望能回答您的问题。

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