Tropo is part of CiscoLearn More

5 Steps To Ask Complete Questions

If you haven’t already, we definitely recommend reading the Asking a Question example first, as this example builds on that one. It could be confusing otherwise.

A slightly more advanced version of the Tropo ask method has five steps:

  1. Provide Tropo the question you want the user to answer.
  2. Provide Tropo with a list of possible choices.
  3. Optional: Change the default settings Tropo uses for your “ask”
  4. Optional: Handle cases where the user does nothing or makes a bad choice.
  5. Take action based on what choice the user selects.

Tropo has several optional parameters you can set that control the behavior of an ask. For example, let’s say you want to repeat your question when the user doesn’t respond to it before the default 30 second timeout occurs. You can set the optional attempts parameter to ask the question up to three times before giving up:

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

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

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

That's not the only optional parameter you can set, however. Next chapter explains adding a timeout.