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 / Intent Slots with John Wheeler


Intent Slots Details
  • 3m 37s
  • Appropriate for all
  • 06-21-2016
  • Updated 06-21-2016

Key Concepts: Slots, Null Values, Default Values

What parameters are to functions, slots are to intent requests. In this video, you'll use Flask-Ask to map intent slots to Python function parameters. We'll map one slot first and then two. Flask-Ask's default parameter is used to supply a default value when slots come in null.

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's founded several SaaS businesses for eBay sellers and written technical articles for IBM and O'Reilly. He lives in San Diego with his wife, daughter, and twin boys. Follow him on Twitter.

Subject: Alexa Skills Kit
Author: John Wheeler
intent_schema.json
{
    "intents": [{
        "intent": "SayHelloIntent",
        "slots": [{
            "name": "firstname",
            "type": "AMAZON.US_FIRST_NAME"
        }]
    }, {
        "intent": "SayAgeIntent",
        "slots": [{
            "name": "firstname",
            "type": "AMAZON.US_FIRST_NAME"
        }, {
            "name": "age",
            "type": "AMAZON.NUMBER"
        }]
    }]
}

sample_utterances.txt
SayHelloIntent say hello to {firstname}
SayHelloIntent say hi to {firstname}
SayHelloIntent greet {firstname}
SayAgeIntent tell {firstname} he is {age}
SayAgeIntent tell {firstname} she is {age}
SayAgeIntent tell {firstname} he is {age} years old
SayAgeIntent tell {firstname} she is {age} years old

demo.py
import logging
from flask import Flask
from flask_ask import Ask, statement, question


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


log = logging.getLogger()
log.addHandler(logging.StreamHandler())
log.setLevel(logging.DEBUG)
logging.getLogger("flask_ask").setLevel(logging.DEBUG)


@ask.intent("SayHelloIntent")
def say_hello(firstname):
    return statement("Hello {}. Nice to meet you.".format(firstname))


@ask.intent("SayAgeIntent", default={'firstname': 'Jack', 'age': 50})
def say_age(firstname, age):
    return statement("Hello {}. You are {} years old.".format(firstname, age))
Intent Slots 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!