Announcements
A couple of items in the news from last week:
Design Notebooks
Let’s take a few minutes to discuss your Design Notebooks.
Voice Menus
SMS is great, but…
- Only supports 160 characters
- Assumes the device supports a language you understand well enough
- Assumes you can read and write
What languages do the most common devices support?
What countries support local phone numbers for Twilio?
Twilio International – Global Reach, Local Experience
Twilio Voice
In addition to SMS, Twilio supports voice. You can use voice using Twilio’s text-to-speech engine, or use recorded messages. Today we’ll be using the text-to-speech engine.
- Download the source code for this week’s examples from the class Github Organization.
- Unzip the repository on your local machine and upload the contents to a new folder in the ‘www’ folder on your TCNJ web account.
- Let’s try out the examples one by one.
Basic Voice
- After you’ve uploaded the basic-voice.xml file to your TCNJ web account, log into Twilio, click into your number detail page, and edit the Voice request url for your number to point to ‘basic-voice.xml’.
- Call your Twilio number.
- What happened?
<!-- basic-voice.xml -->
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
Response
>
<
Say
>Hello Twilio!</
Say
>
</
Response
>
Voice Attribute
Let’ experiment. Take a look at the documentation for the <Say> command paying particular attention to the ‘voice’ attribute.
- Try changing the voice for your app.
- Re-upload the your file to your TCNJ web account and edit the Voice request url for your number to point to your edited file.
- Call your Twilio number.
- What happened?
Langauge Attribute
- Once you’ve successfully changed the voice, try changing the language.
- Re-upload the your file to your TCNJ web account and edit the Voice request url for your number to point to your edited file.
- Call your Twilio number.
- What happened?
Twilio Voice Request Variables
Similar to our experience last week sending SMS messages, TwiML for Voice also supports a number of request variables we can access. Like last week, we can use this to create a simple phone book so we can recognize callers.
- Change (or add) the phone record in the phone book array in your source code.
- Re-upload the your file to your TCNJ web account and edit the Voice request url for your number to point to voice-request-vars.php.
- Call your Twilio number.
- What happened?
<!-- voice-request-vars.php -->
<?php $from = $_REQUEST["From"]; // make an associative array of senders we know, indexed by phone number $phonebook = array( "+12152642459"=>"Professor Thompson", ); $name = "étranger"; // if the caller is in our phonebook, then greet them by name // otherwise, refer to them as étranger if(isset($phonebook[$_REQUEST['From']])) { $name = $phonebook[$_REQUEST['From']]; } header("content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?><
Response
>
<Say voice="alice" language="fr-FR">Allô <?php echo $name ?>.</Say>
<Response>
Gathering Input
Now let’s see if we can gather information interactively from the user.
- Upload numbergame.xml and checknumber.php to your TCNJ web account and edit the Voice request url for your number to point to your edited file.
- Call your Twilio number.
- What happened?
<!-- numbergame.xml -->
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
Response
>
<
Gather
action="./check_number.php" method="get"
finishOnKey
=
"*"
>
<
Say
>I'm thinking of a number between 1 and 10, enter the number then press star.</
Say
>
</
Gather
>
</
Response
>
/* checknumber.php */
<?php
$number = 5;
$guess = $_REQUEST
[
'Digits'
];
header("content-type: text/xml");
echo
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
;
if($guess == $number){
echo
"<Response>";
echo "<Say>Correct. The number was ".$number.". You win!
</Say>";
echo "</Response>"
;
} else {
echo
"<Response>";
echo "<Say>Incorrect. Guess again.
</Say>";
echo "<
Redirect
method
=
"POST"
>http://yourserver/numbergame.xml</
Redirect
>";
echo
"</Response>";
}
Navigating a Tree
Now let’s navigate a simple voice menu.
- Upload class-menu.xml and class-menu-processor.php to your TCNJ web account and edit the Voice request url for your number to point to your edited file.
- Call your Twilio number.
- What happened?
- How could you improve the user’s experience?
<!-- class-menu.xml -->
<?xml version="1.0" encoding="UTF-8"?> <Response> <Gather action="./class-menu-processor.php" numDigits="1"> <Say>Welcome to Interactive Design for the Developing World, Spring 2015.</Say> <Say>For the course description, press 1.</Say> <Say>For the course location and meeting time, press 2.</Say> <Say>To leave a message for the instructor, press 3.</Say> </Gather> <!-- Timeout defaults to 5 seconds, if customer doesn't input anything, redirect to prompt and try again. --> <Say>Sorry, I didn't get your response.</Say> <Redirect>./class-menu.xml</Redirect> </Response>
/* class-menu-processor.php */
<?php $selection = (int) $_REQUEST['Digits']; header('Content-type: text/xml'); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo '<Response>'; switch($selection){ case 1: echo "<Say>For many in the United States...</Say>"; break; case 2: echo "<Say>I M M 470 0 3, meets every Monday morning, 9 30 a m to 12 20 p m, in A I M M 2 22.</Say>"; break; case 3: echo "<Dial>215-264-2459</Dial>"; break; default: echo "<Say>I didn't understand your selection.</Say><Redirect>./class-menu.xml</Redirect>"; break; } echo '</Response>'; ?>
Initiating A Call
Let’s look at how you can call out to initiate an interactive phone menu. This won’t work from your TCNJ account. You’ll need other outside hosting or to run something like MAMP on your local machine.
Other TwiML Verbs
TwiML – the Twilio Markup Language
Challenge
- Break up into teams along the lines of the partner organization you chose as part of last week’s assignment.
- Create a voice menu for your selected partner organization, including options for the most important informational elements of your chosen organization (program, hours of operation, location, etc.).
- What language would you use if you complete control over language?
- How might you use SMS in support of your voice menu?
Assignment
SMS & IVR
Create a new page in your Design Notebook and name it “SMS & IVR” along with today’s date.
- Read the Real World Examples chapter in the Freedom Fone User & Advocacy Guide.
- Identify one (or more) of the examples and explain how a similar approach might work with your favorite Partner Organization from last week’s assignment.
Other Examples in the “Wild”
Create another page in your Design Notebook, naming it “SMS & IVR Examples” and today’s date.
- Demonstrating your Google-foo, search the web for other SMS and/or IVR projects that have been implemented by organizations like your favorite Partner Organization from last week.
- Has the project been successful? How specifically did they engage with their audience(s) and with what technologies (SMS, IVR, 3rd party messaging apps, etc)? Could you replicate their project for your organization? What would you do differently?
*Assignments are due before class begins on Mondays. Be prepared to present your work in class for discussion.
https://docs.google.com/a/apps.tcnj.edu/presentation/d/1kmo7knd0-xt9sywFIiwLWxSTbM2aeriwI6E2wGP8fa4/edit?usp=sharing
https://docs.google.com/a/apps.tcnj.edu/presentation/d/191E2GYH1d4MST_5nx0x4kJOTI-g6gQhwxiLMSB8UH2o/edit#slide=id.g106d75872b617a921
https://docs.google.com/presentation/d/1z5jDARfB0KlyNUTm9ONok04viUkPhWaCdkDr31lgFoI/edit?usp=sharing
https://docs.google.com/a/apps.tcnj.edu/presentation/d/17t0CK-LhVvbBRRCbxOlePV9V9ihQ-LJ97x-jMP8-dQk/edit?usp=sharing
https://docs.google.com/a/apps.tcnj.edu/presentation/d/13rgyeAPdF04T9dQnaOE649MLSvhXNquPLCgv2KRz4Bw/edit?usp=sharing
https://docs.google.com/presentation/d/1xciwBlJNwFPcthMIZEcwlv5vZgNDwDUZmiTswgJo8yk/edit?usp=sharing
https://docs.google.com/presentation/d/1cYirAOqObF3T9q44yTitnSpkraRS_Dcbq6MqbSsAJxo/edit?usp=sharing
https://docs.google.com/presentation/d/1Ku9wovnVXvjVCIY4T2YPh1Tme36NtllxrRN_en_Oolo/edit?usp=sharing
https://docs.google.com/a/apps.tcnj.edu/presentation/d/1gZ0HFSUH8Kx-GAkzj7EY6KvYC3Qi0v1jyJtio9fSFqg/edit#slide=id.g694671d67_00
https://docs.google.com/a/apps.tcnj.edu/presentation/d/1kFAAXg-q0PWNjHmD30QrkHz4PcU__-2gxQ53wJN9s8I/edit?usp=sharing
https://docs.google.com/presentation/d/1B-SKdwz1Qm6yDukf6K9O_ZsADyh8Gdw7XdRewfeIWKs/edit?usp=sharing
https://docs.google.com/a/apps.tcnj.edu/presentation/d/1nJGpo9O9j_Dm8Ksp0PngsBhdD655crWrsvO6QjLJZuo/edit#slide=id.g694707a08_00
https://docs.google.com/presentation/d/1pCthkUQ4Zb5b4ASolS7vk0Zh_vYpXu6mT9MMten3CgQ/edit?usp=sharing
https://docs.google.com/presentation/d/11x0ddyuC0KF_gk3Z9sT5KkwvhiBrGBGxFB0RPr3lmNc/edit?usp=sharing
https://docs.google.com/presentation/d/1IcWhm8d_Le29JDrr8AVAZctLMiOKAOYobFlPtYV56JI/edit?usp=sharing
Here is the design doc…
https://docs.google.com/a/apps.tcnj.edu/presentation/d/1-BIaIuVIkvEFJFui84eHSqkTC3h3VF4zyuvtEiggb74/edit#slide=id.g68966c5ba_05