2
0

Improve new bot engine client side actions

We make sure to save client side actions in an array that will be executed sequentially
This commit is contained in:
Baptiste Arnaud
2023-01-26 15:26:42 +01:00
parent 0fc82cf73b
commit 9aab6ddb2c
15 changed files with 133 additions and 106 deletions

View File

@ -165,6 +165,26 @@ const replyLogSchema = logSchema
})
.and(z.object({ details: z.unknown().optional() }))
const clientSideActionSchema = z
.object({
codeToExecute: codeToExecuteSchema,
})
.or(
z.object({
redirect: redirectOptionsSchema,
})
)
.or(
z.object({
chatwoot: z.object({ codeToExecute: codeToExecuteSchema }),
})
)
.or(
z.object({
googleAnalytics: googleAnalyticsOptionsSchema,
})
)
export const chatReplySchema = z.object({
messages: z.array(chatMessageSchema),
input: inputBlockSchema
@ -175,22 +195,7 @@ export const chatReplySchema = z.object({
})
)
.optional(),
logic: z
.object({
redirect: redirectOptionsSchema.optional(),
codeToExecute: codeToExecuteSchema.optional(),
})
.optional(),
integrations: z
.object({
chatwoot: z
.object({
codeToExecute: codeToExecuteSchema,
})
.optional(),
googleAnalytics: googleAnalyticsOptionsSchema.optional(),
})
.optional(),
clientSideActions: z.array(clientSideActionSchema).optional(),
sessionId: z.string().optional(),
typebot: typebotSchema
.pick({ id: true, theme: true, settings: true })