{"id":13501900,"url":"https://github.com/johnwheeler/flask-ask","last_synced_at":"2025-04-12T01:55:50.062Z","repository":{"id":42553206,"uuid":"58594760","full_name":"johnwheeler/flask-ask","owner":"johnwheeler","description":"Alexa Skills Kit for Python","archived":false,"fork":false,"pushed_at":"2023-05-01T21:13:09.000Z","size":498,"stargazers_count":1915,"open_issues_count":70,"forks_count":368,"subscribers_count":89,"default_branch":"master","last_synced_at":"2025-04-12T01:55:43.331Z","etag":null,"topics":["alexa","alexa-skills-kit","echo","flask","flask-extensions","python-2","python3"],"latest_commit_sha":null,"homepage":"https://developer.amazon.com/blogs/post/Tx14R0IYYGH3SKT/Flask-Ask-A-New-Python-Framework-for-Rapid-Alexa-Skills-Kit-Development","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnwheeler.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-05-12T00:54:46.000Z","updated_at":"2025-04-07T15:12:40.000Z","dependencies_parsed_at":"2022-08-26T03:24:55.365Z","dependency_job_id":"4835e35c-8cec-4418-a812-825930cf8ebc","html_url":"https://github.com/johnwheeler/flask-ask","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnwheeler%2Fflask-ask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnwheeler%2Fflask-ask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnwheeler%2Fflask-ask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnwheeler%2Fflask-ask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnwheeler","download_url":"https://codeload.github.com/johnwheeler/flask-ask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505867,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alexa","alexa-skills-kit","echo","flask","flask-extensions","python-2","python3"],"created_at":"2024-07-31T22:01:54.743Z","updated_at":"2025-04-12T01:55:50.016Z","avatar_url":"https://github.com/johnwheeler.png","language":"Python","funding_links":[],"categories":["Python","Development","声控应用","SDKs/Tools","Voice Controller"],"sub_categories":["Development Tools","底层开发库","Android Things"],"readme":"\n.. image:: http://flask-ask.readthedocs.io/en/latest/_images/logo-full.png\n\n===================================\nProgram the Amazon Echo with Python\n===================================\n\nFlask-Ask is a `Flask extension \u003chttp://flask.pocoo.org/extensions/\u003e`_ that makes building Alexa skills for the Amazon Echo easier and much more fun.\n\n* `Flask-Ask quickstart on Amazon's Developer Blog \u003chttps://developer.amazon.com/public/community/post/Tx14R0IYYGH3SKT/Flask-Ask-A-New-Python-Framework-for-Rapid-Alexa-Skills-Kit-Development\u003e`_.\n* `Level Up with our Alexa Skills Kit Video Tutorial \u003chttps://alexatutorial.com/\u003e`_\n* `Chat on Gitter.im \u003chttps://gitter.im/johnwheeler/flask-ask/\u003e`_\n\nThe Basics\n===============\n\nA Flask-Ask application looks like this:\n\n.. code-block:: python\n\n  from flask import Flask\n  from flask_ask import Ask, statement\n\n  app = Flask(__name__)\n  ask = Ask(app, '/')\n\n  @ask.intent('HelloIntent')\n  def hello(firstname):\n      speech_text = \"Hello %s\" % firstname\n      return statement(speech_text).simple_card('Hello', speech_text)\n\n  if __name__ == '__main__':\n      app.run()\n\nIn the code above:\n\n#. The ``Ask`` object is created by passing in the Flask application and a route to forward Alexa requests to.\n#. The ``intent`` decorator maps ``HelloIntent`` to a view function ``hello``.\n#. The intent's ``firstname`` slot is implicitly mapped to ``hello``'s ``firstname`` parameter.\n#. Lastly, a builder constructs a spoken response and displays a contextual card in the Alexa smartphone/tablet app.\n\nMore code examples are in the `samples \u003chttps://github.com/johnwheeler/flask-ask/tree/master/samples\u003e`_ directory.\n\nJinja Templates\n---------------\n\nSince Alexa responses are usually short phrases, you might find it convenient to put them in the same file.\nFlask-Ask has a `Jinja template loader \u003chttp://jinja.pocoo.org/docs/dev/api/#loaders\u003e`_ that loads\nmultiple templates from a single YAML file. For example, here's a template that supports the minimal voice interface\nabove:\n\n.. code-block:: yaml\n\n    hello: Hello, {{ firstname }}\n\nTemplates are stored in a file called `templates.yaml` located in the application root. Checkout the `Tidepooler example \u003chttps://github.com/johnwheeler/flask-ask/tree/master/samples/tidepooler\u003e`_ to see why it makes sense to extract speech out of the code and into templates as the number of spoken phrases grow.\n\nFeatures\n===============\n\nFlask-Ask handles the boilerplate, so you can focus on writing clean code. Flask-Ask:\n\n* Has decorators to map Alexa requests and intent slots to view functions\n* Helps construct ask and tell responses, reprompts and cards\n* Makes session management easy\n* Allows for the separation of code and speech through Jinja templates\n* Verifies Alexa request signatures\n\nInstallation\n===============\n\nTo install Flask-Ask::\n\n  pip install flask-ask\n\nDocumentation\n===============\n\nThese resources will get you up and running quickly:\n\n* `5-minute quickstart \u003chttps://www.youtube.com/watch?v=cXL8FDUag-s\u003e`_\n* `Full online documentation \u003chttps://alexatutorial.com/flask-ask/\u003e`_\n\nFantastic 3-part tutorial series by Harrison Kinsley\n\n* `Intro and Skill Logic - Alexa Skills w/ Python and Flask-Ask Part 1 \u003chttps://pythonprogramming.net/intro-alexa-skill-flask-ask-python-tutorial/\u003e`_\n* `Headlines Function - Alexa Skills w/ Python and Flask-Ask Part 2 \u003chttps://pythonprogramming.net/headlines-function-alexa-skill-flask-ask-python-tutorial/\u003e`_\n* `Testing our Skill - Alexa Skills w/ Python and Flask-Ask Part 3 \u003chttps://pythonprogramming.net/testing-deploying-alexa-skill-flask-ask-python-tutorial/\u003e`_\n\nDeployment\n===============\n\nYou can deploy using any WSGI compliant framework (uWSGI, Gunicorn). If you haven't deployed a Flask app to production, `checkout flask-live-starter \u003chttps://github.com/johnwheeler/flask-live-starter\u003e`_.\n\nTo deploy on AWS Lambda, you have two options. Use `Zappa \u003chttps://github.com/Miserlou/Zappa\u003e`_ to automate the deployment of an AWS Lambda function and an AWS API Gateway to provide a public facing endpoint for your Lambda function. This `blog post \u003chttps://developer.amazon.com/blogs/post/8e8ad73a-99e9-4c0f-a7b3-60f92287b0bf/new-alexa-tutorial-deploy-flask-ask-skills-to-aws-lambda-with-zappa\u003e`_ shows how to deploy Flask-Ask with Zappa from scratch. Note: When deploying to AWS Lambda with Zappa, make sure you point the Alexa skill to the HTTPS API gateway that Zappa creates, not the Lambda function's ARN.\n\nAlternatively, you can use AWS Lambda directly without the need for an AWS API Gateway endpoint. In this case you will need to `deploy \u003chttps://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html\u003e`_ your Lambda function yourself and use `virtualenv \u003chttp://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html\u003e`_ to create a deployment package that contains your Flask-Ask application along with its dependencies, which can be uploaded to Lambda. If your Lambda handler is configured as `lambda_function.lambda_handler`, then you would save the full application example above in a file called `lambda_function.py` and add the following two lines to it:\n\n.. code-block:: python\n\n    def lambda_handler(event, _context):\n        return ask.run_aws_lambda(event)\n\n\nDevelopment\n===============\n\nIf you'd like to work from the Flask-Ask source, clone the project and run::\n\n  pip install -r requirements-dev.txt\n\nThis will install all base requirements from `requirements.txt` as well as requirements needed for running tests from the `tests` directory.\n\nTests can be run with::\n\n  python setup.py test\n\nOr::\n\n  python -m unittest\n\nTo install from your local clone or fork of the project, run::\n\n  python setup.py install\n\nRelated projects\n===============\n\n`cookiecutter-flask-ask \u003chttps://github.com/chrisvoncsefalvay/cookiecutter-flask-ask\u003e`_ is a Cookiecutter to easily bootstrap a Flask-Ask project, including documentation, speech assets and basic built-in intents.\n\nHave a Google Home? Checkout `Flask-Assistant \u003chttps://github.com/treethought/flask-assistant\u003e`_ (early alpha)\n\n\nThank You\n===============\n\nThanks for checking this library out! I hope you find it useful.\n\nOf course, there's always room for improvement.\nFeel free to `open an issue \u003chttps://github.com/johnwheeler/flask-ask/issues\u003e`_ so we can make Flask-Ask better.\n\nSpecial thanks to `@kennethreitz \u003chttps://github.com/kennethreitz\u003e`_ for his `sense \u003chttp://docs.python-requests.org/en/master/\u003e`_ of `style \u003chttps://github.com/kennethreitz/records/blob/master/README.rst\u003e`_, and of course, `@mitsuhiko \u003chttps://github.com/mitsuhiko\u003e`_ for `Flask \u003chttps://www.palletsprojects.com/p/flask/\u003e`_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnwheeler%2Fflask-ask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnwheeler%2Fflask-ask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnwheeler%2Fflask-ask/lists"}