Skip to content

Instantly share code, notes, and snippets.

@TMcManus
Created March 8, 2012 01:18
Show Gist options
  • Select an option

  • Save TMcManus/1997785 to your computer and use it in GitHub Desktop.

Select an option

Save TMcManus/1997785 to your computer and use it in GitHub Desktop.
Simple Twilio Conditional Logic
---- Setting up this script ----
1) Upload these files to a location that is publicly accessible on the internet.
2) Enter the URL of the file named "index.xml" into the Voice Request URL of the number you want to setup.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="switch.php" method="POST">
<Say>To listen to a robot speak, press 1.</Say>
<Say>To call a fake movie number, press 2.</Say>
</Gather>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>You selected 1, so you get to speak to a robot!</Say>
<Pause length="2"/>
<Say voice="woman">I just paused for 2 seconds, and now I'm a female robot, apparently...</Say>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>You are about to dial a fake number, which won't work. Try replacing this with a real number.</Say>
<Dial>+15555555555</Dial>
</Response>
<?php
switch ($_REQUEST['Digits']):
case '1':
include('option-1.xml');
break;
case '2':
include('option-2.xml');
break;
default:
include('index.xml');
endswitch;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment