diff --git a/packages/scripts/inspectChatSession.ts b/packages/scripts/inspectChatSession.ts new file mode 100644 index 0000000000..7c83278943 --- /dev/null +++ b/packages/scripts/inspectChatSession.ts @@ -0,0 +1,35 @@ +import { PrismaClient } from '@typebot.io/prisma' +import { promptAndSetEnvironment } from './utils' +import * as p from '@clack/prompts' + +const inspectChatSession = 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({ + log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'], + }) + + const chatSession = await prisma.chatSession.findFirst({ + where: { + id, + }, + }) + + if (!chatSession) { + console.log('Session not found') + return + } + + console.log(JSON.stringify(chatSession, null, 2)) +} + +inspectChatSession() diff --git a/packages/scripts/package.json b/packages/scripts/package.json index ea1be2f581..d0a58b99c6 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -27,7 +27,8 @@ "inspectWorkspace": "tsx inspectWorkspace.ts", "getCoupon": "tsx getCoupon.ts", "exportResults": "tsx exportResults.ts", - "updateUserEmail": "tsx updateUserEmail.ts" + "updateUserEmail": "tsx updateUserEmail.ts", + "inspectChatSession": "tsx inspectChatSession.ts" }, "devDependencies": { "@typebot.io/emails": "workspace:*",