How to check and get Alexa slot value with Python ask sdk

In your handler, you can do something like this:

slots = handler_input.request_envelope.request.intent.slots
city = slots['city']
if city.value:
    # take me down to the paradise city
else:
    # this city was not built on rock'n'roll

slots is a dictionary of str: Slot values, see the source code for Intent and Slot for more details.


Per the docs found here, you could do something like this:

import ask_sdk_core.utils as ask_utils
slot = ask_utils.request_util.get_slot(handler_input, "slot_name")
if slot.value:
    # do stuff