没有从 alexa 技能中获取 flask-ask 中的插槽值

Not getting slot values in flask-ask from alexa skills

每当我从 alexa 调用我的服务时,我得到的 None 不是我应该得到的插槽值。 我有这样的意图模式:

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

}

我的 Flask-Ask 代码我想导入城市但是每当我 运行 我的代码我得到 None 在城市名称的地方。

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

您需要使用转换而不是映射,它应该可以很好地工作,请尝试

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