BotBuilder-Samples
BotBuilder-Samples copied to clipboard
Add unit conversions to age, dimension, temperature
With $units we know enough to be able to automatically convert dimension units, i.e. $units = feet, convert kilometer, hectometer, inches, etc. and vice versa. We can also convert areas and perhaps as a bonus currency although that requires an API call to an exchange. I suspect the best way to do this is to create some custom LG functions to do the conversion, i.e.
# convert(entity, desiredUnits)
- SWITCH:
- CASE ${'Inches')
- SWITCH ${entity.units}
- CASE ${'Inches'}
...
and perhaps
# canConvert(entity, desiredUnits)
Then we can use those in the generated dialogs to convert units automatically or complain about not being able to convert. For example if $units = Inches.
"3 feet" would automatically be converted to "36 inches"
"3 square meters" would complain "expected inches"
etc.
We also need to add combination logic, i.e. "6 foot 1 inches" results in this:
"dimension": [
{
"number": 6,
"units": "Foot"
},
{
"number": 1,
"units": "Inch"
}
]