I have a Cortana XML file and I need to input a number. What should I do to ensure I can convert it to a number?
<Command Name="AddMoney">
<Example> Add 10 dollars </Example>
<ListenFor> add {amount} {currency} </ListenFor>
<Feedback> Adding some money </Feedback>
<Navigate/>
</Command>
<PhraseList Label="currency">
<item>dollar</item>
<item>euro</item>
<item>pound</item>
</PhraseList>
<PhraseList Label="amount">
</PhraseList>
I found a way to receive numbers, but it is not perfect.
<PhraseTopic Label="amount" Scenario="Commands">
<Subject>Phone Number</Subject>
</PhraseTopic>
Note I'm using PhraseTopic instead of PhraseList. I don't really know which Scenario
is the best here, but I found Commands
to yield better results than having no Scenario
set. The PhraseTopic tag must be placed after all PhraseList tags for some odd reason...
When trying subjects, the auto complete feature showed a few options where the most promising were Date/Time
, Addresses
and Phone Number
. When trying with multiple subjects I could never have a match, but with "Phone Number" (or just "Number" even if there's no such option) I was able to receive number values somewhat consistently.
The number cames in digits form, so I only need int.TryParse(myText, out myNumber)
and use it or say something as "invalid number input".
Be aware that any thing can be input here, even with the subject and scenario restrictions... The folowing will work:
"Hey Cortana, MyAppName add blah blah blah dollars"
And the amount will literally be "blah blah blah"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With