diff --git a/apps/viewer/src/features/variables/utils.ts b/apps/viewer/src/features/variables/utils.ts index 854882754..4033986b7 100644 --- a/apps/viewer/src/features/variables/utils.ts +++ b/apps/viewer/src/features/variables/utils.ts @@ -24,10 +24,13 @@ export const parseVariables = if (!text || text === '') return '' return text.replace(/\{\{(.*?)\}\}/g, (_, fullVariableString) => { const matchedVarName = fullVariableString.replace(/{{|}}/g, '') - const variable = variables.find((v) => { - return matchedVarName === v.name && isDefined(v.value) + const variable = variables.find((variable) => { + return ( + matchedVarName === variable.name && + (options.fieldToParse === 'id' || isDefined(variable.value)) + ) }) as VariableWithValue | undefined - if (!variable || variable.value === null) return '' + if (!variable) return '' if (options.fieldToParse === 'id') return variable.id const { value } = variable if (options.escapeForJson) return jsonParse(value) diff --git a/packages/bot-engine/src/features/variables/utils.ts b/packages/bot-engine/src/features/variables/utils.ts index 52d4d4f18..a15482b94 100644 --- a/packages/bot-engine/src/features/variables/utils.ts +++ b/packages/bot-engine/src/features/variables/utils.ts @@ -16,10 +16,13 @@ export const parseVariables = if (!text || text === '') return '' return text.replace(/\{\{(.*?)\}\}/g, (_, fullVariableString) => { const matchedVarName = fullVariableString.replace(/{{|}}/g, '') - const variable = variables.find((v) => { - return matchedVarName === v.name && isDefined(v.value) + const variable = variables.find((variable) => { + return ( + matchedVarName === variable.name && + (options.fieldToParse === 'id' || isDefined(variable.value)) + ) }) as VariableWithValue | undefined - if (!variable || variable.value === null) return '' + if (!variable) return '' if (options.fieldToParse === 'id') return variable.id const { value } = variable if (options.escapeForJson) return jsonParse(value)