Skip to content

Commit

Permalink
Merge branch 'hotfix/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
treethought committed Dec 17, 2018
2 parents 37953ae + f399905 commit 55a544c
Show file tree
Hide file tree
Showing 29 changed files with 308 additions and 145 deletions.
16 changes: 8 additions & 8 deletions docs/source/generate_schema.rst
Expand Up @@ -6,7 +6,7 @@ Generating Dialogflow Schema

Flask-Assistant provides a command line utilty to automatically generate your agent's JSON schema and register the required information to communicate with Dialogflow.

This allows you to focus on building your entire webhook from your text editor while needing to interact with the API.AI web interface only for testing.
This allows you to focus on building your entire webhook from your text editor while needing to interact with the Dialogflow web interface only for testing.


The ``schema`` command generates JSON objects representing Intents and Entities
Expand Down Expand Up @@ -73,7 +73,7 @@ You can then annotate parameter values within the phrase to their respective ent
- pepperoni: topping
- delivery: order-method
If the intent requires no parameters or you'd like API.AI to automaticcaly annotate the phrase, simply exclude the ``Annotations`` or leave it blank.
If the intent requires no parameters or you'd like Dialogflow to automaticcaly annotate the phrase, simply exclude the ``Annotations`` or leave it blank.

Re-running the ``schema`` command will then update your agent's Intents with the new user phrases, including their annotations.

Expand Down Expand Up @@ -114,7 +114,7 @@ You can provide entries by listing them under the entity name.
- veggies
- pepperoni
Synonyms can be added for each entry to improve API.AI's detection of the entity.
Synonyms can be added for each entry to improve Dialogflow's detection of the entity.

.. code-block:: yaml
Expand All @@ -132,7 +132,7 @@ Synonyms can be added for each entry to improve API.AI's detection of the entity
.. note:: Any pre-built API.AI `system entities <https://docs.api.ai/docs/concept-entities#section-system-entities>`_ (sys.color) will not be included in the template, as they are already defined within API.AI.
.. note:: Any pre-built Dialogflow `system entities <https://docs.api.ai/docs/concept-entities#section-system-entities>`_ (sys.color) will not be included in the template, as they are already defined within Dialogflow.



Expand All @@ -141,9 +141,9 @@ Synonyms can be added for each entry to improve API.AI's detection of the entity
Running the command
==========================

This will require an existing API.AI agent, and your webhook should be within its own directory, as the utility will create two new folders in the app's root.
This will require an existing Dialogflow agent, and your webhook should be within its own directory, as the utility will create two new folders in the app's root.

1. First obtain your agent's Developer access token from the `API.AI Console`_
1. First obtain your agent's Developer access token from the `Dialogflow Console`_
2. Ensure you are in the same directory as your assistant and store your token as an environment variable
.. code-block:: bash
Expand All @@ -153,12 +153,12 @@ This will require an existing API.AI agent, and your webhook should be within it
schema my_assistant.py
This will generate a JSON object for each intent and entity used in your webhook as described above. The schema objects will be pushed to API.AI and create a new intent/entity or update the existing one if the object already exists.
This will generate a JSON object for each intent and entity used in your webhook as described above. The schema objects will be pushed to Dialogflow and create a new intent/entity or update the existing one if the object already exists.

You will see an output of status messages indicating if the registration was successful for each object.

You can view the JSON generated in the newly created `schema` directory.



.. _`API.AI Console`: https://console.api.ai/api-client/#/login
.. _`Dialogflow Console`: https://console.dialogflow.com/api-client
39 changes: 13 additions & 26 deletions docs/source/hass.rst
Expand Up @@ -2,7 +2,7 @@
Home Assistant Integration
************************************

Flask-Assistant includes a :class:`HassRemote <flask_assistant.HassRemote>` interface to make requests to Home Assistant's `REST api <https://home-assistant.io/developers/rest_api/>`_. This allows your API.AI agent to control and retrieve data about your IoT devices.
Flask-Assistant includes a :class:`HassRemote <flask_assistant.HassRemote>` interface to make requests to Home Assistant's `REST api <https://home-assistant.io/developers/rest_api/>`_. This allows your Dialogflow agent to control and retrieve data about your IoT devices.



Expand Down Expand Up @@ -37,7 +37,7 @@ The HassRemote is a simple wrapper around Home Assistant's own `remote <https://
For example:

If you have a switch in your HA configuration with the name "switch.coffee_maker", the name of the parameter should be "switch". This allows your entities to be properly defined within your entities.yaml template when generating schema.


Controlling Lights
^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -116,26 +116,26 @@ Hass Entity Templates
Home Assistant devices used within action functions can easily be included in your entries template, and are automatically added with the when :doc:`generating schema <generate_schema>`.


Although Home Assistant and API.AI both use the term entities, they are used in slightly different ways.
Although Home Assistant and Dialogflow both use the term entities, they are used in slightly different ways.

Home Assistant:
- uses the term entity to describe any device or service connected to HA.
- Each entity belongs to a domain (component).
- Each entity belongs to a domain (component).

API.AI:
Dialogflow:
- Uses the term entity to describe a concept that is used within actions
- Each instance of the entity is called an entry, and may be the value of parameters required by actions

Therefore, the idea of a ``HA entity`` is similar to an ``API.AI entry``.
Therefore, the idea of a ``HA entity`` is similar to an ``Dialogflow entry``.

So HA devices can be defined as entries under their domain, with their domain serving as the Dialogflow entity.

So HA devices can be defined as entries under their domain, with their domain serving as the API.AI entity.

.. code-block:: yaml
domain:
- device1: [synonyms]
- device2: [synonyms]
Template Examples
-----------------

Expand All @@ -149,9 +149,9 @@ A Group of Lights:
- lamp_2: ['lamp', 'desk lamp']
- lamp_3: ['bedroom light', 'room light', 'bedroom']
- room: ['all lights', 'lights', 'room'] # a group within home assistant
Within Home Assistant lamp_2 would be identified as light.lamp_2 and room as light.room
Switches
^^^^^^^^
Expand All @@ -178,21 +178,8 @@ Shell Commands

.. code-block:: yaml
shell_command:
- playstation_netflix_start: ['netflix', 'netflix on the ps4']
- playstation_overwatch_start: [overwatch]
- playstation_gtav_start: [gta five, gta]
34 changes: 11 additions & 23 deletions docs/source/index.rst
Expand Up @@ -8,20 +8,20 @@
Welcome to Flask-Assistant!
***************************

.. _`Google Actions`: https://developers.google.com/actions/develop/apiai/
.. _`fullfillment`: https://developers.google.com/actions/develop/apiai/dialogs-and-fulfillment#overview
.. _API.AI: https://docs.api.ai/
.. _`Google Actions`: https://developers.google.com/actions/dialogflow/
.. _`fullfillment`: https://dialogflow.com/docs/fulfillment
.. _Dialogflow: https://dialogflow.com/docs

A flask extension serving as an `API.AI`_ SDK to provide an easy way to create virtual assistants which may be integrated with platforms such as `Google Actions`_ (Google Home).
A flask extension serving as an `Dialogflow`_ SDK to provide an easy way to create virtual assistants which may be integrated with platforms such as `Google Actions`_ (Google Home).

Flask-Assistant allows you to focus on building the core business logic of conversational user interfaces while utilizing API.AI's Natural Language Processing to interact with users.
Flask-Assistant allows you to focus on building the core business logic of conversational user interfaces while utilizing Dialogflow's Natural Language Processing to interact with users.


.. This framework provides the ability to:
.. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. - Quickly create fullfillment_ webhooks
.. - Define and register API.AI schema
.. - Design a conversational flow to build contextual dialogues with API.AI's concept of contexts
.. - Define and register Dialogflow schema
.. - Design a conversational flow to build contextual dialogues with Dialogflow's concept of contexts
Expand All @@ -33,8 +33,8 @@ Features
- Context support for crafting dialogue dependent on the user's requests
- Define prompts for missing parameters when they are not present in the users request or past active contexs
- A convenient syntax resembling Flask's decoratored routing
- Internal API.AI schema generation and registration
- Internal Dialogflow schema generation and registration



A Minimal Assistant
Expand All @@ -46,7 +46,7 @@ A Minimal Assistant
from flask_assistant import Assistant, tell
app = Flask(__name__)
assist = Assistant(app)
assist = Assistant(app, project_id='GOOGLE_CLOUD_PROJECT_ID')
@assist.action('Demo')
def hello_world():
Expand All @@ -64,7 +64,7 @@ Explanation
1. Initialized an :class:`Assistant <flask_assistant.Assistant>` object with a Flask app and the route to your webhook URL.
2. Used the :meth:`action <flask_assistant.Assistant.action>` decorator to map the `greetings` intent to the proper action function.
- The action decorator accepts the name of an intent as a parameter
- The decorated function serves as the action view function, called when an API.AI request sent on behalf of the `send-message` intent is received
- The decorated function serves as the action view function, called when an Dialogflow request sent on behalf of the `send-message` intent is received
3. The action function returns an :class:`ask <flask_assistant.ask>` response containing text/speech which prompts the user for the next intent.


Expand All @@ -79,15 +79,3 @@ Check out the :doc:`quick_start` to see how to quickly build an assistant
.. * :ref:`genindex`
.. * :ref:`modindex`
.. * :ref:`search`

0 comments on commit 55a544c

Please sign in to comment.