11import React , { useEffect , useCallback , useState , useMemo } from 'react' ;
22import { motion , AnimatePresence } from 'framer-motion' ;
3- import { X , Loader2 , Shield , Zap , HeadphonesIcon , Bot } from 'lucide-react' ;
3+ import { X , Loader2 , Shield , Zap , HeadphonesIcon , Bot , Sparkles , Rocket } from 'lucide-react' ;
44import { toast } from 'sonner' ;
55import aiTorAvatar from '@/assets/ai-tor-avatar.jpg' ;
66
77// AI Personalities with unique messages and slight visual variations
8+ // Now includes promotional messages integrated into personalities
89const AI_PERSONALITIES = [
910 {
1011 id : 'support' ,
@@ -61,6 +62,34 @@ const AI_PERSONALITIES = [
6162 "¿Buscas algo específico en el ecosistema?" ,
6263 "Déjame mostrarte lo que puedes hacer aquí." ,
6364 ]
65+ } ,
66+ {
67+ id : 'promo' ,
68+ name : 'AI Tor' ,
69+ role : 'Promociones' ,
70+ icon : Sparkles ,
71+ color : 'from-pink-500 to-rose-500' ,
72+ borderColor : 'border-pink-500/50' ,
73+ messages : [
74+ "🚀 ¡Únete a AlienFlowSpace DAO y obtén NFTs exclusivos!" ,
75+ "🎁 Descubre los beneficios de ser miembro de la DAO" ,
76+ "💎 Colecciona NFTs únicos en nuestro ecosistema" ,
77+ "🌟 ¡Nuevas propuestas en la DAO! Tu voto cuenta" ,
78+ "🔥 Explora Academy, Clubs y CoNetWorKing - ¡Todo te espera!" ,
79+ ]
80+ } ,
81+ {
82+ id : 'welcome' ,
83+ name : 'AI Tor' ,
84+ role : 'Bienvenida' ,
85+ icon : Rocket ,
86+ color : 'from-orange-500 to-amber-500' ,
87+ borderColor : 'border-orange-500/50' ,
88+ messages : [
89+ "👽 ¡Bienvenido viajero! ¿Primera vez aquí? Te ayudo a explorar" ,
90+ "🌌 El universo AlienFlowSpace te espera. ¿Qué quieres descubrir?" ,
91+ "✨ ¿Listo para tu viaje cósmico? Pregúntame lo que quieras" ,
92+ ]
6493 }
6594] ;
6695
@@ -72,6 +101,7 @@ const AIChatbot = () => {
72101 const [ shouldLoadIframe , setShouldLoadIframe ] = useState ( false ) ;
73102 const [ currentPersonality , setCurrentPersonality ] = useState ( 0 ) ;
74103 const [ proactiveMessage , setProactiveMessage ] = useState ( '' ) ;
104+ const [ messageCount , setMessageCount ] = useState ( 0 ) ;
75105
76106 // Get current personality
77107 const personality = useMemo ( ( ) => AI_PERSONALITIES [ currentPersonality ] , [ currentPersonality ] ) ;
@@ -85,10 +115,13 @@ const AIChatbot = () => {
85115 return ( ) => clearTimeout ( timer ) ;
86116 } , [ ] ) ;
87117
88- // Proactive engagement with rotating personalities
118+ // Proactive engagement with rotating personalities - shorter initial delay
89119 useEffect ( ( ) => {
90120 if ( hasInteracted || isOpen ) return ;
91121
122+ // First message after 30 seconds
123+ const initialDelay = messageCount === 0 ? 30000 : 120000 ; // 30s first, then 2min
124+
92125 const timer = setTimeout ( ( ) => {
93126 // Pick random personality and message
94127 const randomPersonalityIndex = Math . floor ( Math . random ( ) * AI_PERSONALITIES . length ) ;
@@ -98,21 +131,31 @@ const AIChatbot = () => {
98131 setCurrentPersonality ( randomPersonalityIndex ) ;
99132 setProactiveMessage ( randomMessage ) ;
100133 setShowProactive ( true ) ;
134+ setMessageCount ( prev => prev + 1 ) ;
101135
102- // Auto-hide after 10 seconds
103- setTimeout ( ( ) => setShowProactive ( false ) , 10000 ) ;
104- } , 45000 ) ;
136+ // Auto-hide after 12 seconds
137+ setTimeout ( ( ) => setShowProactive ( false ) , 12000 ) ;
138+ } , initialDelay ) ;
105139
106140 return ( ) => clearTimeout ( timer ) ;
107- } , [ hasInteracted , isOpen ] ) ;
141+ } , [ hasInteracted , isOpen , messageCount ] ) ;
108142
109- // Track user interaction
143+ // Track user interaction - only on meaningful interactions
110144 useEffect ( ( ) => {
111- const handleInteraction = ( ) => setHasInteracted ( true ) ;
112- window . addEventListener ( 'click' , handleInteraction , { once : true } ) ;
113- window . addEventListener ( 'scroll' , handleInteraction , { once : true } ) ;
145+ const handleInteraction = ( ) => {
146+ // Don't mark as interacted if just scrolling slightly
147+ if ( window . scrollY > 200 ) {
148+ setHasInteracted ( true ) ;
149+ }
150+ } ;
151+
152+ const handleClick = ( ) => setHasInteracted ( true ) ;
153+
154+ window . addEventListener ( 'click' , handleClick , { once : true } ) ;
155+ window . addEventListener ( 'scroll' , handleInteraction ) ;
156+
114157 return ( ) => {
115- window . removeEventListener ( 'click' , handleInteraction ) ;
158+ window . removeEventListener ( 'click' , handleClick ) ;
116159 window . removeEventListener ( 'scroll' , handleInteraction ) ;
117160 } ;
118161 } , [ ] ) ;
@@ -144,19 +187,19 @@ const AIChatbot = () => {
144187 ) }
145188 </ AnimatePresence >
146189
147- { /* Proactive Engagement Bubble with Personality */ }
190+ { /* Proactive Engagement Bubble with Personality - FIXED: Right side */ }
148191 < AnimatePresence >
149192 { showProactive && ! isOpen && (
150193 < motion . div
151194 initial = { { opacity : 0 , x : 20 , scale : 0.8 } }
152195 animate = { { opacity : 1 , x : 0 , scale : 1 } }
153196 exit = { { opacity : 0 , x : 20 , scale : 0.8 } }
154197 className = "fixed bottom-36 right-4 sm:bottom-40 sm:right-8 z-40
155- max-w-[280px ] rounded-2xl rounded-br-sm overflow-hidden
198+ max-w-[300px ] rounded-2xl rounded-br-sm overflow-hidden
156199 backdrop-blur-xl border shadow-2xl cursor-pointer"
157200 style = { {
158201 background : 'linear-gradient(135deg, rgba(17,17,25,0.95) 0%, rgba(30,30,40,0.95) 100%)' ,
159- borderColor : `rgba(${ personality . id === 'support' ? '57,255,20' : personality . id === 'dao' ? '240,216,130' : personality . id === 'sentinel' ? '168,85,247' : '34,211,238' } ,0.4)`
202+ borderColor : `rgba(${ personality . id === 'support' ? '57,255,20' : personality . id === 'dao' ? '240,216,130' : personality . id === 'sentinel' ? '168,85,247' : personality . id === 'promo' ? '236,72,153' : personality . id === 'welcome' ? '249,115,22' : '34,211,238' } ,0.4)`
160203 } }
161204 onClick = { handleOpen }
162205 >
@@ -175,7 +218,9 @@ const AIChatbot = () => {
175218 style = { {
176219 filter : personality . id === 'sentinel' ? 'hue-rotate(270deg)' :
177220 personality . id === 'guide' ? 'hue-rotate(180deg)' :
178- personality . id === 'dao' ? 'sepia(30%)' : 'none'
221+ personality . id === 'dao' ? 'sepia(30%)' :
222+ personality . id === 'promo' ? 'hue-rotate(320deg)' :
223+ personality . id === 'welcome' ? 'hue-rotate(30deg)' : 'none'
179224 } }
180225 />
181226 </ div >
@@ -185,6 +230,12 @@ const AIChatbot = () => {
185230 < p className = "text-gray-200 font-exo text-sm leading-relaxed" >
186231 { proactiveMessage }
187232 </ p >
233+ { /* CTA for promo messages */ }
234+ { personality . id === 'promo' && (
235+ < span className = "inline-block mt-2 text-xs text-alien-gold font-nasalization hover:text-alien-green transition-colors" >
236+ Descubre más →
237+ </ span >
238+ ) }
188239 </ div >
189240 { /* Close button */ }
190241 < button
@@ -199,7 +250,7 @@ const AIChatbot = () => {
199250 ) }
200251 </ AnimatePresence >
201252
202- { /* Floating Button with pulsing ring */ }
253+ { /* Floating Button - FIXED: Positioned at bottom RIGHT */ }
203254 < motion . button
204255 initial = { { opacity : 0 , scale : 0.5 } }
205256 animate = { { opacity : 1 , scale : 1 } }
@@ -340,4 +391,4 @@ const AIChatbot = () => {
340391 ) ;
341392} ;
342393
343- export default AIChatbot ;
394+ export default AIChatbot ;
0 commit comments