@@ -1,11 +1,12 @@
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { isDefined, isNotDefined } from '@typebot.io/lib/utils'
|
||||
import { isDefined, isNotDefined, isNotEmpty } from '@typebot.io/lib/utils'
|
||||
import { getSession } from '../queries/getSession'
|
||||
import { continueBotFlow } from '../continueBotFlow'
|
||||
import { filterPotentiallySensitiveLogs } from '../logs/filterPotentiallySensitiveLogs'
|
||||
import { parseDynamicTheme } from '../parseDynamicTheme'
|
||||
import { saveStateToDatabase } from '../saveStateToDatabase'
|
||||
import { computeCurrentProgress } from '../computeCurrentProgress'
|
||||
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
||||
|
||||
type Props = {
|
||||
origin: string | undefined
|
||||
@@ -77,8 +78,11 @@ export const continueChat = async ({
|
||||
clientSideActions,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
hasCustomEmbedBubble: messages.some(
|
||||
(message) => message.type === 'custom-embed'
|
||||
hasEmbedBubbleWithWaitEvent: messages.some(
|
||||
(message) =>
|
||||
message.type === 'custom-embed' ||
|
||||
(message.type === BubbleBlockType.EMBED &&
|
||||
message.content.waitForEvent?.isEnabled)
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
||||
import { computeCurrentProgress } from '../computeCurrentProgress'
|
||||
import { filterPotentiallySensitiveLogs } from '../logs/filterPotentiallySensitiveLogs'
|
||||
import { restartSession } from '../queries/restartSession'
|
||||
import { saveStateToDatabase } from '../saveStateToDatabase'
|
||||
import { startSession } from '../startSession'
|
||||
import { isNotEmpty } from '@typebot.io/lib'
|
||||
|
||||
type Props = {
|
||||
origin: string | undefined
|
||||
@@ -74,8 +76,11 @@ export const startChat = async ({
|
||||
clientSideActions,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
hasCustomEmbedBubble: messages.some(
|
||||
(message) => message.type === 'custom-embed'
|
||||
hasEmbedBubbleWithWaitEvent: messages.some(
|
||||
(message) =>
|
||||
message.type === 'custom-embed' ||
|
||||
(message.type === BubbleBlockType.EMBED &&
|
||||
message.content.waitForEvent?.isEnabled)
|
||||
),
|
||||
})
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { restartSession } from '../queries/restartSession'
|
||||
import { saveStateToDatabase } from '../saveStateToDatabase'
|
||||
import { startSession } from '../startSession'
|
||||
import { computeCurrentProgress } from '../computeCurrentProgress'
|
||||
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
||||
|
||||
type Props = {
|
||||
message?: string
|
||||
@@ -69,8 +70,11 @@ export const startChatPreview = async ({
|
||||
clientSideActions,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
hasCustomEmbedBubble: messages.some(
|
||||
(message) => message.type === 'custom-embed'
|
||||
hasEmbedBubbleWithWaitEvent: messages.some(
|
||||
(message) =>
|
||||
message.type === 'custom-embed' ||
|
||||
(message.type === BubbleBlockType.EMBED &&
|
||||
message.content.waitForEvent?.isEnabled)
|
||||
),
|
||||
initialSessionId: sessionId,
|
||||
})
|
||||
|
||||
@@ -145,6 +145,13 @@ export const continueBotFlow = async (
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
block.type === BubbleBlockType.EMBED &&
|
||||
block.content?.waitForEvent?.saveDataInVariableId
|
||||
) {
|
||||
variableToUpdate = state.typebotsQueue[0].typebot.variables.find(
|
||||
(v) => v.id === block.content?.waitForEvent?.saveDataInVariableId
|
||||
)
|
||||
}
|
||||
|
||||
if (variableToUpdate) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
SessionState,
|
||||
SetVariableHistoryItem,
|
||||
} from '@typebot.io/schemas'
|
||||
import { isNotEmpty } from '@typebot.io/lib'
|
||||
import { isEmpty, isNotEmpty } from '@typebot.io/lib'
|
||||
import {
|
||||
isBubbleBlock,
|
||||
isInputBlock,
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
BubbleBlockWithDefinedContent,
|
||||
parseBubbleBlock,
|
||||
} from './parseBubbleBlock'
|
||||
import { BubbleBlockType } from '@typebot.io/schemas/features/blocks/bubbles/constants'
|
||||
|
||||
type ContextProps = {
|
||||
version: 1 | 2
|
||||
@@ -95,14 +96,30 @@ export const executeGroup = async (
|
||||
|
||||
if (isBubbleBlock(block)) {
|
||||
if (!block.content || (firstBubbleWasStreamed && index === 0)) continue
|
||||
messages.push(
|
||||
parseBubbleBlock(block as BubbleBlockWithDefinedContent, {
|
||||
version,
|
||||
variables: newSessionState.typebotsQueue[0].typebot.variables,
|
||||
typebotVersion: newSessionState.typebotsQueue[0].typebot.version,
|
||||
textBubbleContentFormat,
|
||||
})
|
||||
)
|
||||
const message = parseBubbleBlock(block as BubbleBlockWithDefinedContent, {
|
||||
version,
|
||||
variables: newSessionState.typebotsQueue[0].typebot.variables,
|
||||
typebotVersion: newSessionState.typebotsQueue[0].typebot.version,
|
||||
textBubbleContentFormat,
|
||||
})
|
||||
messages.push(message)
|
||||
if (
|
||||
message.type === BubbleBlockType.EMBED &&
|
||||
message.content.waitForEvent?.isEnabled
|
||||
) {
|
||||
return {
|
||||
messages,
|
||||
newSessionState: {
|
||||
...newSessionState,
|
||||
currentBlockId: block.id,
|
||||
},
|
||||
clientSideActions,
|
||||
logs,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
}
|
||||
}
|
||||
|
||||
lastBubbleBlockId = block.id
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ type Props = {
|
||||
clientSideActions: ContinueChatResponse['clientSideActions']
|
||||
visitedEdges: VisitedEdge[]
|
||||
setVariableHistory: SetVariableHistoryItem[]
|
||||
hasCustomEmbedBubble?: boolean
|
||||
hasEmbedBubbleWithWaitEvent?: boolean
|
||||
initialSessionId?: string
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export const saveStateToDatabase = async ({
|
||||
clientSideActions,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
hasCustomEmbedBubble,
|
||||
hasEmbedBubbleWithWaitEvent,
|
||||
initialSessionId,
|
||||
}: Props) => {
|
||||
const containsSetVariableClientSideAction = clientSideActions?.some(
|
||||
@@ -36,7 +36,9 @@ export const saveStateToDatabase = async ({
|
||||
)
|
||||
|
||||
const isCompleted = Boolean(
|
||||
!input && !containsSetVariableClientSideAction && !hasCustomEmbedBubble
|
||||
!input &&
|
||||
!containsSetVariableClientSideAction &&
|
||||
!hasEmbedBubbleWithWaitEvent
|
||||
)
|
||||
|
||||
const queries: Prisma.PrismaPromise<any>[] = []
|
||||
|
||||
Reference in New Issue
Block a user