🐛 New sendMessage version for the new parser
Make sure old client still communicate with old parser
This commit is contained in:
@ -3,10 +3,17 @@ import { ChatReply, SessionState } from '@typebot.io/schemas'
|
||||
import { executeGroup } from './executeGroup'
|
||||
import { getNextGroup } from './getNextGroup'
|
||||
|
||||
export const startBotFlow = async (
|
||||
state: SessionState,
|
||||
type Props = {
|
||||
version: 1 | 2
|
||||
state: SessionState
|
||||
startGroupId?: string
|
||||
): Promise<ChatReply & { newSessionState: SessionState }> => {
|
||||
}
|
||||
|
||||
export const startBotFlow = async ({
|
||||
version,
|
||||
state,
|
||||
startGroupId,
|
||||
}: Props): Promise<ChatReply & { newSessionState: SessionState }> => {
|
||||
let newSessionState = state
|
||||
if (startGroupId) {
|
||||
const group = state.typebotsQueue[0].typebot.groups.find(
|
||||
@ -17,7 +24,7 @@ export const startBotFlow = async (
|
||||
code: 'BAD_REQUEST',
|
||||
message: "startGroupId doesn't exist",
|
||||
})
|
||||
return executeGroup(newSessionState)(group)
|
||||
return executeGroup(group, { version, state: newSessionState })
|
||||
}
|
||||
const firstEdgeId =
|
||||
newSessionState.typebotsQueue[0].typebot.groups[0].blocks[0].outgoingEdgeId
|
||||
@ -25,5 +32,5 @@ export const startBotFlow = async (
|
||||
const nextGroup = await getNextGroup(newSessionState)(firstEdgeId)
|
||||
newSessionState = nextGroup.newSessionState
|
||||
if (!nextGroup.group) return { messages: [], newSessionState }
|
||||
return executeGroup(newSessionState)(nextGroup.group)
|
||||
return executeGroup(nextGroup.group, { version, state: newSessionState })
|
||||
}
|
||||
|
Reference in New Issue
Block a user