function app_choice() { // Accessing the result object $result = new Result(); $choice = $result->getValue(); // Create a new instance of the Tropo object. $tropo = new Tropo(); // Provide a prompt based on the value if ($choice == "1") { $tropo->say("You picked Lord of the Rings. Did you know Gandalf is also Mag knee toe? Weird."); } if ($choice == "2") { $tropo->say("You picked the original Star Wars. I hear Leonard Nimoy was awe some in those."); } if ($choice == "3") { $tropo->say("You picked the Star Wars prequels. Stop calling this number, Mr. Lucas, we know it's you."); } if ($choice == "4") { $tropo->say("You picked the Matrix. Dude, woe."); } // Tell Tropo what to do next. This redirects to the instructions under dispatch_post('/hangup', 'app_hangup'). $tropo->on(array("event" => "continue", "next" => "favorite-movie-webapi.php?uri=hangup")); // Tell Tropo what to do if there's an problem, like a timeout. This redirects to the instructions under dispatch_post('/incomplete', 'app_incomplete'). $tropo->on(array("event" => "incomplete", "next" => "favorite-movie-webapi.php?uri=incomplete")); // Render the JSON for the Tropo WebAPI to consume. return $tropo->RenderJson(); }
public function voice_continue() { $this->set_output_mode(MY_Controller::OUTPUT_NORMAL); $tropo = new Tropo(); @($result = new Result()); $answer = $result->getValue(); $tropo->say("You said " . $answer); $tropo->RenderJson(); }
function zip_end() { // Create a new instance of the result object and get the value of the user input. $result = new Result(); $zip = $result->getValue(); // Create a new instance of the Tropo object. $tropo = new Tropo(); // Get the weather information for the entered zip code. formatWeatherResponse($tropo, $zip); // Render the JSON for the Tropo WebAPI to consume. return $tropo->RenderJson(); }
function conference() { global $voice; $tropo = new Tropo(); $tropo->setVoice($voice); $result = new Result(); $conference = $result->getValue(); $tropo->say('<speak>Conference ID <say-as interpret-as=\'vxml:digits\'>' . $conference . '</say-as> accepted.</speak>'); $tropo->say('You will now be placed into the conference. Please announce yourself. To exit the conference without disconnecting, press pound.'); $tropo->conference($conference, array('id' => $conference, 'terminator' => '#')); $tropo->say('You have left the conference.'); $tropo->on(array("event" => "continue", "next" => "restart")); $tropo->RenderJson(); }
function demo_end() { $result = new Result(); $zip = $result->getValue(); $weather_info = getWeather($zip); $city = array_pop($weather_info); $tropo = new Tropo(); $tropo->say("The current weather for {$city} is..."); foreach ($weather_info as $info) { $tropo->say("{$info}."); } $tropo->say("Thank you for calling. Goodbye."); $tropo->hangup(); return $tropo->RenderJson(); }
// Build a grammar with the venue ID as the concept and the name and // dtmf tone as options. Strip certain characters from venue names that // might cause the grammar engine to choke $choices .= "{$venue['id']} (" . cleangrammar($venue['name']) . ", {$dtmf}), "; $dtmf++; } } // We allow the caller to say the name of the venue with voice recognition or to press // or say the number of the venue. $tropo->say('Speak the name of the venue or press it\'s number.'); $tropo->ask($say, array('choices' => $choices, 'required' => true, 'attempts' => 3, 'timeout' => 30, 'bargein' => true)); } if ($action == 'checkin') { // This is the result of the question being answered $result = new Result(); $vid = $result->getValue(); if ($vid) { // If we have a value back, it's because the input matched. // So take that venue ID and check in here. $checkin = getapi('checkin', array('vid' => $vid), 1, 'POST'); // We're going to speak the foursquare result message to them $message = $checkin['checkin']['message']; // Is there a new Mayor? if so, let them know! if ($checkin['checkin']['mayor']['type'] != 'nochange') { $message .= ' ' . $checkin['checkin']['mayor']['message']; } $tropo->say($message); } else { // No value came back, so there was no match. Let the user know we // can't help. // An interesting enhancement here would be to look for a lack of matches