diff --git a/lib/tasks/cognigy/index.js b/lib/tasks/cognigy/index.js index fc6b0bb3..f164282e 100644 --- a/lib/tasks/cognigy/index.js +++ b/lib/tasks/cognigy/index.js @@ -241,15 +241,15 @@ class Cognigy extends Task { async _onBotFinalPing(cs, ep) { this.logger.info({prompts: this.prompts}, 'Cognigy:_onBotFinalPing'); - this._enqueueTask(async() => { + try { + // lets wait until we have finished processing the speech before + // starting a gather... + await this.taskQueue.lastPromise; const gatherTask = this._makeGatherTask(); await gatherTask.exec(cs, ep, this); - try { - await sayTask.exec(cs, ep, this); - } catch (err) { - this.logger.info({err}, 'Cognigy gather task returned error'); - } - }); + } catch (err) { + this.logger.info({err}, 'Cognigy gather task returned error'); + } } async _onBotUtterance(cs, ep, evt) {