🐛 (setVariable) Fix setVariable array parsing when executed on client
This commit is contained in:
@ -6,6 +6,7 @@ import {
|
|||||||
InputBlock,
|
InputBlock,
|
||||||
SessionState,
|
SessionState,
|
||||||
SetVariableHistoryItem,
|
SetVariableHistoryItem,
|
||||||
|
Variable,
|
||||||
} from '@typebot.io/schemas'
|
} from '@typebot.io/schemas'
|
||||||
import { byId } from '@typebot.io/lib'
|
import { byId } from '@typebot.io/lib'
|
||||||
import { isInputBlock } from '@typebot.io/schemas/helpers'
|
import { isInputBlock } from '@typebot.io/schemas/helpers'
|
||||||
@ -81,7 +82,7 @@ export const continueBotFlow = async (
|
|||||||
message: 'Group / block not found',
|
message: 'Group / block not found',
|
||||||
})
|
})
|
||||||
|
|
||||||
let variableToUpdate
|
let variableToUpdate: Variable | undefined
|
||||||
|
|
||||||
if (block.type === LogicBlockType.SET_VARIABLE) {
|
if (block.type === LogicBlockType.SET_VARIABLE) {
|
||||||
const existingVariable = state.typebotsQueue[0].typebot.variables.find(
|
const existingVariable = state.typebotsQueue[0].typebot.variables.find(
|
||||||
@ -90,7 +91,6 @@ export const continueBotFlow = async (
|
|||||||
if (existingVariable && reply && typeof reply === 'string') {
|
if (existingVariable && reply && typeof reply === 'string') {
|
||||||
variableToUpdate = {
|
variableToUpdate = {
|
||||||
...existingVariable,
|
...existingVariable,
|
||||||
value: safeJsonParse(reply),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ export const continueBotFlow = async (
|
|||||||
newVariables: [
|
newVariables: [
|
||||||
{
|
{
|
||||||
...variableToUpdate,
|
...variableToUpdate,
|
||||||
value: reply,
|
value: safeJsonParse(reply as string),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user