🚸 Make sure to add start client side action first in the list
This commit is contained in:
@@ -127,25 +127,25 @@ export const startSession = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { messages, input, clientSideActions, newSessionState, logs } =
|
const {
|
||||||
await startBotFlow(initialState, startParams.startGroupId)
|
messages,
|
||||||
|
input,
|
||||||
|
clientSideActions: startFlowClientActions,
|
||||||
|
newSessionState,
|
||||||
|
logs,
|
||||||
|
} = await startBotFlow(initialState, startParams.startGroupId)
|
||||||
|
|
||||||
const clientSideActionsNeedSessionId = clientSideActions?.some(
|
const clientSideActions = startFlowClientActions ?? []
|
||||||
(action) =>
|
|
||||||
'setVariable' in action || 'streamOpenAiChatCompletion' in action
|
|
||||||
)
|
|
||||||
|
|
||||||
const startClientSideAction = clientSideActions ?? []
|
const startClientSideAction = parseStartClientSideAction(typebot)
|
||||||
|
|
||||||
const parsedStartPropsActions = parseStartClientSideAction(typebot)
|
|
||||||
|
|
||||||
const startLogs = logs ?? []
|
const startLogs = logs ?? []
|
||||||
|
|
||||||
if (isDefined(parsedStartPropsActions)) {
|
if (isDefined(startClientSideAction)) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
if ('startPropsToInject' in parsedStartPropsActions) {
|
if ('startPropsToInject' in startClientSideAction) {
|
||||||
const { customHeadCode, googleAnalyticsId, pixelId, gtmId } =
|
const { customHeadCode, googleAnalyticsId, pixelId, gtmId } =
|
||||||
parsedStartPropsActions.startPropsToInject
|
startClientSideAction.startPropsToInject
|
||||||
let toolsList = ''
|
let toolsList = ''
|
||||||
if (customHeadCode) toolsList += 'Custom head code, '
|
if (customHeadCode) toolsList += 'Custom head code, '
|
||||||
if (googleAnalyticsId) toolsList += 'Google Analytics, '
|
if (googleAnalyticsId) toolsList += 'Google Analytics, '
|
||||||
@@ -160,16 +160,23 @@ export const startSession = async ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
startClientSideAction.push(parsedStartPropsActions)
|
clientSideActions.unshift(startClientSideAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clientSideActionsNeedSessionId = clientSideActions?.some(
|
||||||
|
(action) =>
|
||||||
|
'setVariable' in action ||
|
||||||
|
'streamOpenAiChatCompletion' in action ||
|
||||||
|
'webhookToExecute' in action
|
||||||
|
)
|
||||||
|
|
||||||
if (!input && !clientSideActionsNeedSessionId)
|
if (!input && !clientSideActionsNeedSessionId)
|
||||||
return {
|
return {
|
||||||
newSessionState,
|
newSessionState,
|
||||||
messages,
|
messages,
|
||||||
clientSideActions:
|
clientSideActions:
|
||||||
startClientSideAction.length > 0 ? startClientSideAction : undefined,
|
clientSideActions.length > 0 ? clientSideActions : undefined,
|
||||||
typebot: {
|
typebot: {
|
||||||
id: typebot.id,
|
id: typebot.id,
|
||||||
settings: deepParseVariables(
|
settings: deepParseVariables(
|
||||||
@@ -198,7 +205,7 @@ export const startSession = async ({
|
|||||||
messages,
|
messages,
|
||||||
input,
|
input,
|
||||||
clientSideActions:
|
clientSideActions:
|
||||||
startClientSideAction.length > 0 ? startClientSideAction : undefined,
|
clientSideActions.length > 0 ? clientSideActions : undefined,
|
||||||
dynamicTheme: parseDynamicTheme(newSessionState),
|
dynamicTheme: parseDynamicTheme(newSessionState),
|
||||||
logs: startLogs.length > 0 ? startLogs : undefined,
|
logs: startLogs.length > 0 ? startLogs : undefined,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user