8

我的自定义意图插槽始终被识别为None.

我有一个如下所示的意图架构:

{
    "interactionModel": {
        "languageModel": {
            "invocationName": "name_of_app",
            "intents": [
                {
                    "name": "AMAZON.CancelIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.HelpIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StopIntent",
                    "samples": []
                },
                {
                    "name": "EventsIntent",
                    "slots": [
                        {
                            "name": "eventCity",
                            "type": "AMAZON.GB_CITY"
                        }
                    ],
                    "samples": [
                        "whats on in {eventCity}",
                        "whats going on in {eventCity} ",
                        "tell me what events are in {eventCity}"
                    ]
                }
            ],
            "types": []
        }
    }
}

我的代码在 python 中,使用了 flask-ask 框架。我的主要入口点如下所示:

@ask.launch
def start_skill():
    welcome_message = 'Welcome to name_of_app, what do you want?'
    return question(welcome_message)

@ask.intent('EventsIntent', mapping={'city': 'eventCity'})
def weather(city):
    return statement('you have selected {}'.format(city))

然而,即使是这个简单的例子,当输入是:

"whats on in London?"

我在亚马逊开发者控制台的测试面板中尝试过使用小写字母和有/无标点符号,但返回总是:

"you have selected None"

表示 None 作为 'eventCity' 传递。我是否在意图模式或代码中错误地传递了这个插槽?

谢谢

4

1 回答 1

0

嘿伙计,以下是您问题的解决方案:

@ask.launch
def start_skill():
    welcome_message = 'Welcome to name_of_app, what do you want?'
    return question(welcome_message)

@ask.intent('EventsIntent', convert={'eventCity': str})
def weather(eventCity):
    return statement('you have selected {}'.format(eventCity))

我也面临类似的问题,这件事解决了我的问题。

于 2018-10-11T11:05:12.400 回答