Skip to content

Instantly share code, notes, and snippets.

@ObjectIsAdvantag
Last active July 6, 2016 10:41
Show Gist options
  • Save ObjectIsAdvantag/bba17cc04b5cc5f815130b8d10f31cd1 to your computer and use it in GitHub Desktop.
Save ObjectIsAdvantag/bba17cc04b5cc5f815130b8d10f31cd1 to your computer and use it in GitHub Desktop.
DEVNET3002 - Step 1 - IVR - Tropo Voice script
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
say("Hello, Welcome to the DevNet Quiz !", { voice: currentVoice });
wait(500);
say("To take a Quiz, please text your email to this number. You'll be automatically added to the DevNet Quiz room.", { voice: currentVoice });
wait(1000);
// SSML: https://www.tropo.com/docs/scripting/advanced-speech-control/manipulating-say-ssml
event = ask("<speak> Dial 1 to receive more details by SMS <break time='500ms'/> Dial 2 to take a challenge from your phone </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 more details.", { voice: currentVoice });
// Send a SMS from a new Tropo session
var forkedCall = call(currentCall.callerID, {
network: "SMS"
});
forkedCall.value.say("Welcome to the DevNet Quiz. Text your email to join the 'Quiz' Spark room. Attend DEVNET3002 in the DevNet Zone to learn Spark & Tropo APIs.");
forkedCall.value.hangup();
break;
case 2:
default:
say("Sorry, this feature is not implemented yet !", { voice: currentVoice });
// TDOtakeChallenge();
break;
}
}
// Finish the conversation gently
wait(500);
say("Thanks and see you in the DevNet Zone. 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