Tropo is part of CiscoLearn More

attempt

This allows you to set behavior for an individual attempt (the number of possible attempts is defined by the "attempts" parameter in the ask method).

In the following examples, attempts is defined as 3, so Tropo will repeat the prompt three times if the user does not select the correct answer. For event.attempt 1 and event.attempt 2, different behavior is defined.

Examples

  ask("Please press 1.", { 
	attempts:3, 
	choices:"1", 
	mode:"dtmf", 
	onBadChoice:function(event) { 
		switch(event.attempt) { 
			case 1: say("Invalid choice."); 
			break; 
			case 2: say("Still invalid."); 
			} 
		} 
	}
);  
ask "Please press 1.", { 
  :attempts=>3, 
  :choices=>"1", 
  :mode=>"dtmf", 
  :onBadChoice => lambda { |event| 
    case event.attempt 
      when 1 
        say "Invalid choice." 
      when 2 
        say "Still invalid."
    end 
    }
}
<?php 

ask("Please press 1.", array( 
	"attempts" => 3, 
	"choices"=>"1", 
	"mode" => "dtmf", 
	"onBadChoice" => "badChoiceFCN" )); 

function badChoiceFCN($event) { 
	switch($event->attempt){ 
		case 1: say("Invalid choice."); 
		break; 
		case 2: say("Still invalid."); 
		break; 
		} 
	} 

?>
ask("Please press 1.", { 
	"attempts":3, 
	"choices":"1", 
	"mode":"dtmf", 
	"onBadChoice": lambda event : say("Invalid choice.") if event.attempt == 1 else say("Still invalid.") 
	}
)
ask("Please press 1.", [ 
	attempts:3, 
	choices: "1", 
	mode: "dtmf", 
	onBadChoice: { 
		event-> switch(event.attempt){ 
			case 1: say("Invalid choice.") 
			break 
			case 2: say("Still invalid.")
		}
	}
])