Tropo is part of CiscoLearn More

choice

The event structure contains additional available levels in the "choice" object, with various uses:

  • event.choice.concept - Only tags or concepts returned from recognition.
  • event.choice.interpretation - Full semantic interpretation of the results.
  • event.choice.utterance - What the caller actually input before interpretation.
  • event.choice.confidence - The ASR engine's confidence in the result
  • event.choice.xml - The raw NLSML result returned from the underlying MRCP engine.

We'll show one of the most common uses in the following examples - "event.choice.interpretation".

Examples

  ask("Please press say support or sales to select your preferred department", { 
	attempts:3, 
	choices:"support(Kevin, support), sales(Kris, sales)", 
	onChoice:function(event) { 
		if (event.choice.interpretation == "Kevin") {
    		say("You selected " + event.value);
    	}
		else if (event.choice.interpretation == "Kris") {
    		say("You selected " + event.value);
    	}
	}
});    
ask "Please press say support or sales to select your preferred department", { 
  :attempts => 3, 
  :choices => "support(Kevin, support), sales(Kris, sales)",
  :onChoice => lambda { |event| 
    if event.choice.interpretation == "Kevin" 
        say "You selected, #{event.value}"
    elsif event.choice.interpretation == "Kris"  
        say "You selected, #{event.value}"
    end 
    }
}
<?php 

ask("Please say support or sales to select your preferred department", array( 
	"attempts" => 3, 
	"choices"=>"support(Kevin, support), sales(Kris, sales)", 
	"onChoice" => "ChoiceFCN" )); 

function ChoiceFCN($event) { 
	if ($event->choice->interpretation == "Kevin") {
    	say("You selected " . $event->value);
    	}
	elseif ($event->choice->interpretation == "Kris") {
    	say("You selected " . $event->value);
    }
}

?>
ask("Please say support or sales to select your preferred department", { 
  "attempts":3, 
  "choices":"support(Kevin, support), sales(Kris, sales)", 
  "onChoice": lambda event : 
        say("You selected " + event.value) if event.choice.interpretation == "Kevin" 
        else say("You selected " + event.value) if event.choice.interpretation == "Kris" 
        else say("You selected " + event.value)
})
ask("Please press say support or sales to select your preferred department", [ 
	attempts:3, 
	choices:"support(Kevin, support), sales(Kris, sales)", 
	onChoice:{event->  
		if (event.choice.interpretation == "Kevin") {
    		say("You selected " + event.value);
    	}
		else if (event.choice.interpretation == "Kris") {
    		say("You selected " + event.value);
    	}
	}
]);