add refer and hangup

This commit is contained in:
akirilyuk
2022-02-01 18:12:08 +01:00
parent 6dbbbf8c9e
commit 97d7a60994

View File

@@ -256,7 +256,6 @@ class Cognigy extends Task {
const text = parseBotText(evt);
if (evt.data) this.config.update(evt.data);
if (text) {
this._enqueueTask((async() => {
this.logger.info({text}, 'received text');
const sayTask = this._makeSayTask(text);
@@ -272,24 +271,23 @@ class Cognigy extends Task {
this._enqueueTask((async() => {
this.performAction({cognigyResult: 'hangup Succeeded'});
this.reportedFinalAction = true;
const hangupTask = this._makeHangupTask(evt.data.reason);
await hangupTask.exec(cs, ep, this);
cs.replaceApplication([{hangup: {
headers: {
'X-Reason': evt.data.reason
}
}}]);
this.taskQueue.end();
}).bind(this));
return;
case 'refer':
this._enqueueTask((async() => {
const referTask = this._makeReferTask(evt.data.number);
await referTask.exect(cs, ep, this);
this.performAction({cognigyResult: 'refer succeeded'});
this.reportedFinalAction = true;
this.notifyTaskDone();
this.kill(cs);
cs.replaceApplication([{'sip:refer': {
referTo: number,
referredBy: 'cognigy'
}}]);
}).bind(this));
return;
default: