Created
February 25, 2010 14:11
-
-
Save mheadd/314557 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
Options +FollowSymlinks | |
Options +Indexes | |
RewriteEngine on | |
RewriteCond %{SCRIPT_FILENAME} !-f | |
RewriteCond %{SCRIPT_FILENAME} !-d | |
RewriteRule ^(.*)$ index.php?/$1 | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Include the Limonade Framework (http://limonade.sofa-design.net/). | |
include('limonade/lib/limonade.php'); | |
// Include Cloudvox JSON helper classes (See Gist 308081). | |
include('cloudvox-json-http-classes.php'); | |
// Variable that will be references in dispatch functions for postbacks. | |
$scriptName = 'http://'.$_SERVER['SERVER_ADDR'].$_SERVER['PHP_SELF']; | |
dispatch_get('/start', 'cloudvox_start'); | |
function cloudvox_start() { | |
global $scriptName; | |
// Skip the intro message if reprompting caller. | |
$playWelcome = (isset($_REQUEST['playWelcome'])) ? false : true; | |
$speak = new Speak("Welcome to my demo application."); | |
$playback = new Playback("enter-phone-number10"); | |
$getDigits = new GetDigits(10,5); | |
$getDigits->url = $scriptName."/phone"; | |
if($playWelcome) { | |
Output::renderJSON($speak, $playback, $getDigits); | |
} else { | |
Output::renderJSON($playback, $getDigits); | |
} | |
} | |
dispatch_get('/phone', 'phone_verify'); | |
function phone_verify() { | |
global $scriptName; | |
// Instantiate a new CloudVox response object. | |
$response = new CloudVoxResponse(); | |
// Insert spaces in between each digit in the phone number to improve readback. | |
$phoneNumber = implode(" ", str_split($response->result)); | |
$playback_youentered = new Playback("you-entered"); | |
$speak_phone = new Speak($phoneNumber); | |
$playback_correct = new Playback("if-this-is-correct"); | |
$playback_press1 = new Playback("press-1"); | |
$playback_notcorrect = new Playback("if-this-is-not-correct"); | |
$playback_press2 = new Playback("press-2"); | |
$getDigits = new GetDigits(1,5); | |
$getDigits->url = $scriptName."/confirm"; | |
Output::renderJSON($playback_youentered, $speak_phone, $playback_correct, | |
$playback_press1, $playback_notcorrect, $playback_press2, | |
$getDigits); | |
} | |
dispatch_get('/confirm', 'confirm_response'); | |
function confirm_response() { | |
global $scriptName; | |
// Instantiate a new CloudVox response object. | |
$response = new CloudVoxResponse(); | |
// We need to create playback elements for both confirmation scenarios. | |
$playback_sorry = new Playback("im-sorry"); | |
$playback_try_again = new Playback("please-try-again"); | |
$include = new IncludeStep($scriptName."/start?playWelcome=false"); | |
$playback_thanks = new Playback("thanks-for-calling-today"); | |
$playback_goodbye = new Playback("goodbye"); | |
$hangup = new Hangup(); | |
// If the caller confirmed their response, end the call, if not start over. | |
if($response->result != 1) { | |
Output::renderJSON($playback_sorry, $playback_try_again, $include); | |
} | |
else { | |
Output::renderJSON($playback_thanks, $playback_goodbye, $hangup); | |
} | |
} | |
// Don't forget to run this puppy. | |
run(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment