Above, x and y will both be passed to int() and thus converted to int instances.

Flask-Ask provides convenient API constants for Amazon AMAZON.DATE, AMAZON.TIME, and AMAZON.DURATION
types exist since those are harder to build callables against. Instead of trying to define functions that work with
inputs like those in Amazon’s
documentation,
just pass the strings in the second column below:

Recover gracefully with the convert_errors context local. Import it to use it:

...fromflask_askimportstatement,question,convert_errors@ask.intent('AgeIntent',convert={'age':int})defsay_age(age):if'age'inconvert_errors:# since age failed to convert, it keeps its string# value (e.g. "?") for later interrogation.returnquestion("Can you please repeat your age?")# conversion guaranteed to have succeeded# age is an intreturnstatement("Your age is {}".format(age))

convert_errors is a dict that maps parameter names to the Exceptions raised during
conversion. When writing your own converters, raise Exceptions on failure, so
they work with convert_errors:

defto_direction_const(s):ifs.lower()notin['left','right']raiseException("must be left or right")returnLEFTifs=='left'elseRIGHT@ask.intent('TurnIntent',convert={'direction':to_direction_const})defturn(direction):# do something with direction...

An Alexa
request payload
has four top-level elements: session, context, request and version. Like Flask, Flask-Ask provides context
locals that spare you from having to add these as extra parameters to
your functions. However, the request and session objects are distinct from Flask’s request and session.
Flask-Ask’s request, context and session correspond to the Alexa request payload components while Flask’s correspond
to lower-level HTTP constructs.