Git Product home page Git Product logo

alexadeploymentsample's Introduction

Sample project to demonstrate how to create a lambda function in Python that can be used in an Alexa Skill.

This project is not meant to be a tutorial on Alexa development. For that please see the Amazon documentation at:

Youtube video for this project. https://www.youtube.com/watch?v=WFWAK175p2g

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit

AlexaBaseHandler class

The AlexaBaseHandler class is an abstract class that provides the necessary framework to build the necessary response hooks for an Alexa application.

process_request

This method will take the 2 parameters that are sent to the lambda function and determine which of the Alexa handlers to invoke.

_build_speechlet_response

This method ( from the Alexa color example ) will put together the speechlet portion into a properly formatted json message. This is typically called by the concrete implementations of the AlexaBaseHandler.

_build_response

This method (from the Alexa color example ) will construct a property formatted response message so the Amazon Echo knows what to reponse with.

AlexaDeploymentHandler class

This class is a reference implementation that does nothing useful. All Alexa handlers are handled the same way.

main.py

This file contains the main entry point of the lambda function that is called for the Alexa skill.

lambda_handler(event, context)

This method ( which can be called anything, you just need to configure it in the lambda handler ), is the method that is called with the 2 parameters.

This method will typically instantiate an concrete implementation of the AlexaBaseHandler and delegate to the process_request method.

requirements.txt

This file is the standard Python requirements file. This file is used by the create_deployment.py script to install the necessary 3rd party libraries that your Alexa skill might need. Any library specified in the requirements.txt file will be installed into your deployment directory.

create_deployment

This script creates a zip file per the Amazon lambda specification, such that it is suitable to upload as your lambda function implementation.

All deployments are stored in the deployments subdirectory and follow the naming convention of 'deployment_n' and 'deployment_n.zip', where 'n' is automatically calculated to the next largest 'n' in the directory. Right now it does this based on the name of the subdirectories of deployments - NOT - the names of the zip files.

The deployment script will create a deployment directory and zip file for everything in the requirements.txt file AND the files in the deployment_files variable in the create_deployment.py file.

When this script is done running, there should be a 'deploment_n.zip' file in the deployments directory. It is that file that needs to be upload to the Amazon Lambda console.

Useful links:

http://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

alexadeploymentsample's People

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.