-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrapped repo using cookiecutter-flask-ask
- Loading branch information
0 parents
commit a056429
Showing
11 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/dataSources/ | ||
.idea/dataSources.ids | ||
.idea/dataSources.xml | ||
.idea/dataSources.local.xml | ||
.idea/sqlDataSources.xml | ||
.idea/dynamic.xml | ||
.idea/uiDesigner.xml | ||
.idea/gradle.xml | ||
.idea/libraries | ||
.idea/mongoSettings.xml | ||
*.iws | ||
/out/ | ||
.idea_modules/ | ||
atlassian-ide-plugin.xml | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*.so | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
*.manifest | ||
*.spec | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
*.mo | ||
*.pot | ||
*.log | ||
local_settings.py | ||
instance/ | ||
.webassets-cache | ||
.scrapy | ||
docs/_build/ | ||
target/ | ||
.ipynb_checkpoints | ||
.python-version | ||
celerybeat-schedule | ||
.env | ||
.venv/ | ||
venv/ | ||
ENV/ | ||
.spyderproject | ||
.ropeproject | ||
.Python | ||
[Bb]in | ||
[Ii]nclude | ||
[Ll]ib | ||
[Ll]ib64 | ||
[Ll]ocal | ||
[Ss]cripts | ||
pyvenv.cfg | ||
.venv | ||
pip-selfcheck.json | ||
|
||
# An Ignore for scratch and test API outputs | ||
test_*.json | ||
test_*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Beef and Dairy Network Unofficial Skill | ||
============================= | ||
|
||
The number one Alexa skill for those involved or just interested in the production of beef animals and dairy herds. | ||
|
||
Setup | ||
----- | ||
|
||
It is recommended to run this project in a virtualenv. If virtualenvs are unfamiliar to you, `this handy tutorial`_ | ||
might be a good place to start. | ||
|
||
#. Create a virtualenv for this project, and activate it. | ||
#. Use ``pip install -r requirements.txt`` to install the required Python packages. | ||
#. You will require ``ngrok`` to make your skill accessible to Alexa for testing. You can download ngrok `here`_. | ||
|
||
.. _here: https://ngrok.com/download | ||
.. _this handy tutorial: http://docs.python-guide.org/en/latest/dev/virtualenvs/ | ||
|
||
Quickstart | ||
---------- | ||
|
||
Follow these easy steps to test your brand new Flask-Ask project. | ||
|
||
#. Launch the server by invoking ``python beef_and_dairy_skill.py``. | ||
#. With the server running, start ``ngrok http 5000``. | ||
#. Configure your app on the `Alexa Developer Portal`_. `This video`_ by `John Wheeler`_ shows how to deploy your speech assets configuration to the `Alexa Developer Portal`_. | ||
#. That's all! If you are using a browser that supports WebRTC for micophone input (Chrome, Firefox or Opera), you may use `echosim`_ to test your script - simply log in with the same credentials you used to deploy your Skill. | ||
|
||
.. _Alexa Developer Portal: https://developer.amazon.com/alexa | ||
.. _This video: https://alexatutorial.com | ||
.. _John Wheeler: https://alexatutorial.com/flask-ask/ | ||
.. _echosim: http://www.echosim.io/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# coding=utf-8 | ||
|
||
# Beef and Dairy Network Unofficial Skill | ||
# By Alasdair Nicol <[email protected]> | ||
# | ||
# The number one Alexa skill for those involved or just interested in the production of beef animals and dairy herds. | ||
|
||
import logging | ||
from datetime import datetime | ||
from flask import Flask, json, render_template | ||
from flask_ask import Ask, request, session, question, statement | ||
|
||
__author__ = 'Alasdair Nicol' | ||
__email__ = '[email protected]' | ||
|
||
|
||
app = Flask(__name__) | ||
ask = Ask(app, '/') | ||
logging.getLogger("flask_ask").setLevel(logging.DEBUG) | ||
|
||
# Session starter | ||
# | ||
# This intent is fired automatically at the point of launch (= when the session starts). | ||
# Use it to register a state machine for things you want to keep track of, such as what the last intent was, so as to be | ||
# able to give contextual help. | ||
|
||
@ask.on_session_started | ||
def start_session(): | ||
""" | ||
Fired at the start of the session, this is a great place to initialise state variables and the like. | ||
""" | ||
logging.debug("Session started at {}".format(datetime.now().isoformat())) | ||
|
||
# Launch intent | ||
# | ||
# This intent is fired automatically at the point of launch. | ||
# Use it as a way to introduce your Skill and say hello to the user. If you envisage your Skill to work using the | ||
# one-shot paradigm (i.e. the invocation statement contains all the parameters that are required for returning the | ||
# result | ||
|
||
@ask.launch | ||
def handle_launch(): | ||
""" | ||
(QUESTION) Responds to the launch of the Skill with a welcome statement and a card. | ||
Templates: | ||
* Initial statement: 'welcome' | ||
* Reprompt statement: 'welcome_re' | ||
* Card title: 'Beef and Dairy Network Unofficial Skill | ||
* Card body: 'welcome_card' | ||
""" | ||
|
||
welcome_text = render_template('welcome') | ||
welcome_re_text = render_template('welcome_re') | ||
welcome_card_text = render_template('welcome_card') | ||
|
||
return question(welcome_text).reprompt(welcome_re_text).standard_card(title="Beef and Dairy Network Unofficial Skill", | ||
text=welcome_card_text) | ||
|
||
|
||
# Built-in intents | ||
# | ||
# These intents are built-in intents. Conveniently, built-in intents do not need you to define utterances, so you can | ||
# use them straight out of the box. Depending on whether you wish to implement these in your application, you may keep | ||
# or delete them/comment them out. | ||
# | ||
# More about built-in intents: http://d.pr/KKyx | ||
|
||
@ask.intent('AMAZON.StopIntent') | ||
def handle_stop(): | ||
""" | ||
(STATEMENT) Handles the 'stop' built-in intention. | ||
""" | ||
farewell_text = render_template('stop_bye') | ||
return statement(farewell_text) | ||
|
||
|
||
@ask.intent('AMAZON.CancelIntent') | ||
def handle_cancel(): | ||
""" | ||
(STATEMENT) Handles the 'cancel' built-in intention. | ||
""" | ||
farewell_text = render_template('cancel_bye') | ||
return statement(farewell_text) | ||
|
||
|
||
@ask.intent('AMAZON.HelpIntent') | ||
def handle_help(): | ||
""" | ||
(QUESTION) Handles the 'help' built-in intention. | ||
You can provide context-specific help here by rendering templates conditional on the help referrer. | ||
""" | ||
|
||
help_text = render_template('help_text') | ||
return question(help_text) | ||
|
||
|
||
@ask.intent('AMAZON.NoIntent') | ||
def handle_no(): | ||
""" | ||
(?) Handles the 'no' built-in intention. | ||
""" | ||
pass | ||
|
||
@ask.intent('AMAZON.YesIntent') | ||
def handle_yes(): | ||
""" | ||
(?) Handles the 'yes' built-in intention. | ||
""" | ||
pass | ||
|
||
|
||
@ask.intent('AMAZON.PreviousIntent') | ||
def handle_back(): | ||
""" | ||
(?) Handles the 'go back!' built-in intention. | ||
""" | ||
pass | ||
|
||
@ask.intent('AMAZON.StartOverIntent') | ||
def start_over(): | ||
""" | ||
(QUESTION) Handles the 'start over!' built-in intention. | ||
""" | ||
pass | ||
|
||
|
||
# Ending session | ||
# | ||
# This intention ends the session. | ||
|
||
@ask.session_ended | ||
def session_ended(): | ||
""" | ||
Returns an empty for `session_ended`. | ||
.. warning:: | ||
The status of this is somewhat controversial. The `official documentation`_ states that you cannot return a response | ||
to ``SessionEndedRequest``. However, if it only returns a ``200/OK``, the quit utterance (which is a default test | ||
utterance!) will return an error and the skill will not validate. | ||
""" | ||
return statement("") | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Minimal makefile for Sphinx documentation | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = | ||
SPHINXBUILD = sphinx-build | ||
SPHINXPROJ = beef_and_dairy_skill | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Oops, something went wrong.