File size: 760 Bytes
cd5a285 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | export const detectIntent = (text) => {
const lower = text.toLowerCase().trim();
// Explicit keywords
const invTerms = ['inventory', 'stock', 'product', 'items', 'supplies', 'units'];
const salesTerms = ['sales', 'revenue', 'orders', 'earnings', 'performance', 'stat'];
const actionTerms = ['how many', 'show', 'list', 'check', 'total', 'get', 'what', 'view', 'display', 'analyze', 'identify'];
const hasAction = actionTerms.some(a => lower.includes(a));
const hasInv = invTerms.some(i => lower.includes(i));
const hasSales = salesTerms.some(s => lower.includes(s));
if ((hasAction && hasInv) || invTerms.includes(lower)) return 'INVENTORY';
if ((hasAction && hasSales) || salesTerms.includes(lower)) return 'SALES';
return 'CHAT';
}; |