diff --git a/lib/tasks/cognigy/index.js b/lib/tasks/cognigy/index.js index 91edd096..44050d0d 100644 --- a/lib/tasks/cognigy/index.js +++ b/lib/tasks/cognigy/index.js @@ -233,11 +233,15 @@ class Cognigy extends Task { async _onBotFinalPing(cs, ep) { this.logger.info({prompts: this.prompts}, 'Cognigy:_onBotFinalPing'); - await this.taskQueue.lastPromise; - this.gatherTask = this._makeGatherTask({textPrompt: 'this should be changed'}); - this.gatherTask.exec(cs, ep, this) - .catch((err) => this.logger.info({err}, 'Cognigy gather task returned error')); - this.prompts = []; + try { + await this.taskQueue.lastPromise; + this.gatherTask = this._makeGatherTask(); + this.gatherTask.exec(cs, ep, this) + .catch((err) => this.logger.info({err}, 'Cognigy gather task returned error')); + this.prompts = []; + } catch (err) { + this.logger.error({err}, 'Could not execute bot final ping!'); + } } async _onBotUtterance(cs, ep, evt) { @@ -285,14 +289,14 @@ class Cognigy extends Task { return; case 'refer': - this._enqueueTask(async() => { + 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); - }); + }).bind(this)); return; default: break;