Giter Site home page Giter Site logo

gitter-badger / flask-ask Goto Github PK

View Code? Open in Web Editor NEW

This project forked from johnwheeler/flask-ask

0.0 1.0 0.0 208 KB

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

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

License: Apache License 2.0

Python 100.00%

flask-ask's Introduction

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

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.

Get started with the Flask-Ask quickstart on Amazon's Developer Blog.

👊 Level Up with the Alexa Skills Kit Video Tutorial

☤ 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

flask-ask's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.