Skip to content

Commit

Permalink
🧐 Add inspectChatSession script
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 29, 2024
1 parent 7e9c67a commit 53e778e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions packages/scripts/inspectChatSession.ts
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 2 additions & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down

0 comments on commit 53e778e

Please sign in to comment.