Tina / src /intent.js
KyleAIers's picture
Create intent.js
cd5a285 verified
Raw History Blame Contribute Delete
760 Bytes
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';
};