Tropo is part of CiscoLearn More

Concepts & Vocabulary

Here's a company directory that starts off by welcoming the user, then asks the user who they’re trying to reach; this can be the name of a person or department. Depending on the type selected (person or department), one of two web services is called to play back the contact information.

ask("Welcome to the Tropo company directory. Who are you trying to reach?", {
    choices:"department(support, engineering, sales), person(jose, jason, adam)",
    onChoice: function(event) {
        say("You said " + event.choice.interpretation + ", which is a " + event.value);
    }
});
ask "Welcome to the Tropo company directory.  Who are you trying to reach?", {
    :choices => "department(support, engineering, sales), person(jose, jason, adam)",
    :onChoice => lambda { |event| 
        say("You said " + event.choice.interpretation + ", which is a " + event.value)    
    }
}
<?php
    ask("Welcome to the Tropo company directory. Who are you trying to reach?", 
        array(
          "choices"=>"department(support, engineering, sales), person(jose, jason, adam)",
          "onChoice" => "choiceFCN"
        )
    );
    function choiceFCN($event) {
        say("You said " . $event->choice->interpretation . ", which is a " . $event->value);
        }
?>
def choiceFCN(event):
    if (event.name == "choice"):
        say("You said " + event.choice.interpretation + ", which is a " + event.value)

event = ask("Welcome to the Tropo company directory.  Who are you trying to reach?", {
    "choices":"department(support, engineering, sales), person(jose, jason, adam)",
    "onChoice":choiceFCN})
ask("Welcome to the Tropo company directory.  Who are you trying to reach?", [
    choices: "department(support, engineering, sales), person(jose, jason, adam)",
    onChoice: { event->
        say "You said " + event.choice.interpretation + ", which is a " + event.value}
])

There’s a lot going on in this short example so let’s break it down.

First, we tell Tropo to speak the introductory prompt which asks the user who they’d like to reach. We pass in two parameters to the ask method: choices and onChoice. The choices parameter instructs Tropo to listen for a set of words; in this case, department and people names. The key thing here is the notation used to define the grammar:

    department(support, engineering, sales), person(jose, jason, adam)

The words outside the parentheses are called concepts. Concepts provide a context when handling the user’s response. The company directory grammar defines two concepts: department and person. When the caller says one of the items inside the parentheses (such as support, jose, etc.), an event is triggered that gives us access to both the spoken word and the concept to which it belongs.

Speech recognition is language and accent specific. The default language that Tropo recognizes speech for is US accented English, but you can change the language by setting the "recognizer" property of Ask

Note that Simple Grammar only accepts single-byte characters. Multibyte characters such as Japanese, Arabic, or Hindi are not supported. To perform speech recognition for a language that uses a multi-byte character set, use Tropo's GrXML support.