Skip to content

Instantly share code, notes, and snippets.

@chemax
Created February 20, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemax/8ec6d2cb053dc1fff9f126cdd6e214e0 to your computer and use it in GitHub Desktop.
Save chemax/8ec6d2cb053dc1fff9f126cdd6e214e0 to your computer and use it in GitHub Desktop.
this._handler = (context) => {
console.log('hello, AGI');
context.onEvent('variables')
.then((vars) => {
console.log('Agi vars: ', vars);
// console.log(this.currentCall.a)
console.log(vars.agi_callerid)
if ((this.currentCall.a == vars.agi_callerid) && (this.currentCall.b == vars.agi_dnid)) {
this.currentCall.chanB = vars.agi_channel;
this.currentCall.timer = setTimeout(
() => context.answer(),
this._getRandom(this.answerWait.from, this.answerWait.to)
);
// return context.answer()
return context
}
return context.hangup()
})
.then((vars) => {
return context.playback(this.soundB)
})
.then((result) => {
return context.end();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment