@@ -52,6 +52,7 @@ export const continueChat = async ({ origin, sessionId, message }: Props) => {
|
||||
logs,
|
||||
lastMessageNewFormat,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
} = await continueBotFlow(message, {
|
||||
version: 2,
|
||||
state: session.state,
|
||||
@@ -68,6 +69,7 @@ export const continueChat = async ({ origin, sessionId, message }: Props) => {
|
||||
logs,
|
||||
clientSideActions,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
hasCustomEmbedBubble: messages.some(
|
||||
(message) => message.type === 'custom-embed'
|
||||
),
|
||||
|
||||
@@ -16,6 +16,7 @@ import { isForgedBlockType } from '@typebot.io/schemas/features/blocks/forged/he
|
||||
import { updateVariablesInSession } from '@typebot.io/variables/updateVariablesInSession'
|
||||
import { updateSession } from '../queries/updateSession'
|
||||
import { deepParseVariables } from '@typebot.io/variables/deepParseVariables'
|
||||
import { saveSetVariableHistoryItems } from '../queries/saveSetVariableHistoryItems'
|
||||
|
||||
type Props = {
|
||||
sessionId: string
|
||||
@@ -114,11 +115,17 @@ export const getMessageStream = async ({ sessionId, messages }: Props) => {
|
||||
(variable) => variable.id === id
|
||||
)
|
||||
if (!variable) return
|
||||
const { updatedState, newSetVariableHistory } =
|
||||
updateVariablesInSession({
|
||||
newVariables: [{ ...variable, value }],
|
||||
state: session.state,
|
||||
currentBlockId: session.state.currentBlockId,
|
||||
})
|
||||
if (newSetVariableHistory.length > 0)
|
||||
await saveSetVariableHistoryItems(newSetVariableHistory)
|
||||
await updateSession({
|
||||
id: session.id,
|
||||
state: updateVariablesInSession(session.state)([
|
||||
{ ...variable, value },
|
||||
]),
|
||||
state: updatedState,
|
||||
isReplying: undefined,
|
||||
})
|
||||
},
|
||||
|
||||
@@ -33,6 +33,7 @@ export const startChat = async ({
|
||||
clientSideActions,
|
||||
newSessionState,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
} = await startSession({
|
||||
version: 2,
|
||||
startParams: {
|
||||
@@ -69,6 +70,7 @@ export const startChat = async ({
|
||||
logs,
|
||||
clientSideActions,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
hasCustomEmbedBubble: messages.some(
|
||||
(message) => message.type === 'custom-embed'
|
||||
),
|
||||
|
||||
@@ -13,6 +13,7 @@ type Props = {
|
||||
typebot?: StartTypebot
|
||||
userId?: string
|
||||
prefilledVariables?: Record<string, unknown>
|
||||
sessionId?: string
|
||||
}
|
||||
|
||||
export const startChatPreview = async ({
|
||||
@@ -24,6 +25,7 @@ export const startChatPreview = async ({
|
||||
typebot: startTypebot,
|
||||
userId,
|
||||
prefilledVariables,
|
||||
sessionId,
|
||||
}: Props) => {
|
||||
const {
|
||||
typebot,
|
||||
@@ -34,6 +36,7 @@ export const startChatPreview = async ({
|
||||
clientSideActions,
|
||||
newSessionState,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
} = await startSession({
|
||||
version: 2,
|
||||
startParams: {
|
||||
@@ -45,6 +48,7 @@ export const startChatPreview = async ({
|
||||
typebot: startTypebot,
|
||||
userId,
|
||||
prefilledVariables,
|
||||
sessionId,
|
||||
},
|
||||
message,
|
||||
})
|
||||
@@ -61,9 +65,11 @@ export const startChatPreview = async ({
|
||||
logs,
|
||||
clientSideActions,
|
||||
visitedEdges,
|
||||
setVariableHistory,
|
||||
hasCustomEmbedBubble: messages.some(
|
||||
(message) => message.type === 'custom-embed'
|
||||
),
|
||||
initialSessionId: sessionId,
|
||||
})
|
||||
|
||||
const isEnded =
|
||||
|
||||
Reference in New Issue
Block a user