🐛 (typebotLink) Fix nested typebot link pop
This commit is contained in:
@@ -119,7 +119,7 @@ export const executeGroup =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nextEdgeId && state.typebotsQueue.length === 1)
|
if (!nextEdgeId && newSessionState.typebotsQueue.length === 1)
|
||||||
return { messages, newSessionState, clientSideActions, logs }
|
return { messages, newSessionState, clientSideActions, logs }
|
||||||
|
|
||||||
const nextGroup = await getNextGroup(newSessionState)(
|
const nextGroup = await getNextGroup(newSessionState)(
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const getNextGroup =
|
|||||||
isCompleted: true,
|
isCompleted: true,
|
||||||
hasStarted: state.typebotsQueue[0].answers.length > 0,
|
hasStarted: state.typebotsQueue[0].answers.length > 0,
|
||||||
})
|
})
|
||||||
const newSessionState = {
|
let newSessionState = {
|
||||||
...state,
|
...state,
|
||||||
typebotsQueue: [
|
typebotsQueue: [
|
||||||
{
|
{
|
||||||
@@ -69,6 +69,7 @@ export const getNextGroup =
|
|||||||
],
|
],
|
||||||
} satisfies SessionState
|
} satisfies SessionState
|
||||||
const nextGroup = await getNextGroup(newSessionState)(nextEdgeId)
|
const nextGroup = await getNextGroup(newSessionState)(nextEdgeId)
|
||||||
|
newSessionState = nextGroup.newSessionState
|
||||||
if (!nextGroup)
|
if (!nextGroup)
|
||||||
return {
|
return {
|
||||||
newSessionState,
|
newSessionState,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export const startBotFlow = async (
|
|||||||
state: SessionState,
|
state: SessionState,
|
||||||
startGroupId?: string
|
startGroupId?: string
|
||||||
): Promise<ChatReply & { newSessionState: SessionState }> => {
|
): Promise<ChatReply & { newSessionState: SessionState }> => {
|
||||||
|
let newSessionState = state
|
||||||
if (startGroupId) {
|
if (startGroupId) {
|
||||||
const group = state.typebotsQueue[0].typebot.groups.find(
|
const group = state.typebotsQueue[0].typebot.groups.find(
|
||||||
(group) => group.id === startGroupId
|
(group) => group.id === startGroupId
|
||||||
@@ -16,12 +17,13 @@ export const startBotFlow = async (
|
|||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: "startGroupId doesn't exist",
|
message: "startGroupId doesn't exist",
|
||||||
})
|
})
|
||||||
return executeGroup(state)(group)
|
return executeGroup(newSessionState)(group)
|
||||||
}
|
}
|
||||||
const firstEdgeId =
|
const firstEdgeId =
|
||||||
state.typebotsQueue[0].typebot.groups[0].blocks[0].outgoingEdgeId
|
newSessionState.typebotsQueue[0].typebot.groups[0].blocks[0].outgoingEdgeId
|
||||||
if (!firstEdgeId) return { messages: [], newSessionState: state }
|
if (!firstEdgeId) return { messages: [], newSessionState }
|
||||||
const nextGroup = await getNextGroup(state)(firstEdgeId)
|
const nextGroup = await getNextGroup(newSessionState)(firstEdgeId)
|
||||||
if (!nextGroup.group) return { messages: [], newSessionState: state }
|
newSessionState = nextGroup.newSessionState
|
||||||
return executeGroup(state)(nextGroup.group)
|
if (!nextGroup.group) return { messages: [], newSessionState }
|
||||||
|
return executeGroup(newSessionState)(nextGroup.group)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,12 +88,13 @@ export const startWhatsAppSession = async ({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const sessionState: SessionState = chatReply.newSessionState
|
let sessionState: SessionState = chatReply.newSessionState
|
||||||
|
|
||||||
// If first block is an input block, we can directly continue the bot flow
|
// If first block is an input block, we can directly continue the bot flow
|
||||||
const firstEdgeId =
|
const firstEdgeId =
|
||||||
sessionState.typebotsQueue[0].typebot.groups[0].blocks[0].outgoingEdgeId
|
sessionState.typebotsQueue[0].typebot.groups[0].blocks[0].outgoingEdgeId
|
||||||
const nextGroup = await getNextGroup(sessionState)(firstEdgeId)
|
const nextGroup = await getNextGroup(sessionState)(firstEdgeId)
|
||||||
|
sessionState = nextGroup.newSessionState
|
||||||
const firstBlock = nextGroup.group?.blocks.at(0)
|
const firstBlock = nextGroup.group?.blocks.at(0)
|
||||||
if (firstBlock && isInputBlock(firstBlock)) {
|
if (firstBlock && isInputBlock(firstBlock)) {
|
||||||
const resultId = sessionState.typebotsQueue[0].resultId
|
const resultId = sessionState.typebotsQueue[0].resultId
|
||||||
|
|||||||
Reference in New Issue
Block a user