Skip to content

umbc-hackafe/pyalexa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyalexa

Simple Python API for granting custom skills to the Amazon Echo (Alexa)

Design

pyalexa uses flask-style decorators to mark functions that handle a particular intent.

Examples

Declaring a skill

To declare a skill, you will need your Amazon app ID, something like amzn1.echo-sdk-ams.app.12345678-9abc-def0-1234-56789abcdef0. Then, just create a Skill object:

from pyalexa import Skill

skill = Skill(app_id='amzn1.echo-sdk-ams.app.12345678-9abc-def0-1234-56789abcdef0',
              version='1.0')

Intents are handled using decorators, in the style of the popular flask library. There are three decorators provided: launch, for the LaunchRequest, end for SessionEndedRequest, and intent for [IntentRequest]s. Here's a pyalexa version of HelloWorld, from Amazon's sample skills.

from pyalexa import Skill, Card

skill = Skill(app_id='amzn1.echo-sdk-ams.app.12345678-9abc-def0-1234-56789abcdef0')

@skill.launch
def launch(request):
    return request.response(
        speech="Welcome to pyalexa, you can say hello",
        reprompt="You can say hello"
    )

@skill.end
def end(request):
    print("We can do cleanup stuff here")

@skill.intent("HelloWorldIntent")
def hello_world(request):
    return request.response(
        card=Card("Greeter", "Hello World!")
        speech="Hello world!"
    )

@skill.intent("HelpIntent")
def help_intent(request):
    return request.response(
        text="You can say hello to me!",
        reprompt="You can say hello to me!"
    )

About

Python API for writing new Amazon Echo skills

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages