diff --git a/lib/tasks/cognigy/index.js b/lib/tasks/cognigy/index.js index 6e26be39..6d355365 100644 --- a/lib/tasks/cognigy/index.js +++ b/lib/tasks/cognigy/index.js @@ -256,9 +256,11 @@ class Cognigy extends Task { const text = parseBotText(evt); if (evt.data) this.config.update(evt.data); if (text) { - this.logger.info({text}, "received text"); + await this._enqueueTask((async() => { - await this._makeSayTask(text); + this.logger.info({text}, "received text"); + const sayTask = this._makeSayTask(text).exec(); + await sayTask.exec(cs, ep, this); }).bind(this)); } @@ -268,7 +270,8 @@ class Cognigy extends Task { switch (evt.data.type) { case 'hangup': await this._enqueueTask((async() => { - await this._makeHangupTask(evt.data.reason); + const hangupTask = this._makeHangupTask(evt.data.reason); + await hangupTask.exec(cs, ep, this); this.performAction({cognigyResult: 'hangup Succeeded'}); this.reportedFinalAction = true; this.notifyTaskDone(); @@ -278,7 +281,8 @@ class Cognigy extends Task { return; case 'refer': await this._enqueueTask(async() => { - await this._makeReferTask(evt.data.number); + const referTask = this._makeReferTask(evt.data.number); + await referTask.exect(cs, ep, this); this.performAction({cognigyResult: 'refer succeeded'}); this.reportedFinalAction = true; this.notifyTaskDone();