diff --git a/src/services/conciergeInbound.js b/src/services/conciergeInbound.js index 927ca0f..a3f193c 100644 --- a/src/services/conciergeInbound.js +++ b/src/services/conciergeInbound.js @@ -25,6 +25,32 @@ function isGuestProtectedQuery(text) { return GUEST_PROTECTED_KEYWORDS.some((k) => lower.includes(k)); } +const INTENT_CATEGORIES = { + EVENT_INFORMATION: 'Event Information', + PERSONAL_INFORMATION: 'Personal Information', + FOOD: 'Food', + PLACES: 'Places', + UNRECOGNIZED: 'unrecognized', +}; + +function determineIntentCategory(text) { + const normalized = String(text || '').toLowerCase().trim(); + if (!normalized) return INTENT_CATEGORIES.UNRECOGNIZED; + + const contains = (terms) => terms.some((term) => normalized.includes(term)); + + const personalTerms = ['ticket', 'badge', 'seat', 'registration', 'check in', 'check-in', 'attendee', 'profile']; + const foodTerms = ['food', 'menu', 'eat', 'lunch', 'dinner', 'breakfast', 'snack', 'coffee', 'tea', 'restaurant', 'cafe', 'vendor', 'catering', 'meal', 'vegan', 'vegetarian']; + const placeTerms = ['where', 'location', 'map', 'nearest', 'restroom', 'bathroom', 'parking', 'entrance', 'exit', 'hall', 'stage', 'booth', 'room', 'lounge', 'gate', 'venue', 'office', 'directions', 'route', 'floor']; + const eventTerms = ['event', 'information', 'info', 'schedule', 'agenda', 'program', 'speaker', 'speakers', 'sessions', 'session', 'time', 'date', 'venue', 'wifi', 'wi-fi', 'rules', 'policy', 'sponsor', 'join', 'host']; + + if (contains(foodTerms)) return INTENT_CATEGORIES.FOOD; + if (contains(placeTerms)) return INTENT_CATEGORIES.PLACES; + if (contains(personalTerms)) return INTENT_CATEGORIES.PERSONAL_INFORMATION; + if (contains(eventTerms)) return INTENT_CATEGORIES.EVENT_INFORMATION; + return INTENT_CATEGORIES.UNRECOGNIZED; +} + async function findParticipantForEvent(eventId, organizationId, input) { const raw = String(input || '').trim(); if (!raw) return null; @@ -220,6 +246,9 @@ async function processInboundMessage(jobData) { if (!incomingRawText) return; + const intentCategory = determineIntentCategory(incomingRawText); + console.log(`[intent] query="${incomingRawText}" category="${intentCategory}"`); + const includeEventDetails = bot.knowledge?.includeEventDetails !== false; const answer = await executeLocalRAG(eventId, incomingRawText, eventName, { includeEventDetails }); const reply =