Natural Language Types (Called Entities on API.AI)
Your commands can have variables, and each variable has a type
For example, in a voice command like
- Turn on my living room light
living room can be a variable of the type light
You can create the light type and give it multiple options. For example:
- living room
- dining room
- bathroom
If you want, each item can have synonyms so that any of those values will work. For example:
- living room; Synonyms:main room,large room
- dining room; Synonyms:night room,small room
- bathroom; Synonyms:bath room,rest room
You can then create commands using this type. For example:
Here you use the $light type as a placeholder so that any of the types of lights can apply there.
After creating this type and command you'll be able to say any of these
- Turn on my living room light
- Turn on my small room light
- Turn on my bath room light
and the same natural language command will always be triggered and the light variable will have a different room name in each case.
Reference Mode
You can define types in 2 ways: Synonym mode and Reference mode
To toggle between these, touch a type in the list and select Toggle Reference Mode
With the default Synonym mode you simply define a base value and a list of synonyms for each item like shown above
With Reference mode you can reference other types and create Composite Types.
For example, if you create a type called light-state it could have these entries:
- @light:light light @state:state
- @state:state my @light:light
- @state:state the @light:light
You can then create commands using this type. For example:
- Turn $light-state light
- Turn $light-state
After creating this type and command you'll be able to say any of these
- Turn bath room light on
- Turn on my living room light
- Turn off the small room light
Notice how the commands here match the patters above.
For example @state:state my @light:light means that you want a state (on or off), followed by the word "my", followed by the name of a light. This matches the command "Turn on my living room light"
Full tutorial for this example
here.
Composite Types in Tasker
When you receive a command that uses a composite type in Tasker, the variable will be a JSON string containing the values. You can then read these using
AutoTools JSON Read
For example, if you receive a light-state variable in Tasker you would get something like
{"light":"bath room","state":"on"}
As you can see the same variable contains both the name of the light and the state.
Again full tutorial for this example
here.