Skip to content

Instantly share code, notes, and snippets.

@goastoman
Last active January 20, 2018 07:13
Show Gist options
  • Save goastoman/561a9e32501e0365e8d662553839ea22 to your computer and use it in GitHub Desktop.
Save goastoman/561a9e32501e0365e8d662553839ea22 to your computer and use it in GitHub Desktop.
Autoresponder
require(Modules.IVR);
let extState;
function initIVR() {
extState = new IVRState("extension", {
type: "inputfixed",
inputLength: 2,
prompt: {
say: "Hello, World. To continue, enter two digits.",
lang: Language.UK_ENGLISH_FEMALE
}
}, function (data) {
inboundCall.say(`Sum of your digits is ${+data[0] + +data[1]}. Thank you. Bye.`, Language.UK_ENGLISH_FEMALE);
inboundCall.addEventListener(CallEvents.PlaybackFinished);
});
function handleCallConnected(e) {
extState.enter(inboundCall);
}
function handleCallDisconnected(e) {
VoxEngine.terminate();
}
VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
inboundCall = e.call;
inboundCall.addEventListener(CallEvents.Connected, handleCallConnected);
inboundCall.addEventListener(CallEvents.Disconnected, handleCallDisconnected);
inboundCall.answer();
});
}
VoxEngine.addEventListener(AppEvents.Started, function (e) {
initIVR();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment