2
0

🐛 New sendMessage version for the new parser

Make sure old client still communicate with old parser
This commit is contained in:
Baptiste Arnaud
2023-10-06 10:14:26 +02:00
parent 6f3e9e9251
commit 3838ac9c3f
35 changed files with 710 additions and 416 deletions

View File

@ -31,6 +31,7 @@ import { upsertResult } from './queries/upsertResult'
import { continueBotFlow } from './continueBotFlow'
type Props = {
version: 1 | 2
message: string | undefined
startParams: StartParams
userId: string | undefined
@ -38,6 +39,7 @@ type Props = {
}
export const startSession = async ({
version,
message,
startParams,
userId,
@ -135,7 +137,11 @@ export const startSession = async ({
}
}
let chatReply = await startBotFlow(initialState, startParams.startGroupId)
let chatReply = await startBotFlow({
version,
state: initialState,
startGroupId: startParams.startGroupId,
})
// If params has message and first block is an input block, we can directly continue the bot flow
if (message) {
@ -154,10 +160,13 @@ export const startSession = async ({
resultId,
typebot: newSessionState.typebotsQueue[0].typebot,
})
chatReply = await continueBotFlow({
...newSessionState,
currentBlock: { groupId: firstBlock.groupId, blockId: firstBlock.id },
})(message)
chatReply = await continueBotFlow(message, {
version,
state: {
...newSessionState,
currentBlock: { groupId: firstBlock.groupId, blockId: firstBlock.id },
},
})
}
}