diff --git a/lib/tasks/cognigy/index.js b/lib/tasks/cognigy/index.js index 926d075c..eb937738 100644 --- a/lib/tasks/cognigy/index.js +++ b/lib/tasks/cognigy/index.js @@ -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: