Veterun / flask-ask

Alexa Skills Kit framework for Python. Includes Sphinx documentation, samples ported from Java, and YouTube videos.

Home Page:https://alexatutorial.com/flask-ask/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

http://flask-ask.readthedocs.io/en/latest/_images/logo-full.png

😎 Lighten your cognitive load. Level up with the Alexa Skills Kit Video Tutorial.

Alexa Skills Kit Development for Python

Building high-quality Alexa skills for Amazon Echo Devices takes time. Flask-Ask makes it easier and much more fun. Use Flask-Ask with ngrok to eliminate the deploy-to-test step and get work done faster.

A Flask-Ask quickstart is available on the Amazon Developer Blog.

☤ The Basics

A Flask-Ask application looks like this:

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

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

@ask.intent('HelloIntent')
def hello(firstname):
    text = render_template('hello', firstname=firstname)
    return statement(text).simple_card('Hello', text)

if __name__ == '__main__':
    app.run()

In the code above:

  1. The Ask object is created by passing in the Flask application and a route to forward Alexa requests to.
  2. The intent decorator maps HelloIntent to a view function hello.
  3. The intent's firstname slot is implicitly mapped to hello's firstname parameter.
  4. Jinja templates are supported. Internally, templates are loaded from a YAML file (discussed further below).
  5. Lastly, a builder constructs a spoken response and displays a contextual card in the Alexa smartphone/tablet app.

Since Alexa responses are usually short phrases, it's convenient to put them in the same file. Flask-Ask has a Jinja template loader that loads multiple templates from a single YAML file. For example, here's a template that supports the minimal voice interface above.Templates are stored in a file called templates.yaml located in the application root:

hello: Hello, {{ firstname }}

For more information about how the Alexa Skills Kit works, see Understanding Custom Skills in the Alexa Skills Kit documentation.

Additionally, more code and template examples are in the samples directory.

☤ Features

Flask-Ask handles the boilerplate, so you can focus on writing clean code. Flask-Ask:

  • Has decorators to map Alexa requests and intent slots to view functions
  • Helps construct ask and tell responses, reprompts and cards
  • Makes session management easy
  • Allows for the separation of code and speech through Jinja templates
  • Verifies Alexa request signatures

☤ Installation

To install Flask-Ask:

pip install flask-ask

☤ Documentation

These resources will get you up and running quickly:

5-minute quickstart

Full online documentation

☤ Thank You

Thanks for checking this library out! I hope you find it useful.

Of course, there's always room for improvement. Feel free to open an issue so we can make Flask-Ask better.

Special thanks to @kennethreitz for his sense of style, and of course, @mitsuhiko for Flask

About

Alexa Skills Kit framework for Python. Includes Sphinx documentation, samples ported from Java, and YouTube videos.

https://alexatutorial.com/flask-ask/

License:Apache License 2.0


Languages

Language:Python 100.0%