diff --git a/packages/scripts/deleteChatSession.ts b/packages/scripts/deleteChatSession.ts new file mode 100644 index 000000000..bf4371eea --- /dev/null +++ b/packages/scripts/deleteChatSession.ts @@ -0,0 +1,28 @@ +import { PrismaClient } from '@typebot.io/prisma' +import { promptAndSetEnvironment } from './utils' +import * as p from '@clack/prompts' + +const deleteChatSession = async () => { + await promptAndSetEnvironment('production') + + const id = await p.text({ + message: 'Session ID?', + }) + + if (!id || typeof id !== 'string') { + console.log('No ID provided') + return + } + + const prisma = new PrismaClient() + + const chatSession = await prisma.chatSession.delete({ + where: { + id, + }, + }) + + console.log(JSON.stringify(chatSession, null, 2)) +} + +deleteChatSession() diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 599d2c06e..36c9ddaf7 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -29,7 +29,8 @@ "redeemCoupon": "tsx redeemCoupon.ts", "exportResults": "tsx exportResults.ts", "updateUserEmail": "tsx updateUserEmail.ts", - "inspectChatSession": "tsx inspectChatSession.ts" + "inspectChatSession": "tsx inspectChatSession.ts", + "deleteChatSession": "tsx deleteChatSession.ts" }, "devDependencies": { "@typebot.io/emails": "workspace:*",