Announcements
- NBC Builds SMS/IVR Political Confessions app using Twilio
- Two Vision APIs: Google Vision & IBM Watson’s Vision Alchemy
- Two new Amazon Alexa devices! The Amazon Dot and the Tap
- Complete an Alexa trivia game by March 31st & qualify for an Echo T-Shirt
- Next week: Data, APIs & Vision Documents
Project Status
Let’s take a few minutes to get caught up on the status of each of your projects. Have you created your list of questions for your partner contacts?
Surveys
Why do we use surveys and questionnaires?
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
- 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 Phone Interview Loop
Interview Loop with
- After you’ve uploaded the poll_gather.xml and respond.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’.
- Call your Twilio number.
- What happened?
Welcome to the 2016 Oscars phone poll. What film would you vote for for Best Picture? <Say>Press 1 for The Big Short.</Say> <Say>Press 2 for Bridge of Spies.</Say> <Say>Press 3 for Brooklyn.</Say> <Say>Press 4 for Mad Max Fury Road.</Say> <Say>Press 5 for The Martian.</Say> <Say>Press 6 for The Revenant.</Say> <Say>Press 7 for Room.</Say> <Say>Press 8 for Spotlight.</Say> Or press 9 to repeat these choices.
// respond.php
<?php header('Content-type: text/xml'); echo ''; // collect the selection number $selection = (int) $_REQUEST['Digits']; echo ''; switch($selection){ case 1: echo "Thanks for your response. You chose The Big Short."; break; case 2: echo "Thanks for your response. You chose Bridge of Spies."; break; case 3: echo "Thanks for your response. You chose Brooklyn."; break; case 4: echo "Thanks for your response. You chose Mad Max Fury Road."; break; case 5: echo "Thanks for your response. You chose The Martian."; break; case 6: echo "Thanks for your response. You chose The Revenant."; break; case 7: echo "Thanks for your response. You chose Room."; break; case 8: echo "Thanks for your response. You chose Spotlight."; break; case 9: echo "O K. Redirecting back to the choices../poll_gather.xml"; break; default: echo "I didn't understand your selection../poll_gather.xml"; break; } // close out file pointer fclose($fp); echo ''; ?>
Storing Responses to a File
- 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’.
- Call your Twilio number.
- What happened?
- Now point your web browser to http://www.tcnj.edu/~your-user-name/your-folder/data.txt
- 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.
<Gather action="./record_data.php" method="get"> Welcome to the 2015 Oscars phone poll. What film would you vote for for Best Picture? Press 1 for The Big Short. Press 2 for Bridge of Spies. Press 3 for Brooklyn. Press 4 for Mad Max Fury Road. Press 5 for The Martian. Press 6 for The Revenant. Press 7 for Room. Press 8 for Spotlight.
Or press 9 to repeat these choices.
// record_data.php
<?php header('Content-type: text/xml'); echo ''; // 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 ''; switch($selection){ case 1: // write the callers phone number, selection, a timestamp of the record fwrite($fp, $from . ',Best Picture,The Big Short,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose The Big Short."; break; case 2: // write the callers phone number, selection, a timestamp of the record & respond fwrite($fp, $from . ',Best Picture,Bridge of Spies,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose Bridge of Spies."; break; case 3: // write the callers phone number, selection, a timestamp of the record fwrite($fp, $from . ',Best Picture,Brooklyn,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose Brooklyn."; break; case 4: // write the callers phone number, selection, a timestamp of the record & respond fwrite($fp, $from . ',Best Picture,Mad Max Fury Road,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose Mad Max Fury Road."; break; case 5: // write the callers phone number, selection, a timestamp of the record fwrite($fp, $from . ',Best Picture,The Martian,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose The Martian."; break; case 6: // write the callers phone number, selection, a timestamp of the record fwrite($fp, $from . ',Best Picture,The Revenant,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose The Revenant."; break; case 7: // write the callers phone number, selection, a timestamp of the record fwrite($fp, $from . ',Best Picture,Room,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose Room."; break; case 8: // write the callers phone number, selection, a timestamp of the record fwrite($fp, $from . ',Best Picture,Spotlight,' . date("c", $t) . "\n"); echo "Thanks for your response. You chose Spotlight."; break; case 9: echo "O K. Redirecting back to the choices../poll_gather_data.xml"; break; default: echo "I didn't understand your selection../poll_gather_data.xml"; break; } // close out file pointer fclose($fp); echo ''; ?>
Interview Loop with
- 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’.
- Call your Twilio number.
- What happened?
- Now point your web browser to http://www.tcnj.edu/~your-user-name/your-folder/data.txt
- What do you see?
Welcome to the 2015 Oscars Phone Poll What was your favorite movie last year? Record your answer at the beep. Press the pound key when you're done recording.
/* recording.php */ <?php header("content-type: text/xml"); echo "\n"; // 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"); // 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"); ?> Thanks for taking our poll. Your favorite movie this year was
An SMS Example
- 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’.
- Text the word ‘poll’ to your number.
- What happened?
- Check for a text back from the system and follow the instructions.
- What happened this time?
- Now point your web browser to http://www.tcnj.edu/~your-user-name/your-folder/data.txt
- What do you see?
/* sms_poll_data.php */ <?php // we can get the number of the sender using the 'From' request value $from = $_REQUEST['From']; $msg = $_REQUEST['Body']; header("content-type: text/xml"); echo "\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": case "POLL": 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); ?>
Challenges
Twilio
- Break up into your groups and compare notes on your list of questions for your Partner Organization from last week’s assignment.
- Using the Phone Poll design pattern, create a Phone Poll app that asks 3 closed-ended questions and one open-ended question.
- Be sure to store the responses in a comma-separated (csv) file on your TCNJ web account or other hosting account.
Alexa
Using the Reindeer Games tutorial, set up your own example trivia game.
Cordova
- Cordova SMS plugin – Install the plugin and try out the “Using the Plugin’ example.
- Review the Cordova Plugin APIs page
- What other plugins might you combine with an SMS interface to improve the basic SMS capabilities of your phone in a useful way?
Assignment
Reading
Design Notebooks
- Create a new page in your Design Notebooks and title it “The Jack Principles”
- Read The Jack Principles and write few paragraphs discussing how you might apply the three main principles for creating “interactive conversation interfaces” to your project
Projects
- Make initial contact with your contacts
- Arrange to meet with them to present your project concepts and to interview them using the questions you developed last week
- Based upon the feedback from your partner contacts, begin diagraming your “interactive conversation interface” flows
*Submit the link to your Design Notebook to Canvas before we meet again next week займ на карту онлайн