Search code examples
win-universal-appcortana

How to set Cortana Command ListenFor just with a destination?


I am currently working on Cortana integration in my app, in that I am trying to do something like below

<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

  <CommandSet xml:lang="en-us" Name="NearbyCommandSet_en-us">
    <AppName> Nearby </AppName>
    <Example> Nearby sign out from the app</Example>

    <Command Name="actionCommands">
      <Example> sign out from the app </Example>
      <ListenFor RequireAppName="BeforeOrAfterPhrase"> {destination} </ListenFor>
      <Feedback> Signing Out from the app</Feedback>
      <Navigate />
    </Command> 

    <PhraseList Label="destination">
      <Item>Sign Out</Item>
    </PhraseList>
  </CommandSet>

</VoiceCommands>

I have a command sign out and I want to say to Cortana "Nearby Sign Out", this is not working, but When I change the ListenFor like below it is working.

<ListenFor RequireAppName="BeforeOrAfterPhrase"> {destination} from app</ListenFor>

When I mention just the command {destination} it is not working. My requirement is to just say "Nearby Sign Out"

How can I achieve this, is it possible to implement with just a command inside ListenFor?

Thanks.


Solution

  • In your PhraseList, the label is set to "destination", change it to "action". In addition, if you want to have an optional term, use square brackets as below.

    <ListenFor RequireAppName="BeforeOrAfterPhrase">{destination} [from app]</ListenFor>
    

    Please let me know if you still have the same issue.

    Edit. You can also try to add two instructions in the same Command if you want both.

    <ListenFor RequireAppName="BeforePhrase">{destination} [from app]</ListenFor>
    <ListenFor RequireAppName="AfterPhrase">{destination} [from app]</ListenFor>