Tropo is part of CiscoLearn More

Asking a Question

The most fundamental of needs - asking a question and processing the answer. A typical ask has three steps:

  1. Provide Tropo the question you want the user to answer.
  2. Provide Tropo with a list of possible choices.
  3. Take action based on what choice the user selects.

Here’s a basic example that asks the caller their favorite color, repeats it back to her, and records the result in the log.

var result = ask("What's your favorite color?  Choose from red, blue or green.", {
   choices:"red, blue, green"
});
say("You said " + result.value);
log("They said " + result.value);
result = ask "What's your favorite color?  Choose from red, blue or green.", {
   :choices => "red, blue, green"}
say "You said " + result.value
log "They said " + result.value
<?php

$result = ask("What's your favorite color?  Choose from red, blue or green.", array(
   "choices" => "red, blue, green"
));
say("You said" . $result->value);
_log("They said " . $result->value);

?>
result = ask("What's your favorite color? Choose from red, blue or green.", {
   "choices":"red, blue, green"})
say("You said " + result.value)
log("They said " + result.value)
result = ask("What's your favorite color? Choose from red, blue or green.", [
   choices: "red, blue, green"])
say("You said $result.value")
log("They said $result.value")

The caller makes her choice by speaking, and Tropo recognizes and interprets the speech. Tropo provides high-quality automatic speech recognition (ASR) in nearly 80 languages, at no additional cost. The default speech recognition works with US accented English, and you can change this in your code. We'll show how to change speech recognition languages in a later guide.