-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-intent.js
More file actions
118 lines (97 loc) · 4.5 KB
/
test-intent.js
File metadata and controls
118 lines (97 loc) · 4.5 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const { detectIntent, IntentDetector } = require('./services/intentService');
console.log('🧪 === TESTING UPDATED IVR INTENT SYSTEM ===\n');
console.log('=== Testing Simple Intent Detection Function ===');
console.log('detectIntent("check balance"):', detectIntent("check balance"));
console.log('detectIntent("recharge account"):', detectIntent("recharge account"));
console.log('detectIntent("last transaction"):', detectIntent("last transaction"));
console.log('detectIntent("loan information"):', detectIntent("loan information"));
console.log('detectIntent("talk to agent"):', detectIntent("talk to agent"));
console.log('detectIntent("update my details"):', detectIntent("update my details"));
console.log('detectIntent("cancel this"):', detectIntent("cancel this"));
console.log('detectIntent("weather today"):', detectIntent("weather today")); // Should be UNKNOWN
console.log('\n=== Testing Enhanced Intent Detector Class ===');
// Test all new ACS intents
console.log('🏦 ACS SERVICE TESTS:');
console.log('Balance:', IntentDetector.detectIntent("check my account balance"));
console.log('Recharge:', IntentDetector.detectIntent("recharge my phone"));
console.log('Last Transaction:', IntentDetector.detectIntent("show me my last transaction"));
console.log('Loan Info:', IntentDetector.detectIntent("tell me about my loan"));
// Test all new BAP intents
console.log('\n🎧 BAP SERVICE TESTS:');
console.log('Agent Support:', IntentDetector.detectIntent("I need to talk to someone"));
console.log('Update Details:', IntentDetector.detectIntent("I want to update my profile"));
console.log('Cancel Action:', IntentDetector.detectIntent("cancel everything"));
console.log('\n=== Testing Digit Mapping ===');
const intentMapping = IntentDetector.getIntentMapping();
console.log('Intent to Digit Mapping:');
Object.entries(intentMapping).forEach(([intent, config]) => {
console.log(` ${intent}: Digit ${config.digit} -> ${config.service.toUpperCase()}`);
});
console.log('\n=== Comprehensive Test Phrases ===');
const testPhrases = [
// Balance inquiries (Digit 1 - ACS)
"What's my account balance?",
"Check my balance please",
"How much money do I have?",
"Show me my account",
// Recharge requests (Digit 2 - ACS)
"I want to recharge my phone",
"Top up my account",
"Add money to my account",
"Reload my balance",
// Last transaction (Digit 3 - ACS)
"Show me my last transaction",
"What was my recent payment?",
"Transaction history please",
"Latest transaction details",
// Loan information (Digit 4 - ACS)
"Tell me about my loan",
"What's my loan status?",
"EMI information please",
"Check my credit details",
// Agent support (Digit 5 - BAP)
"Can I talk to customer support?",
"Connect me to an agent",
"I need human assistance",
"Speak to someone please",
// Update details (Digit 6 - BAP)
"I want to update my profile",
"Change my personal details",
"Modify my information",
"Edit my account details",
// Cancel action (Digit 7 - BAP)
"Cancel this transaction",
"Stop everything",
"I want to quit",
"Abort this process",
// Unknown intents
"What's the weather today?",
"Play some music",
"Random gibberish xyz123"
];
console.log('\nDetailed Test Results:');
testPhrases.forEach((phrase, index) => {
const result = IntentDetector.detectIntent(phrase);
const status = result.intent !== 'unknown' ? '✅' : '❌';
console.log(`${status} "${phrase}"`);
console.log(` -> Intent: ${result.intent} | Service: ${result.service.toUpperCase()} | Digit: ${result.digit} | Confidence: ${result.confidence}`);
});
console.log('\n=== Testing Expected Digit Routing ===');
console.log('Expected ACS digits (1-4):');
['1', '2', '3', '4'].forEach(digit => {
console.log(` Digit ${digit}: Should route to ACS service`);
});
console.log('Expected BAP digits (5-7):');
['5', '6', '7'].forEach(digit => {
console.log(` Digit ${digit}: Should route to BAP service`);
});
console.log('Special digit:');
console.log(' Digit 9: Should display menu');
console.log('\n🎯 === TEST SUMMARY ===');
console.log('✅ All new intents have been implemented');
console.log('✅ Intent detection covers digits 1-7');
console.log('✅ Service routing: ACS (1-4), BAP (5-7)');
console.log('✅ Menu repeat functionality (digit 9)');
console.log('✅ Enhanced keyword matching for all services');
console.log('\n📋 Menu Text:');
console.log('"Press 1 for balance. 2 for recharge. 3 for last transaction. 4 for loan info. 5 for an agent. 6 to update details. 7 to cancel. 9 to repeat this menu."');