From a9f730b7019330f11dd5b64cc465c9f803508d05 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 31 May 2022 08:17:04 +0200 Subject: [PATCH] =?UTF-8?q?fix(engine):=20=F0=9F=90=9B=20Variable=20value?= =?UTF-8?q?=20reset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/bot-engine/src/services/logic.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/bot-engine/src/services/logic.ts b/packages/bot-engine/src/services/logic.ts index d44b893bcd..8d4c319184 100644 --- a/packages/bot-engine/src/services/logic.ts +++ b/packages/bot-engine/src/services/logic.ts @@ -66,11 +66,10 @@ const executeSetVariable = ( step: SetVariableStep, { typebot: { variables }, updateVariableValue, updateVariables }: LogicContext ): EdgeId | undefined => { - if (!step.options?.variableId || !step.options.expressionToEvaluate) - return step.outgoingEdgeId - const evaluatedExpression = evaluateExpression(variables)( - step.options.expressionToEvaluate - ) + if (!step.options?.variableId) return step.outgoingEdgeId + const evaluatedExpression = step.options.expressionToEvaluate + ? evaluateExpression(variables)(step.options.expressionToEvaluate) + : undefined const existingVariable = variables.find(byId(step.options.variableId)) if (!existingVariable) return step.outgoingEdgeId updateVariableValue(existingVariable.id, evaluatedExpression)