diff --git a/lib/tasks/cognigy/speech-config.js b/lib/tasks/cognigy/speech-config.js index ad12cfd8..f83a51e6 100644 --- a/lib/tasks/cognigy/speech-config.js +++ b/lib/tasks/cognigy/speech-config.js @@ -1,4 +1,6 @@ +const obj = require('drachtio-fsmrf/lib/utils'); const Emitter = require('events'); +const { isArray } = require('lodash'); const lodash = require('lodash'); const hasKeys = (obj) => typeof obj === 'object' && Object.keys(obj) > 0; @@ -18,11 +20,17 @@ class SpeechConfig extends Emitter { _mergeConfig(changedConfig = {}) { const merged = lodash.merge( - {}, this.sessionConfig, - changedConfig + changedConfig, + (objValue, sourceValue) => { + if(isArray(objValue)){ + if(isArray(sourceValue)){ + return sourceValue; + } + return objValue; + } + } ); - merged.bargein.enable = changedConfig.bargein?.enable?.length === 0 ? [] : changedConfig.bargein?.enable; this.logger.debug({merged, sessionConfig: this.sessionConfig, changedConfig}, 'merged config'); // should we override hints with empty array or leave it as it is once saved? // merged.recognizer.hints = changedConfig.recognizer?.hints