2024-01-25 08:43:55 +01:00
|
|
|
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,
|
|
|
|
},
|
2024-05-22 14:59:24 +02:00
|
|
|
select: {
|
|
|
|
state: true,
|
|
|
|
},
|
2024-01-25 08:43:55 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
if (!chatSession) {
|
|
|
|
console.log('Session not found')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-22 14:59:24 +02:00
|
|
|
const result = await prisma.result.findFirst({
|
|
|
|
where: {
|
|
|
|
id: (chatSession.state as any).typebotsQueue[0].resultId,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log({
|
|
|
|
result,
|
|
|
|
})
|
2024-01-25 08:43:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
inspectChatSession()
|