Search code examples
pythonalexa-skills-kitflask-ask

Not getting slot values in flask-ask from alexa skills


When ever i am calling my service from alexa i am getting None not the values of slot which i should get. i have intent schema like :

{
"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": []
    }
}

}

my Flask-Ask code where i want to import the city but when ever i run my code i get None on the place of a city name.

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

Solution

  • You need to use convert rather than mapping it should work nicely please try

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