CEWOD

Contacts

CEWOD

(Primary) Digna Peter, digner_peter [at] yahoo.com

  • Bridget McGraw, info [at] bridgetmcgraw.com

TCNJ

(Primary) Prof. Mark Thompson, thompsom [at] tcnj.edu

  • Brianna D’Anton, dantonb1 [at] tcnj.edu
  • Maria Molina, molinam3 [at] tcnj.edu
  • Melissa Sheu, sheum1 [at] tcnj.edu
  • Samantha Mills, millss2 [at] tcnj.edu

Resources

Vision Document

 

Current Progress

  • Dongle issues / Dongle disappeared
  • Frontline SMS Groups, Subscription & Notification
  • Talked about possible poster designs (the only thing Digna really wanted)

Goals for next week

  • Begin coding / have some sort of baseline to work with
  • One poster design finished / possibly sent to Digna for feedback

TICAH Health 1 – Aunty Jane SMS System

Contacts

TICAH

(Primary) Sally Leiyan, sleiyan [at] ticahealth.org

  • Jeremiah Musyoka, jmusyoka [at] ticahealth.org
  • Bridget McGraw, info [at] bridgetmcgraw.com

TCNJ IMM

(Primary) Prof. Mark Thompson, thompsom [at] tcnj.edu

 

OUR TEAM

  • Kerrin McLaughlin,     mclaugk3 [at] tcnj.edu
  • Gabe Franc,                   francg1 [at] tcnj.edu
  • Adam Czaplinski,         czaplia1 [at] tcnj.edu
  • Alexander Young,        younga6 [at] tcnj.edu
  • Yu-sheng Tu,                 tuy1 [at] tcnj.edu

VISION DOCUMENT

http://bit.ly/ticahSMSProposal

PROJECT OVERVIEW

 

auntyjanesms-02

 

Our project’s goal is to create  an SMS counterpart to TICAH’s Aunty Jane service.  Aunty Jane is a hotline that allows users call questions about sexual and reproductive health. Our service will be utilized by TICAH directly, using automated functionality to read through the received messages. Our system will provide immediate, automated responses to inquiries by providing a list of SMS menus for the users to interact and receive information. For more specific questions the user will always have the option to get a personalized response back from a TICAH representative during operating hours. Our system will provide a solution to these problems community members face when using TICAH’s Aunty Jane service:

EDITING/EXTENDING THE SYSTEM

Basic Overview/Introduction to Text.in           – textit.in

Text.in Video Tutorials                                        – textit.in/video

Text.in Written Documentation                        – docs.textit.in

Resources

1000 Hills Community Helpers

Contacts
1000 Hills Community Helpers

  • Nathi , 1000hch [at] zamail.co.za
  • Dawn Leppan, 1000hch.dawn [at] zamail.co.za

TCNJ

  • (Primary) Prof. Mark Thompson, thompsom [at] tcnj.edu
  • Domenic Portera, porterd4 [at] tcnj.edu
  • Emma Dwight, dwighte1 [at] tcnj.edu
  • Isabelle Tan, tani1 [at] tcnj.edu
  • Niveda Harishankar, harishn1 [at] tcnj.edu

Resources

Project Summary

Our team worked with an organization in South Africa called 1000 Hills Community Helpers Center to create a Twitter Integrated SMS Alert System, as a way for the organization to remain in communication with their community members. The center can send out messages from the Twitter account that we set up for them and immediately reach different subset of their users. The members can subscribe to a list by texting a phone number with a keyword. There are three different keywords(#center, #class, #clinic).Members get texts specific to the keyword. Once subscribed, a confirmation text message is sent. Now, the user is subscribed to the list and will receive any tweets from the organization here on out that contains that specific keyword. We converted tweets to text messages to send it out the the members. There is a 140 character limit to Twitter posts so the text messages are within their limit.

A person who has subscribed to the center list will only get tweets that have “#center” in the sentence. The tweet below will only be received by  people who have subscribed to the center list.

Screen Shot 2015-05-14 at 6.15.53 AM

Often, community members travel distances to get access to the facilities of the center such as the clinic, schooling, daycare, etc. However, there is no portal for the organization to reach out to their audience and make announcements/provide updates except for word of mouth and sometimes, posters. This only reaches a fraction of their user base and is a necessary but inefficient process. We saw an opportunity in the high mobile penetration across the community to streamline this process. People used simple phones there for utilitarian purposes and we came to the conclusion that the best way to reach our audience was through SMS text messaging.

Take a look at our Demo Video .

 

Vision Document

Click the heading for the vision document for our project intended for the 1000 Hills Community Helpers Center.

 

Screen Shot 2015-05-04 at 11.18.34 AM
Basic project back-end flow chart

 

valley of 1000 hills poster
User Guide Poster

 

We used FrontlineSMS to create this application.

credit-n.ru

Twilio Polls

Announcements

Design Notebooks

Let’s take a few minutes to review some of your Design Notebook entries from last week.

Surveys

Why do we use surveys and questionnaires?

Survey Guide

Types of Survey Questions

  • Closed-ended Questions
  • Open-ended Questions

Types of Survey Questions on Explorable

Online Survey Tools

Here’s an example TCNJ Qualtrics Survey

Phone Polls

  1. Download the source code for this week’s examples from the class Github Organization.
  2. Unzip the  repository on your local machine and upload the contents to a new folder in the ‘www’ folder on your TCNJ web account.
  3. Let’s try out the examples one by one.

Basic Phone Interview Loop

flowchart_lg

Interview Loop with <Gather>

  1. After you’ve uploaded the poll_gather.xml and response.php files 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 ‘poll_gather.xml’.
  2. Call your Twilio number.
  3. What happened?
<!-- poll_gather.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Response>
 <!-- ask poll question, default finish key is # -->
 <Gather action="./response.php" method="get">
 <Say>Welcome to the 2015 Oscars phone poll.</Say>
 <Say>What film would you vote for for Best Picture?</Say>
 <Say>Press 1 for American Sniper.</Say>
 <Say>Press 2 for Birdman.</Say>
 <Say>Press 3 for Boyhood.</Say>
 <Say>Press 4 for The Grand Budapest Hotel.</Say>
 <Say>Press 5 for The Imitation Game.</Say>
 <Say>Press 6 for Selma.</Say>
 <Say>Press 7 for The Theory of Everything.</Say>
 <Say>Press 8 for Whiplash.</Say>
 <Say>Or press 9 to repeat these choices.</Say>
 </Gather>
</Response>
// response.php
<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';

// collect the selection number
$selection = (int) $_REQUEST['Digits'];

echo '<Response>';

switch($selection){
case 1:
echo "<Say>Thanks for your response. You chose American Sniper.</Say>";
break;

case 2:
echo "<Say>Thanks for your response. You chose Birdman.</Say>";
break;

case 3:
echo "<Say>Thanks for your response. You chose Boyhood.</Say>";
break;

case 4:
echo "<Say>Thanks for your response. You chose The Grand Budapest Hotel.</Say>";
break;

case 5:
echo "<Say>Thanks for your response. You chose The Imatation Game.</Say>";
break;

case 6:
echo "<Say>Thanks for your response. You chose Selma.</Say>";
break;

case 7:
echo "<Say>Thanks for your response. You chose The Theory of Everything.</Say>";
break;

case 8:
echo "<Say>Thanks for your response. You chose Whiplash.</Say>";
break;

case 9:
echo "<Say>O K. Redirecting back to the choices.</Say><Redirect>./poll_gather.xml</Redirect>";
break;

default:
echo "<Say>I didn't understand your selection.</Say><Redirect>./poll_gather.xml</Redirect>";
break;
}

// close out file pointer
fclose($fp);

echo '</Response>';
?>

Storing Responses to a File

  1. After you’ve uploaded the poll_gather_data.xml, record_data.php and data.txt files 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 ‘poll_gather_data.xml’.
  2. Call your Twilio number.
  3. What happened?
  4. Now point your web browser to http://www.tcnj.edu/~your-user-name/your-folder/data.txt
  5. What do you see?

*A note on file permissions – these examples write the callers’ selections to a comma-separated file (csv). You’ll need to set the file permissions on your data file to ‘read & write’ with settings 666.

<!-- poll_gather_data.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Response>
 <!-- ask poll question, default finish key is # -->
 <Gather action="./record_data.php" method="get">
 <Say>Welcome to the 2015 Oscars phone poll.</Say>
 <Say>What film would you vote for for Best Picture?</Say>
 <Say>Press 1 for American Sniper.</Say>
 <Say>Press 2 for Birdman.</Say>
 <Say>Press 3 for Boyhood.</Say>
 <Say>Press 4 for The Grand Budapest Hotel.</Say>
 <Say>Press 5 for The Imatation Game.</Say>
 <Say>Press 6 for Selma.</Say>
 <Say>Press 7 for The Theory of Everything.</Say>
 <Say>Press 8 for Whiplash.</Say>
 <Say>Or press 9 to repeat these choices.</Say>
 </Gather>
</Response>
// record_data.php
<?php
 header('Content-type: text/xml');
 echo '<?xml version="1.0" encoding="UTF-8"?>'; 
 
 // collect the selection number
 $selection = (int) $_REQUEST['Digits'];
 // collect the caller's phone number
 $from = $_REQUEST["From"];
 // get the exact time of the response
 $t = time();
 // set the timezone
 date_default_timezone_set('America/New_York');
 // open a file ponter to write our data
 $fp = fopen("data.txt", "a");
 
 echo '<Response>';
 
 switch($selection){
 case 1:
 // write the callers phone number, selection, a timestamp of the record
 fwrite($fp, $from . ',Best Picture,American Sniper,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose American Sniper.</Say>";
 break;
 
 case 2:
 // write the callers phone number, selection, a timestamp of the record & respond
 fwrite($fp, $from . ',Best Picture,Birdman,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose Birdman.</Say>";
 break;
 
 case 3:
 // write the callers phone number, selection, a timestamp of the record
 fwrite($fp, $from . ',Best Picture,Boyhood,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose Boyhood.</Say>";
 break;
 
 case 4:
 // write the callers phone number, selection, a timestamp of the record & respond
 fwrite($fp, $from . ',Best Picture,The Grand Budapest Hotel,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose The Grand Budapest Hotel.</Say>";
 break;
 
 case 5:
 // write the callers phone number, selection, a timestamp of the record
 fwrite($fp, $from . ',Best Picture,The Imitation Game,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose The Imatation Game.</Say>";
 break;
 
 case 6:
 // write the callers phone number, selection, a timestamp of the record 
 fwrite($fp, $from . ',Best Picture,Selma,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose Selma.</Say>";
 break;
 
 case 7:
 // write the callers phone number, selection, a timestamp of the record
 fwrite($fp, $from . ',Best Picture,The Theory of Everything,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose The Theory of Everything.</Say>";
 break;
 
 case 8:
 // write the callers phone number, selection, a timestamp of the record
 fwrite($fp, $from . ',Best Picture,Whiplash,' . date("c", $t) . "\n");
 echo "<Say>Thanks for your response. You chose Whiplash.</Say>";
 break;
 
 case 9:
 echo "<Say>O K. Redirecting back to the choices.</Say><Redirect>./poll_gather_data.xml</Redirect>";
 break; 
 
 default:
 echo "<Say>I didn't understand your selection.</Say><Redirect>./poll_gather_data.xml</Redirect>";
 break;
 }
 
 // close out file pointer
 fclose($fp);
 
 echo '</Response>';
?>

Interview Loop with <Record>

  1. After you’ve uploaded the poll_record_data.xml and recording.php files 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 ‘poll_record_data.xml’.
  2. Call your Twilio number.
  3. What happened?
  4. Now point your web browser to http://www.tcnj.edu/~your-user-name/your-folder/data.txt
  5. What do you see?
<!-- poll_record_data.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Response>
 <Say>Welcome to the 2015 Oscars Phone Poll</Say>
 <Say>What was your favorite movie last year? Record your answer at the beep. Press the pound key when you're done recording.</Say>
 <Record 
 action="http://www.tcnj.edu/~your-username/your-folder/recording.php"
 method="GET"
 maxLength="20"
 finishOnKey="#"
 />
</Response>
<?php
 header("content-type: text/xml");
 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
 // collect the cller's phone number
 $from = $_REQUEST["From"];
 // get the exact time of the response
 $t = time();
 // set the timezone
 date_default_timezone_set('America/New_York');
 // open a file ponter to write our data
 $fp = fopen("data.txt", "a");
 
 // get the url to the voice recording
 $recording = $_REQUEST['RecordingUrl'];
 // get the duration of the voice recording
 $duration = $_REQUEST['RecordingDuration'];
 // write the data file
 fwrite($fp, $from . ',Favorite Movie this year,' . $recording . ',' . $duration . ',' . date("c", $t) . "\n");
?>
<Response>
 <Say>Thanks for taking our poll. Your favorite movie this year was</Say>
 <Play><?php echo $recording; ?></Play>
</Response>

An SMS Example

  1. After you’ve uploaded the sms_poll_data.php file to your TCNJ web account, log into Twilio, click into your number detail page, and edit the Messaging request url for your number to point to ‘sms_poll_data.php’.
  2. Call your Twilio number.
  3. What happened?
  4. Now point your web browser to http://www.tcnj.edu/~your-user-name/your-folder/data.txt
  5. What do you see?
<?php
 // we can get the number of the sender using the 'Fromn' request value
 $from = $_REQUEST['From'];
 $msg = $_REQUEST['Body'];
 
 header("content-type: text/xml");
 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 // get the exact time of the response
 $t = time();
 // set the timezone
 date_default_timezone_set('America/New_York');
 // open a file ponter to write our data
 $fp = fopen("data.txt", "a");
 switch($msg){
 case "poll":
 $out = "Thanks for taking our poll! Text us back with the name of your favorite movie from last year!";
 break;
 
 default:
 // write the data file
 fwrite($fp, $from . ',sms,Favorite Movie this year,' . $msg . ',' . date("c", $t) . "\n");
 $out = "Really? Your favorite film last year was " . $msg;
 break;
 }
 
 // close out file pointer
 fclose($fp);
?>
<Response>
 <Message><?php echo $out; ?></Message>
</Response>

Challenge

  1. Break up into your groups and compare notes on your list of questions for your Partner Organizations from last week’s assignment.
  2. Using the Phone Poll design pattern, create a Phone Poll app that asks 3 closed-ended questions and one open-ended question.
  3. Be sure to store the responses in a comma-separated (csv) file on your TCNJ web account.

Assignment

Partner Organization Interview and Follow-up Survey

  1. Meet with your team and combine all of your questions from last week’s assignment.
  2. Discuss your questions and determine if there are any other questions that need to be added.
  3. Refine your questions to fit into either the closed- or open-ended question type forms and organize them into 2 groups: initial interview questions, and secondary & followup questions
  4. Create a one-sheet list of your initial interview questions in preparation for a call with your Partner Organization (call time to be determined).
  5. Using the secondary & followup questions list, create a TCNJ Qualtrics survey as a starting point for a followup survey to your initial interview call.

Design Notebook

  1. Create a new page in your Design Notebook and label it “Interview & Survey” and today’s date.
  2. List the initial interview questions you and your group came up with in preparation for your initial interviews.
  3. Include a link to your TCNJ Qualtrics Survey.

*Assignments are due before class begins on Mondays. Be prepared to present your work in class for discussion.

Voice Recordings

Announcements

  • Today: Voice Recording equipment overview & demonstration at the IMM Cage with Dickie
  • Tim Wisniewski, Chief Data Officer, The City of Philadelphia – Brown Bag Lunch Feb 20, 12:30-1:30 & 3:00-4:00 @ IMM
  • Next Week, Feb 23 – Phone Polls
  • Partner Organization Interviews, setting up for the week of Feb 23 or March 2

Design Notebooks

Let’s take a few minutes to go over some of your Design Notebook entries from last week.

Cage Visit

Let’s head over to the cage to meet with Dickie.

Design Patterns

Christopher Alexander – The Timeless Way of Building

The Gang of Four – Design Patterns

Architectural Patterns

Interactive Voice Response (IVR) Patterns

Phone Menus

  • keypad input
  • voice input

Leave-a-Message

  • crowd-sourced incident reporting
  • oral histories
  • voicemail

Phone Polls

  • keypad input multiple choice
  • voice response

Click-to-Call

  • web/mobile interface to initiate a call out

SMS-to-Call

  • sms message to initiate a call out

Voice Broadcast

  • call out notification to a group of numbers

Message Broadcast

  • SMS out to a group of numbers

Twilio Voice Recordings

Twilio’s Text-to-Speech engine is cool, but…

  • language limitations (even Alice supports only 26 languages/dialects)
  • sometimes we want greater flexibility with specific voices, i.e. celebrities

Today we’ll be using Twilio’s <Play> and <Record> TwiML verbs.

  1. Download the source code for this week’s examples from the class Github Organization.
  2. Unzip the  repository on your local machine and upload the contents to a new folder in the ‘www’ folder on your TCNJ web account.
  3. Let’s try out the examples one by one.

Basic Voice Playback

Instead of using Twilio’s text-to-speech engine, let’s play back a recorded message.

  1. 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-playback.xml’.
  2. Call your Twilio number.
  3. What happened?
<!-- basic-voice-playback.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Play>http://www.mediamesis.net/imm/3hellos2.wav</Play>
</Response>

Twilio <Play> documentation

Gathering Input

Now let’s use the <Play> verb with <Gather>.

  1. Upload matrix.xml and checkpill.php to your TCNJ web account and edit the Voice request url in the Twilio Dashboard for your number to point to your edited file.
  2. Call your Twilio number.
  3. What happened?
 <!-- matrix.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Gather action="./check_pill.php" method="get" finishOnKey="*">
        <Play>http://www.mediamesis.net/imm/redpill.mp3</Play>
        <Say>Press 1 to take the red pill.</Say>
        <Say>Press 2 to take the blue pill.</Say>
    </Gather>
</Response>
 /* checkpill.php */
<?php
$pill = $_REQUEST['Digits'];

header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

if($pill == 1){ // red pill
    echo "<Response>";
    echo "<Play>http://www.mediamesis.net/imm/bluepill.mp3</Play>";
    echo "</Response>";
} else if($pill = 2) { // blue pill
    echo "<Response>";
    echo "<Play>http://www.mediamesis.net/imm/matrix66.mp3</Play>"
    echo "</Response>";
} else { // other
    echo "<Response>";
    echo "<Say>Sorry, I didn't understand your selection. Please try again.</Say>"; 
    echo "<Redirect method=\"POST\">http://yourserver/matrix.xml</Redirect>";
    echo "</Response>";
}

“Please Leave a Message…”

Now let’s try building a simple answering machine.

  1. Upload voicemail.xml and record.php to your TCNJ web account and edit the Voice request url in the Twilio Dashboard for your number to point to your edited file.
  2. Call your Twilio number.
  3. What happened?
<!-- voicemail.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Say>Leave a message after the beep. Press the pound key when you're done recording.</Say>
  <Record 
      action="http://www.tcnj.edu/~thompsom/imm-470-03/voice-recordings/record.php"
      method="GET"
      maxLength="20"
      finishOnKey="#"
   />
</Response>
/* recording.php */
<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";

$recording = $_REQUEST['RecordingUrl']; 
$duration = $_REQUEST['RecordingDuration'];
?>
<Response>
 <Say>Thanks for calling. Your message was <?php echo $duration; ?> seconds long. Here's the message you left.</Say>
 <Play><?php echo $recording; ?></Play>
</Response>

Twilio <Record> Documentation

Workflow for Creating Voice Menu Recordings

Basic flow

  1. Start with a flow diagram
  2. Prototype it using <Say>
  3. Create a script for the voice talent
  4. Record the messages
  5. Implement using <Play>

What about foreign languages/dialects?

Challenge

Break into your groups and review the Twilio Audio Recording Best Practices.

Using Audacity or other audio recording software, create a voice menu + leave-a-message app that presents the caller with information about the upcoming HackTCNJ event and prompts them to record a message about what kind of app they’re thinking about creating at the event.

Create menu options for:

  • Date, time and location
  • An overview description of the event
  • A sponsor listing
  • Request the caller leave-a-message about what they’d like to create at the event

Assignment

Know Your Audience

  • Read pages 52-59 in the Freedom Fone User and  Advocacy Guide
  • Create a new page in your Design Notebook and name it “Know Your Audience” and today’s date. Make a list of all the audience characteristics you feel would be important to your Partner Organization. Research as much as you can about each of the items discussed in the reading, filling in the information based upon what you know or can find out about your Partner Organizations’ communities.

Questions for Your Partner Organization

  • Create a list of questions for your Partner Organization about their services and most pressing communication problems.
  • Create another slide in your Design Notebook, titling it “Interview Questions” and today’s date., and drop in your list of questions from above.
  • Next week, you’ll combine your questions with those from your teammates to create a master list.

*Assignments are due before class begins on Mondays. Be prepared to present your work in class for discussion.

More Info

Voice Menus

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?

Android

iPhone

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.

  1. Download the source code for this week’s examples from the class Github Organization.
  2. Unzip the  repository on your local machine and upload the contents to a new folder in the ‘www’ folder on your TCNJ web account.
  3. Let’s try out the examples one by one.

Basic Voice

  1. 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’.
  2. Call your Twilio number.
  3. What happened?
<!-- basic-voice.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Hello Twilio!</Say>
</Response>

TwiML Say Documentation

Voice Attribute

Let’ experiment. Take a look at the documentation for the <Say> command paying particular attention to the ‘voice’ attribute.

  1. Try changing the voice for your app.
  2. 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.
  3. Call your Twilio number.
  4. What happened?
Langauge Attribute
  1. Once you’ve successfully changed the voice, try changing the language.
  2. 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.
  3. Call your Twilio number.
  4. 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.

  1. Change (or add) the phone record in the phone book array in your source code.
  2. 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.
  3. Call your Twilio number.
  4. 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>

TwiML Voice Request Variables

Gathering Input

Now let’s see if we can gather information interactively from the user.

  1. 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.
  2. Call your Twilio number.
  3. 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>";
}

TwiML Gather Documentation

Navigating a Tree

Now let’s navigate a simple voice menu.

  1. 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.
  2. Call your Twilio number.
  3. What happened?
  4. 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>';
?>

TwiML Redirect Documentation

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.

Twilio REST API: Making Calls

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.