Created
September 23, 2016 14:41
-
-
Save ObjectIsAdvantag/ae6c5181eccd194fc1bf79fc44b05e76 to your computer and use it in GitHub Desktop.
IVR for HackPoste mobile
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
if (!currentCall) { // No tropo session yet => this is an outgoing call initiated via Tropo token url | |
var offset = +2; // CET+2 | |
var now = new Date(Date.now() + (3600000 * offset)); | |
call(phonenumber); | |
say("it is now " + now.getHours() + ":" + now.getMinutes() + " in Paris, Rome, Madrid, Berlin, Zurich and Amsterdam."); | |
wait(500); | |
offset = +1; // CET+1 | |
now = new Date(Date.now() + (3600000 * offset)); | |
say("note that it is now " + now.getHours() + ":" + now.getMinutes() + " in Lisbon, London and Dublin."); | |
} | |
else { // Session initiated => this is an incoming call | |
answer(); | |
wait(1000); // On-boarding pause : do not speak too quickly the IVR | |
// Pick a voice depending on your language & preference (male/female) | |
// https://www.tropo.com/docs/scripting/international-features/speaking-multiple-languages | |
var currentVoice = "Ava"; // Allison, Ava, Samantha, Susan, Veronica, Vanessa (Default), Tom, Victor | |
log("speaking the welcome invite to: +" + currentCall.callerID); | |
say("Hello, Welcome to Hack Poste 2016 at Talent Garden Roma !", { voice: currentVoice }); | |
wait(500); | |
say("What about learning Poste, Spark, Tropo, CMX APIs and compose them easilly with Samplay ?", { voice: currentVoice }); | |
wait(1000); | |
// SSML: https://www.tropo.com/docs/scripting/advanced-speech-control/manipulating-say-ssml | |
event = ask("<speak>Dial 1 to receive instructions by SMS <break time='500ms'/> Dial 2 to get the name of the winner</speak>", { | |
voice: currentVoice, | |
choices: "1,2", | |
timeout: 5, | |
attempts: 3, | |
mode: "dtmf", // dial tone only as we are in an open conference room | |
onTimeout: function(event) { | |
say("Sorry, I didn't hear your choice.", { voice: currentVoice }); | |
}, | |
onBadChoice: function(event) { | |
say("Sorry, I didn't understand what you said.", { voice: currentVoice }); | |
} | |
}); | |
if (event.name == 'choice') { | |
var selected = parseInt(String(event.value)); | |
switch (selected) { | |
case 1: | |
say("Got it, we are texting you the instructions.", { voice: currentVoice }); | |
// Send a SMS from a new Tropo session | |
log("sending details via SMS to: +" + currentCall.callerID); | |
var forkedCall = call(currentCall.callerID, { | |
network: "SMS" | |
}); | |
forkedCall.value.say("Welcome to the Cisco Emmi challenge."); | |
forkedCall.value.hangup(); | |
break; | |
case 2: | |
default: | |
log("running the challenge via Tropo: +" + currentCall.callerID); | |
// [TODO] Implement takeChallenge() | |
say("Sorry, cheat mode is not implemented yet !", { voice: currentVoice }); | |
break; | |
} | |
} | |
// Finish the conversation gently | |
wait(500); | |
say("Thanks and see you at the Cisco Emmi booth at the entrance on the right. Bye Bye.", { voice: currentVoice }); | |
wait(1000); | |
hangup(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment