Last active
January 20, 2018 07:13
-
-
Save goastoman/561a9e32501e0365e8d662553839ea22 to your computer and use it in GitHub Desktop.
Autoresponder
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
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