python – flask-ask slot始终映射到None

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

我有一个intents架构,如下所示:

{
    "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’传递.我是否在意图模式或代码中错误地传递此插槽?

谢谢

嘿哥们跟随你的问题的解决方案:

@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))

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

相关文章
相关标签/搜索