-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathview-conversations.js
More file actions
64 lines (50 loc) · 2.2 KB
/
view-conversations.js
File metadata and controls
64 lines (50 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
const fileStorage = require('./src/services/fileStorage');
const fs = require('fs').promises;
const path = require('path');
async function viewConversations() {
console.log('📊 CRM Bot Conversation Viewer\n');
try {
// Get recent conversations
const conversations = await fileStorage.getRecentConversations(20);
if (conversations.length === 0) {
console.log('No conversations found yet.');
console.log('\nData directory: data/conversations/');
return;
}
console.log(`Found ${conversations.length} recent conversations:\n`);
conversations.forEach((conv, index) => {
console.log(`\n${'='.repeat(80)}`);
console.log(`📅 ${conv.timestamp} | #${conv.channelName || conv.channel}`);
console.log(`👤 ${conv.userName} (${conv.userId})`);
console.log(`💬 "${conv.userMessage}"`);
if (conv.toolsUsed && conv.toolsUsed.length > 0) {
console.log(`🛠️ Tools: ${conv.toolsUsed.join(', ')}`);
}
console.log(`${conv.success ? '✅' : '❌'} Response: ${conv.finalResponse?.substring(0, 200)}...`);
if (conv.agentThoughts && conv.agentThoughts.length > 0) {
console.log(`\n🧠 Agent Thoughts (${conv.agentThoughts.length} steps):`);
conv.agentThoughts.slice(0, 3).forEach((thought, i) => {
console.log(` ${i + 1}. ${thought.substring(0, 100)}...`);
});
}
if (conv.error) {
console.log(`\n❌ Error: ${conv.error}`);
}
});
// Show storage info
const dataDir = path.join(__dirname, 'data/conversations');
const files = await fs.readdir(dataDir).catch(() => []);
const jsonFiles = files.filter(f => f.endsWith('.json'));
const logFiles = files.filter(f => f.endsWith('.log'));
console.log(`\n${'='.repeat(80)}`);
console.log('\n📁 Storage Statistics:');
console.log(`- Total conversation files: ${jsonFiles.length}`);
console.log(`- Daily log files: ${logFiles.length}`);
console.log(`- Data directory: ${dataDir}`);
} catch (error) {
console.error('Error viewing conversations:', error);
}
}
// Run the viewer
viewConversations().catch(console.error);