Home

Awesome

ask-alexa-pykit

Release Version : <b>Master</b> (Unstable! For a stable release, check out the 0.5 branch)

ask-alexa-pykit 0.5 is out!

A minimalist framework for developing apps (skills) for the Amazon Echo's SDK: The Alexa Skills Kit (<b>ASK</b>).

Projects that use this library

Other Github Projects

If this library helps you build some dialog systems or do some interesting research - please remember to cite it!

  @Misc{kumarask2015,
  author =   {Anjishnu Kumar},
  title =    {ASK Alexa PyKit},
  howpublished = {\url{github.com/anjishnu/ask-alexa-pykit}},
  year = {2015}
  }

Let me know if you know any other projects that use or build on top of ask-alexa-pykit.

<b>What does this library do?</b>

To use this code for your own skill, simply generate training data, and an intent schema definition and edit <b>lambda_function.py</b> to add handler functions for the intents and requests that your skill supports - this should be enough to get started.

<b>Note</b>: Unless someone asks me to reconsider - I am now only going to do further releases of this library for AWS Lambda - the core library is concise enough that it can be included into any python server framework with just a few imports. The old releases (for cherrypy) will contain the infuriating request validation parts of the library which can be useful for people who don't want to use the Lambda or LambdaProxy approach to skill development.

What's new?

Latest changes:

Basic overview of Classes:

Step 1: Download Code

Method 1:

<b>$ git clone https://github.com/anjishnu/ask-alexa-pykit.git </b>

Make sure you're in a python lambda release branch. E.g

<b> $ cd ask-alexa-pykit <br> $ git checkout python_lambda_0.5_release </b> <br> Otherwise your build my be broken since the master branch is not always stable. <br> Method 2: <br> <b> $ mkdir my_new_skill <br> $ pip install ask-alexa-pykit --target my_new_skill <br> </b>

ask-alexa-pykit is now installed in your <b>my_new_skill</b> directory. Just import the library and start hacking.

Step 2: Create a intent schema for your app

Skip this if you're trying the included basic example and use <b>sample_intent_schema.json</b> as your <b>INTENT_SCHEMA</b>.

<br><b> $ python -m ask.intent_schema -i FILEPATH </b>

This script takes you through the process of generating an intent schema for your app- which defines how Alexa's language understanding system interprets results. After the process is complete, it asks you whether you the intent schema stored at the appropriate location.

Step 3: Generate training data and upload to Amazon.

3(a): Create a file containing your training examples and upload to Amazon. I've created a script which loads in the intent schema and does some validation and prompting while you type utterances, but I haven't played around with it enough to know if it actually helps. <br> <b>$ python -m ask.write_sample -i INTENT_SCHEMA -o TRAINING_DATA_OUTPUT_LOCATION</b> <br> This script prompts you to enter valid training data in the format defined by the ASK (https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/defining-the-voice-interface). You toggle through the different intents by pressing enter with blank input. Play around with it and see if you find it intuitive.

3(b): Once you are done, this script generates a file called utterance.txt with all your training data in it, ready to be uploaded to your skill: https://developer.amazon.com/edw/home.html#/skills

Step 4: Add your business logic

Skip this if you're just trying to run the included basic example.

Go to <b> lambda_function.py </b> and add handler functions to the code for your specific request or intent. This is what a handler function for NextRecipeIntent looks like.

@alexa.intent("NextRecipeIntent")
def next_recipe_intent_handler(request):
  """
  You can insert arbitrary business logic code here
  """
  return alexa.create_response("Getting Next Recipe ...")

Step 5: Package your code for Lambda

Package the code folder for AWS Lambda. Detailed instructions are here: http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

For the basic example included in the package simply zip the folder: <b> <br> $ cd ask-alexa-pykit <br> $ zip -r ask-lambda.zip * </b>

Step 6: Create a Lambda Function

Step 7: Associate Lambda Function with Alexa Skill

Add the ARN code for the Lambda Function you've just created as the Lambda ARN (Amazon Resource Name) Endpoint in the Skill Information tab of your skill's information on https://developer.amazon.com/edw/home.html#/skills/list

Note an ARN code is at the top of you Lambda page and starts with something like: <b>arn:aws:lambda:us</b>...

Contributing

Credits: Anjishnu Kumar 2015