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

@@ -0,0 +1,23 @@
import { TRPCError } from '@trpc/server'
import { SessionState } from '@typebot.io/schemas'
export const getFirstEdgeId = ({
state,
startEventId,
}: {
state: SessionState
startEventId: string | undefined
}) => {
const { typebot } = state.typebotsQueue[0]
if (startEventId) {
const event = typebot.events?.find((e) => e.id === startEventId)
if (!event)
throw new TRPCError({
code: 'BAD_REQUEST',
message: "Start event doesn't exist",
})
return event.outgoingEdgeId
}
if (typebot.version === '6') return typebot.events[0].outgoingEdgeId
return typebot.groups[0].blocks[0].outgoingEdgeId
}