diff --git a/components/SiteMenteVoiceWidget.tsx b/components/SiteMenteVoiceWidget.tsx index 86d01f6..97c4633 100644 --- a/components/SiteMenteVoiceWidget.tsx +++ b/components/SiteMenteVoiceWidget.tsx @@ -129,16 +129,41 @@ export default function SiteMenteVoiceWidget({ // For now, simulate response await new Promise(resolve => setTimeout(resolve, 1000)); - const responses: Record = { + // Spanish responses + const spanishResponses: Record = { "hola": `¡Hola! 👋 Soy el asistente de ${businessName}. ¿En qué puedo ayudarte hoy?`, "horario": `Nuestros horarios de atención son de lunes a domingo. ¿Tienes alguna pregunta específica?`, "reservar": "Para hacer una reserva, puedo ayudarte ahora mismo. ¿Qué servicio te interesa?", "contacto": `Puedes llamarnos al +34 XXX XXX XXX o escribirnos aquí.`, - "default": "Gracias por tu mensaje. Un miembro de nuestro equipo te responderá pronto. ¿Hay algo específico en lo que pueda ayudarte?" }; - + + // English responses + const englishResponses: Record = { + "hello": `Hello! 👋 I'm the AI assistant for ${businessName}. How can I help you today?`, + "hours": `We're open Monday to Sunday. Do you have a specific question?`, + "book": "I can help you book right now. What service are you interested in?", + "contact": `You can call us at +34 XXX XXX XXX or message us here.`, + "price": "We offer packages starting from €299/month. Would you like me to tell you more?", + "cost": "We offer packages starting from €299/month. Would you like me to tell you more?", + "menu": "We serve delicious food daily. Would you like to see our menu or make a reservation?", + "reservation": "I can help you make a reservation! What date and time works for you?", + "thanks": "You're welcome! Is there anything else I can help you with?", + "thank you": "You're welcome! Is there anything else I can help you with?", + }; + + // Default responses + const spanishDefault = "Gracias por tu mensaje. Un miembro de nuestro equipo te responderá pronto. ¿Hay algo específico en lo que pueda ayudarte?"; + const englishDefault = "Thanks for your message! A team member will get back to you shortly. Is there anything specific I can help you with?"; + const lowerInput = userMessage.toLowerCase(); - let response = responses.default; + + // Detect language (simple check for English keywords) + const isEnglish = /^(hello|hi|hours|book|contact|price|cost|menu|reservation|thanks|thank you|what|how|when|where)/i.test(lowerInput); + + const responses = isEnglish ? englishResponses : spanishResponses; + const defaultResponse = isEnglish ? englishDefault : spanishDefault; + + let response = defaultResponse; for (const [key, value] of Object.entries(responses)) { if (lowerInput.includes(key)) {