// Script to check what's in the transcript files // Usage: node scripts/check-transcript-content.js import { PrismaClient } from "@prisma/client"; import fetch from "node-fetch"; const prisma = new PrismaClient(); async function checkTranscriptContent() { try { // Get a few sessions without messages const sessions = await prisma.session.findMany({ where: { AND: [{ fullTranscriptUrl: { not: null } }, { messages: { none: {} } }], }, include: { company: true }, take: 3, }); for (const session of sessions) { console.log(`\nšŸ“„ Checking session ${session.id}:`); console.log(` URL: ${session.fullTranscriptUrl}`); try { const authHeader = session.company.csvUsername && session.company.csvPassword ? "Basic " + Buffer.from( `${session.company.csvUsername}:${session.company.csvPassword}` ).toString("base64") : undefined; const response = await fetch(session.fullTranscriptUrl, { headers: authHeader ? { Authorization: authHeader } : {}, timeout: 10000, }); if (!response.ok) { console.log(` āŒ HTTP ${response.status}: ${response.statusText}`); continue; } const content = await response.text(); console.log(` šŸ“ Content length: ${content.length} characters`); if (content.length === 0) { console.log(` āš ļø Empty file`); } else if (content.length < 100) { console.log(` šŸ“ Full content: "${content}"`); } else { console.log( ` šŸ“ First 200 chars: "${content.substring(0, 200)}..."` ); } // Check if it matches our expected format const lines = content.split("\n").filter((line) => line.trim()); const formatMatches = lines.filter((line) => line.match(/^\[([^\]]+)\]\s*([^:]+):\s*(.+)$/) ); console.log( ` šŸ” Lines total: ${lines.length}, Format matches: ${formatMatches.length}` ); } catch (error) { console.log(` āŒ Error: ${error.message}`); } } } catch (error) { console.error("āŒ Error:", error); } finally { await prisma.$disconnect(); } } checkTranscriptContent();