fix(engine): 🐛 Nested typebots webhhok exec

This commit is contained in:
Baptiste Arnaud
2022-04-19 10:09:38 -07:00
parent 240cbeed62
commit 9fbe1cc34c
4 changed files with 36 additions and 15 deletions

View File

@@ -28,7 +28,11 @@ type LogicContext = {
apiHost: string
typebot: PublicTypebot
linkedTypebots: LinkedTypebot[]
pushEdgeIdInLinkedTypebotQueue: (edgeId: EdgeId) => void
currentTypebotId: string
pushEdgeIdInLinkedTypebotQueue: (bot: {
edgeId: string
typebotId: string
}) => void
setCurrentTypebotId: (id: string) => void
updateVariableValue: (variableId: string, value: string) => void
updateVariables: (variables: VariableWithValue[]) => void
@@ -157,6 +161,7 @@ const executeTypebotLink = async (
createEdge,
setCurrentTypebotId,
pushEdgeIdInLinkedTypebotQueue,
currentTypebotId,
} = context
const linkedTypebot = (
step.options.typebotId === 'current'
@@ -172,7 +177,11 @@ const executeTypebotLink = async (
})
return { nextEdgeId: step.outgoingEdgeId }
}
if (step.outgoingEdgeId) pushEdgeIdInLinkedTypebotQueue(step.outgoingEdgeId)
if (step.outgoingEdgeId)
pushEdgeIdInLinkedTypebotQueue({
edgeId: step.outgoingEdgeId,
typebotId: currentTypebotId,
})
setCurrentTypebotId(
'typebotId' in linkedTypebot ? linkedTypebot.typebotId : linkedTypebot.id
)