Last active
September 19, 2016 12:24
-
-
Save ObjectIsAdvantag/935cd5185fc4250c5a8c8e12857c91a9 to your computer and use it in GitHub Desktop.
Simple IVR to introduce Tropo Voice concepts at events in Europe. Applies for HackZurich
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 HackZurick !", { voice: currentVoice }); | |
wait(500); | |
say("What about winning a Yogurt Challenge ?", { voice: currentVoice }); | |
wait(1000); | |
// SSML: https://www.tropo.com/docs/scripting/advanced-speech-control/manipulating-say-ssml | |
event = ask("<speak>To take the Cisco Emmi challeng, dial 1 to receive instructions by SMS <break time='500ms'/> dial 2 to get a chance to win yogurts for free for fifty years</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 Emmi challenge via Tropo: +" + currentCall.callerID); | |
// [TODO] Implement takeChallenge() | |
say("Sorry, this feature 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