fix(engine): 🐛 Webhook call on linked typebot
This commit is contained in:
@ -42,6 +42,7 @@ export const ChatBlock = ({
|
||||
onBlockEnd,
|
||||
}: ChatBlockProps) => {
|
||||
const {
|
||||
currentTypebotId,
|
||||
typebot,
|
||||
updateVariableValue,
|
||||
createEdge,
|
||||
@ -50,6 +51,7 @@ export const ChatBlock = ({
|
||||
onNewLog,
|
||||
injectLinkedTypebot,
|
||||
linkedTypebots,
|
||||
setCurrentTypebotId,
|
||||
} = useTypebot()
|
||||
const { resultValues, updateVariables } = useAnswers()
|
||||
const [processedSteps, setProcessedSteps] = useState<Step[]>([])
|
||||
@ -110,6 +112,7 @@ export const ChatBlock = ({
|
||||
injectLinkedTypebot,
|
||||
onNewLog,
|
||||
createEdge,
|
||||
setCurrentTypebotId,
|
||||
})
|
||||
nextEdgeId ? onBlockEnd(nextEdgeId, linkedTypebot) : displayNextStep()
|
||||
}
|
||||
@ -118,7 +121,7 @@ export const ChatBlock = ({
|
||||
step: currentStep,
|
||||
context: {
|
||||
apiHost,
|
||||
typebotId: typebot.typebotId,
|
||||
typebotId: currentTypebotId,
|
||||
blockId: currentStep.blockId,
|
||||
stepId: currentStep.id,
|
||||
variables: typebot.variables,
|
||||
|
@ -13,10 +13,12 @@ export type LinkedTypebot = Pick<
|
||||
'id' | 'blocks' | 'variables' | 'edges'
|
||||
>
|
||||
const typebotContext = createContext<{
|
||||
currentTypebotId: string
|
||||
typebot: PublicTypebot
|
||||
linkedTypebots: LinkedTypebot[]
|
||||
apiHost: string
|
||||
isPreview: boolean
|
||||
setCurrentTypebotId: (id: string) => void
|
||||
updateVariableValue: (variableId: string, value: string) => void
|
||||
createEdge: (edge: Edge) => void
|
||||
injectLinkedTypebot: (typebot: Typebot | PublicTypebot) => LinkedTypebot
|
||||
@ -40,6 +42,7 @@ export const TypebotContext = ({
|
||||
}) => {
|
||||
const [localTypebot, setLocalTypebot] = useState<PublicTypebot>(typebot)
|
||||
const [linkedTypebots, setLinkedTypebots] = useState<LinkedTypebot[]>([])
|
||||
const [currentTypebotId, setCurrentTypebotId] = useState(typebot.id)
|
||||
|
||||
useEffect(() => {
|
||||
setLocalTypebot((localTypebot) => ({
|
||||
@ -95,6 +98,8 @@ export const TypebotContext = ({
|
||||
createEdge,
|
||||
injectLinkedTypebot,
|
||||
onNewLog,
|
||||
currentTypebotId,
|
||||
setCurrentTypebotId,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
@ -28,6 +28,7 @@ type LogicContext = {
|
||||
apiHost: string
|
||||
typebot: PublicTypebot
|
||||
linkedTypebots: LinkedTypebot[]
|
||||
setCurrentTypebotId: (id: string) => void
|
||||
updateVariableValue: (variableId: string, value: string) => void
|
||||
updateVariables: (variables: VariableWithValue[]) => void
|
||||
injectLinkedTypebot: (typebot: Typebot | PublicTypebot) => LinkedTypebot
|
||||
@ -142,7 +143,8 @@ const executeTypebotLink = async (
|
||||
nextEdgeId?: EdgeId
|
||||
linkedTypebot?: PublicTypebot | LinkedTypebot
|
||||
}> => {
|
||||
const { typebot, linkedTypebots, onNewLog, createEdge } = context
|
||||
const { typebot, linkedTypebots, onNewLog, createEdge, setCurrentTypebotId } =
|
||||
context
|
||||
const linkedTypebot =
|
||||
step.options.typebotId === 'current'
|
||||
? typebot
|
||||
@ -156,6 +158,7 @@ const executeTypebotLink = async (
|
||||
})
|
||||
return { nextEdgeId: step.outgoingEdgeId }
|
||||
}
|
||||
setCurrentTypebotId(linkedTypebot.id)
|
||||
const nextBlockId =
|
||||
step.options.blockId ??
|
||||
linkedTypebot.blocks.find((b) => b.steps.some((s) => s.type === 'start'))
|
||||
|
Reference in New Issue
Block a user