diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 92ef9466..72232449 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -2269,6 +2269,7 @@ Duration=${duration} ` _startActionHookNoResponseTimer(options) { this._clearActionHookNoResponseTimer(); + this._actionHookDelayResolved = false; if (options.noResponseTimeoutMs) { this.logger.debug(`CallSession:_startActionHookNoResponseTimer ${options.noResponseTimeoutMs}`); this._actionHookNoResponseTimer = setTimeout(() => { @@ -2282,7 +2283,9 @@ Duration=${duration} ` if (t.length) { t[0].on('playDone', (err) => { if (err) this.logger.error({err}, `Call-Session:exec Error delay action, play ${verb}`); - this._startActionHookNoResponseTimer(options); + if (!this._actionHookDelayResolved) { + this._startActionHookNoResponseTimer(options); + } }); } this.tasks.push(...t); @@ -2300,7 +2303,16 @@ Duration=${duration} ` _clearActionHookNoResponseTimer() { if (this._actionHookNoResponseTimer) { + // Action Hook delay is solved. + this._actionHookDelayResolved = true; clearTimeout(this._actionHookNoResponseTimer); + // if delay action is enabled + // and bot has responded with list of new verbs + // Only kill current running play task. + //https://github.com/jambonz/jambonz-feature-server/issues/710 + if (this.currentTask?.name === TaskName.Play) { + this.currentTask.kill(this); + } } this._actionHookNoResponseTimer = null; } diff --git a/lib/tasks/config.js b/lib/tasks/config.js index a084bf7c..19ef615f 100644 --- a/lib/tasks/config.js +++ b/lib/tasks/config.js @@ -250,8 +250,7 @@ class TaskConfig extends Task { cs.stopBackgroundTask('transcribe'); } } - - if (this.actionHookDelayAction) { + if (Object.keys(this.actionHookDelayAction).length !== 0) { cs.actionHookDelayEnabled = this.actionHookDelayAction.enabled || false; cs.actionHookNoResponseTimeout = this.actionHookDelayAction.noResponseTimeout || 0; cs.actionHookNoResponseGiveUpTimeout = this.actionHookDelayAction.noResponseGiveUpTimeout || 0;