From e579514321d8e3f6525e6165f7378228967fbc27 Mon Sep 17 00:00:00 2001 From: akirilyuk Date: Wed, 2 Feb 2022 20:25:52 +0100 Subject: [PATCH] exec gather after finishing queue --- lib/tasks/cognigy/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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) {