A flexible and easy-to-use package for building Alexa skill applications.
Project description
alexa-skill
alexa-skill is flexible, easy to use and extend package for creating Alexa skill applications.
This package is based on alexa documentation.
Installing
Install and update using pip:
pip install -U alexa-skill
Examples
Define intent class
from alexa_skill.intents import BaseIntents
class ExampleIntents(BaseIntents):
@property
def mapper(self):
return {
'EXAMPLE.hello': self.hello,
}
def hello(self):
return self.response('Hello. Nice to meet you.'), True
Define intent class with slots
from alexa_skill import dates
from alexa_skill.intents import BaseIntents
class DateIntents(BaseIntents):
@property
def mapper(self):
return {
'EXAMPLE.date_intent': self.date_intent,
}
def date_intent(self, slots):
date, date_type = dates.AmazonDateParser.to_date(slots['dateslot']['value'])
text = "Your date is <say-as interpret-as='date'>{}</say-as> and it is a {}".format(
date.strftime('%Y%m%d'),
date_type
)
return self.response(text), True
Define buildin intents
from alexa_skill.intents import BuildInIntents
buildin_intents = BuildInIntents(
help_message='Say "HI" to us',
not_handled_message="Sorry, I don't understand you. Could you repeat?",
stop_message='stop',
cancel_message='cancel'
)
Falcon
Initiate intents in fulfiller webhook for Alexa
import logging
import alexa_skill
import falcon
class Fulfiller(object):
def on_post(self, req, resp):
get_response = alexa_skill.Processor(
req.media,
buildin_intents,
'Welcome to Alexa skill bot',
'Good bye',
ExampleIntents(), # Insert created Intents as arguments
DateIntents(),
)
json_response, handled = get_response()
logging.info('Response was handled by system: {}'.format(handled))
resp.media = json_response
app = falcon.API(media_type=falcon.MEDIA_JSON)
app.add_route('/v1/alexa/fulfiller', Fulfiller())
Flask
import logging
import alexa_skill
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/v1/alexa/fulfiller", methods=['POST'])
def fulfiller():
get_response = alexa_skill.Processor(
request.json,
buildin_intents,
'Welcome to Alexa skill bot',
'Good bye',
ExampleIntents(),
DateIntents(),
)
json_response, handled = get_response()
logging.info('Response was handled by system: {}'.format(handled))
return jsonify(json_response)
Documentation
Auto generate documentation
cd docs/
sphinx-apidoc -o ./source/_modules/ ../alexa_skill/
make html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alexa_skill-0.1.0.tar.gz.
File metadata
- Download URL: alexa_skill-0.1.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f33abd37cab34ee55e1d8552110dba8d22af54aaa877d93cf36524bfd3b2a80c
|
|
| MD5 |
edcfe42ee266affab7a0e7378f794764
|
|
| BLAKE2b-256 |
86fddd847cac7f3b07e2ee378d6ac4ed29e8b88dc66ab434902f91ede2eb1929
|
File details
Details for the file alexa_skill-0.1.0-py2-none-any.whl.
File metadata
- Download URL: alexa_skill-0.1.0-py2-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2df6d6cfd2e6ff7e56c0f25767a3a4d97d5870fdea205c18fa20a0535d77a7c
|
|
| MD5 |
da89e7db1ee78ea52c57d8eeabee9300
|
|
| BLAKE2b-256 |
41468daf5bfeafbb42204ba431227bf3b079dcaeb31bbf646b91ca2da62cf146
|