2
0

🐛 (whatsapp) Fix first message capture regression

Closes #1168
This commit is contained in:
Baptiste Arnaud
2024-01-22 14:54:45 +01:00
parent 2654e7277d
commit 32927e00bf
3 changed files with 33 additions and 24 deletions

View File

@@ -36,6 +36,7 @@ import { IntegrationBlockType } from '@typebot.io/schemas/features/blocks/integr
import { defaultTheme } from '@typebot.io/schemas/features/typebot/theme/constants'
import { VisitedEdge } from '@typebot.io/prisma'
import { env } from '@typebot.io/env'
import { getFirstEdgeId } from './getFirstEdgeId'
type StartParams =
| ({
@@ -166,9 +167,14 @@ export const startSession = async ({
// If params has message and first block is an input block, we can directly continue the bot flow
if (message) {
const firstEdgeId =
chatReply.newSessionState.typebotsQueue[0].typebot.groups[0].blocks[0]
.outgoingEdgeId
const firstEdgeId = getFirstEdgeId({
state: chatReply.newSessionState,
startEventId:
startParams.type === 'preview' &&
startParams.startFrom?.type === 'event'
? startParams.startFrom.eventId
: undefined,
})
const nextGroup = await getNextGroup(chatReply.newSessionState)(firstEdgeId)
const newSessionState = nextGroup.newSessionState
const firstBlock = nextGroup.group?.blocks.at(0)