2
0
Files
bot/packages/bot-engine/queries/restartSession.ts
2023-09-20 15:42:34 +02:00

25 lines
402 B
TypeScript

import prisma from '@typebot.io/lib/prisma'
import { SessionState } from '@typebot.io/schemas'
type Props = {
id?: string
state: SessionState
}
export const restartSession = async ({ id, state }: Props) => {
if (id) {
await prisma.chatSession.deleteMany({
where: {
id,
},
})
}
return prisma.chatSession.create({
data: {
id,
state,
},
})
}