diff --git a/packages/bot-engine/blocks/logic/setVariable/executeSetVariable.ts b/packages/bot-engine/blocks/logic/setVariable/executeSetVariable.ts index 8e96e376f..4fee21b8a 100644 --- a/packages/bot-engine/blocks/logic/setVariable/executeSetVariable.ts +++ b/packages/bot-engine/blocks/logic/setVariable/executeSetVariable.ts @@ -384,7 +384,12 @@ const parseTranscriptProps = async ( const parsePreviewTranscriptProps = async ( state: SessionState ): Promise => { - if (!state.previewMetadata) return + if (!state.previewMetadata) + return { + answers: [], + setVariableHistory: [], + visitedEdges: [], + } return { answers: state.previewMetadata.answers ?? [], setVariableHistory: state.previewMetadata.setVariableHistory ?? [], diff --git a/packages/logic/computeResultTranscript.ts b/packages/logic/computeResultTranscript.ts index aff2e0d30..2abf15dc8 100644 --- a/packages/logic/computeResultTranscript.ts +++ b/packages/logic/computeResultTranscript.ts @@ -131,7 +131,14 @@ const executeGroup = ({ for (const block of nextGroup?.group.blocks.slice( nextGroup.blockIndex ?? 0 )) { - if (stopAtBlockId && block.id === stopAtBlockId) return currentTranscript + if ( + stopAtBlockId && + block.id === stopAtBlockId && + answers.length === 0 && + setVariableHistory.length === 0 && + visitedEdges.length === 0 + ) + return currentTranscript if (setVariableHistory.at(0)?.blockId === block.id) typebotsQueue[0].typebot.variables = applySetVariable( setVariableHistory.shift(),