🐛 (webhook) Fix parent linked typebot data parsing in webhook
This commit is contained in:
@ -60,11 +60,13 @@ export const ChatGroup = ({
|
||||
createEdge,
|
||||
apiHost,
|
||||
isPreview,
|
||||
parentTypebotIds,
|
||||
onNewLog,
|
||||
injectLinkedTypebot,
|
||||
linkedTypebots,
|
||||
setCurrentTypebotId,
|
||||
pushEdgeIdInLinkedTypebotQueue,
|
||||
pushParentTypebotId,
|
||||
} = useTypebot()
|
||||
const { resultValues, updateVariables, resultId } = useAnswers()
|
||||
const { scroll } = useChat()
|
||||
@ -131,6 +133,7 @@ export const ChatGroup = ({
|
||||
setCurrentTypebotId,
|
||||
pushEdgeIdInLinkedTypebotQueue,
|
||||
currentTypebotId,
|
||||
pushParentTypebotId,
|
||||
})
|
||||
const isRedirecting =
|
||||
currentBlock.type === LogicBlockType.REDIRECT &&
|
||||
@ -156,6 +159,7 @@ export const ChatGroup = ({
|
||||
groups: typebot.groups,
|
||||
onNewLog,
|
||||
resultId,
|
||||
parentTypebotIds,
|
||||
},
|
||||
})
|
||||
nextEdgeId ? onGroupEnd({ edgeId: nextEdgeId }) : displayNextBlock()
|
||||
|
@ -22,6 +22,7 @@ export const executeWebhook = async (
|
||||
resultValues,
|
||||
onNewLog,
|
||||
resultId,
|
||||
parentTypebotIds,
|
||||
}: IntegrationState
|
||||
) => {
|
||||
const params = stringify({ resultId })
|
||||
@ -31,6 +32,7 @@ export const executeWebhook = async (
|
||||
body: {
|
||||
variables,
|
||||
resultValues,
|
||||
parentTypebotIds,
|
||||
},
|
||||
})
|
||||
const statusCode = (
|
||||
|
@ -18,6 +18,7 @@ export const executeTypebotLink = async (
|
||||
createEdge,
|
||||
setCurrentTypebotId,
|
||||
pushEdgeIdInLinkedTypebotQueue,
|
||||
pushParentTypebotId,
|
||||
currentTypebotId,
|
||||
} = context
|
||||
const linkedTypebot = (
|
||||
@ -42,6 +43,7 @@ export const executeTypebotLink = async (
|
||||
edgeId: block.outgoingEdgeId,
|
||||
typebotId: currentTypebotId,
|
||||
})
|
||||
pushParentTypebotId(currentTypebotId)
|
||||
setCurrentTypebotId(
|
||||
'typebotId' in linkedTypebot ? linkedTypebot.typebotId : linkedTypebot.id
|
||||
)
|
||||
|
@ -30,10 +30,12 @@ const typebotContext = createContext<{
|
||||
isPreview: boolean
|
||||
linkedBotQueue: LinkedTypebotQueue
|
||||
isLoading: boolean
|
||||
parentTypebotIds: string[]
|
||||
setCurrentTypebotId: (id: string) => void
|
||||
updateVariableValue: (variableId: string, value: unknown) => void
|
||||
createEdge: (edge: Edge) => void
|
||||
injectLinkedTypebot: (typebot: Typebot | PublicTypebot) => LinkedTypebot
|
||||
pushParentTypebotId: (typebotId: string) => void
|
||||
popEdgeIdFromLinkedTypebotQueue: () => void
|
||||
pushEdgeIdInLinkedTypebotQueue: (bot: {
|
||||
typebotId: string
|
||||
@ -63,6 +65,7 @@ export const TypebotProvider = ({
|
||||
const [linkedTypebots, setLinkedTypebots] = useState<LinkedTypebot[]>([])
|
||||
const [currentTypebotId, setCurrentTypebotId] = useState(typebot.typebotId)
|
||||
const [linkedBotQueue, setLinkedBotQueue] = useState<LinkedTypebotQueue>([])
|
||||
const [parentTypebotIds, setParentTypebotIds] = useState<string[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
setLocalTypebot((localTypebot) => ({
|
||||
@ -149,6 +152,10 @@ export const TypebotProvider = ({
|
||||
}
|
||||
})
|
||||
|
||||
const pushParentTypebotId = (typebotId: string) => {
|
||||
setParentTypebotIds((ids) => [...ids, typebotId])
|
||||
}
|
||||
|
||||
const pushEdgeIdInLinkedTypebotQueue = (bot: {
|
||||
typebotId: string
|
||||
edgeId: string
|
||||
@ -156,6 +163,7 @@ export const TypebotProvider = ({
|
||||
|
||||
const popEdgeIdFromLinkedTypebotQueue = () => {
|
||||
setLinkedBotQueue((queue) => queue.slice(1))
|
||||
setParentTypebotIds((ids) => ids.slice(1))
|
||||
setCurrentTypebotId(linkedBotQueue[0].typebotId)
|
||||
}
|
||||
|
||||
@ -172,6 +180,8 @@ export const TypebotProvider = ({
|
||||
onNewLog,
|
||||
linkedBotQueue,
|
||||
isLoading,
|
||||
parentTypebotIds,
|
||||
pushParentTypebotId,
|
||||
pushEdgeIdInLinkedTypebotQueue,
|
||||
popEdgeIdFromLinkedTypebotQueue,
|
||||
currentTypebotId,
|
||||
|
@ -25,6 +25,7 @@ export type LogicState = {
|
||||
typebot: TypebotViewerProps['typebot']
|
||||
linkedTypebots: LinkedTypebot[]
|
||||
currentTypebotId: string
|
||||
pushParentTypebotId: (id: string) => void
|
||||
pushEdgeIdInLinkedTypebotQueue: (bot: {
|
||||
edgeId: string
|
||||
typebotId: string
|
||||
@ -47,6 +48,7 @@ export type IntegrationState = {
|
||||
resultValues: ResultValues
|
||||
groups: Group[]
|
||||
resultId?: string
|
||||
parentTypebotIds: string[]
|
||||
updateVariables: (variables: VariableWithUnknowValue[]) => void
|
||||
updateVariableValue: (variableId: string, value: unknown) => void
|
||||
onNewLog: (log: Omit<Log, 'id' | 'createdAt' | 'resultId'>) => void
|
||||
|
Reference in New Issue
Block a user