Architecture
Step 1:
Follow the steps in my previous blog entry to connect the Nespresso machine to the internet using particle photon and a servo.
Step 2:
Now we build an API.AI agent to handle the natural language request translation, this would require building an agent and training it to understand the requests and how to translate them.
Create Agent
Each agent should have a specific domain, in our case the agent’s domain will be home automation.
Create new Intent make.coffee
The intent is the action flow for the agent, it will include the agent training set and the expressions it is to expect and the parameters it expects to gather before invoking an action. In our case the device to use and whether to warm the device or actually make the coffee.
Create Entities
Here we create the entities (also serve as parameters) that the intent will use.
I defined two abstract entities, device and action.
I then created 1 device instance :Coffee machine and listed all the synonyms i usually use to refer to it.
Two actions were then defined : Warm and make, also with all the synonyms usually used to refer to them.
Click to view slideshow.Configure intent make.coffee
Now we go back to the intent and add the user expressions (commands) I added some expressions such as :
- can I have some coffee please
- heat up the Nespresso machine
- prepare the Nespresso machine
- make me some coffee please
Make sure that the entities are mapped in your expressions. If not you can click on any of the terms and manually map it to the correct entity.
The next step is to define the required parameters for the actions, scroll to the actions section and expand it and add the required entities, in this case we have two required parameters : Device and Action. Also add what should the agent prompt the user if a parameter is missing. For instance you an ask the user for action if it was not picked up from the initial interaction or the device if it was not mentioned.
Response
Go to the response section and add a response such as : working on it. This will later be replaced by the webservice response, but for now lets use this.
Test Your agent
In theory the agent is ready now to translate requests so its time for some QA, the test scenarios you should try are a fully completed request and a partial request to check whether the more info question prompt would be triggered or not.
The JSON interpretation of the request should include in the result object the request interpretation in this case
Action -> warm
coffee_machine -> coffee machine
Click to view slideshow.Integrate with FB chat
This will allow you to talk with your bot through facebook chat. Follow the steps here-> How to link api.ai with FB chat.
Step 3 :
Build the middleware using hook.io (coming soon)
