What is Flask-Ask?
With the Amazon Echo, you ask "Alexa" to play songs, get the weather, and report scores. Those "skills", as they're called, have an open API for building conversational apps. Flask-Ask is an Alexa Skills Kit for Python that makes programming the Amazon Echo super easy.

Alexa Skills Kit / Conversion Helpers with John Wheeler

Conversion Helpers Details
  • 4m 27s
  • Appropriate for all
  • 06-21-2016
  • Updated 06-21-2016

Key Concepts: Amazon Data Types, Python datetime Package

Unless you're keen on writing code to convert strings like 'P2YT3H10M' and '2015-W48-WE' into meaningful Python datatypes, you need this video. Learn how to use Flask-Ask's convert parameter along with its special, shorthand function helpers: 'time', 'date', and 'timedelta' to convert from the Alexa service's built-in date/time types into Python's counterparts.

About the author

John Wheeler is the creator of Flask-Ask He's been developing for two decades in Java, JavaScript, Python, C# and Ruby. He lives in San Diego with his wife, daughter, and twin boys. Follow him on Twitter.

Subject: Alexa Skills Kit
Author: John Wheeler
     "intents": [{
         "intent": "MorningOrEveningIntent",
         "slots": [{
             "name": "timeofday",
             "type": "AMAZON.TIME"
     }, {
         "intent": "DayCountIntent",
         "slots": [{
             "name": "thedate",
             "type": "AMAZON.DATE"
     }, {
         "intent": "ReverseDayCountIntent",
         "slots": [{
             "name": "delta",
             "type": "AMAZON.DURATION"

MorningOrEveningIntent is {timeofday} in the morning or evening
DayCountIntent how many days away is {thedate}
ReverseDayCountIntent what day is {delta} from now

import logging
from datetime import date

from flask import Flask
from flask_ask import Ask, statement, question

app = Flask(__name__)
ask = Ask(app, "/")

log = logging.getLogger()

@ask.intent("MorningOrEveningIntent", convert={'timeofday': 'time'})
def morning_or_evening_intent(timeofday):
    period = "morning" if timeofday.hour <= 12 else "evening"
    return statement("{} is in the {}".format(timeofday, period))

@ask.intent("DayCountIntent", convert={'thedate': 'date'})
def day_count_intent(thedate):
    delta = thedate - date.today()
    days = delta.days
    return statement("It is {} days from now".format(days))

@ask.intent("ReverseDayCountIntent", convert={'delta': 'timedelta'})
def reverse_day_count(delta):
    thedate = date.today() + delta
    return statement("It is {}".format(thedate))
Conversion Helpers Discussion
Tutorial Playlist
Flask-Ask Quickstart
Project Bootstrap, Alexa Skills Kit, Flask-Ask, ngrok

4m 48s

Request Handling
Launch Requests, Intent Requests, Session Ended Requests

3m 17s

Building Responses
Statements, Questions, Cards, Reprompts

3m 50s

Intent Slots
Slots, Null Values, Default Values

3m 37s

Slot Conversions
Using Built-ins, Custom Callables, Error Handling

5m 40s

Conversion Helpers
Amazon Data Types, Python datetime Package

4m 27s

With more on the way!