import React, { useState, useEffect, useRef } from 'react';
import { Calendar, CheckCircle, MessageSquare, Building2, TrendingUp, Loader2 } from 'lucide-react';
const LeadGenBot = () => {
const [stage, setStage] = useState('welcome');
const [isTyping, setIsTyping] = useState(false);
const messagesEndRef = useRef(null);
const [leadData, setLeadData] = useState({
name: '',
company: '',
companySize: '',
currentMarketing: '',
monthlyBudget: '',
email: '',
phone: '',
mainGoal: '',
timeline: ''
});
const [messages, setMessages] = useState([
{ type: 'bot', text: "Hi! 👋 Welcome to The Borealit Company. I'm here to help you scale your business through strategic digital advertising." }
]);
// Auto-scroll to bottom of chat
useEffect(() => {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
}, [messages, isTyping]);
const addMessage = (text, type = 'bot') => {
setMessages(prev => [...prev, { type, text }]);
};
const handleInput = (value, field) => {
setLeadData(prev => ({ ...prev, [field]: value }));
};
const moveToNextStage = (nextStage, userResponse) => {
if (userResponse) {
addMessage(userResponse, 'user');
}
setIsTyping(true);
setTimeout(() => {
setIsTyping(false);
setStage(nextStage);
}, 800);
};
const checkBudgetQualification = (budgetRange) => {
// Check if the first number in the range is >= 1,000,000
const firstNum = parseInt(budgetRange.split('-')[0].replace(/[^0-9]/g, ''));
return firstNum >= 1000000;
};
const getCalendarLink = () => {
const details = encodeURIComponent(
`Discovery call with ${leadData.name} from ${leadData.company}\n\n` +
`Company Size: ${leadData.companySize}\n` +
`Budget Range: ${leadData.monthlyBudget}\n` +
`Main Goal: ${leadData.mainGoal}\n` +
`Timeline: ${leadData.timeline}`
);
return `https://calendar.google.com/calendar/appointments/schedules/AcZssZ0l7ygGcBJ3_example?text=Discovery+Call+-+The+Borealit+Company&details=${details}`;
};
const renderStage = () => {
switch(stage) {
case 'welcome':
setTimeout(() => {
addMessage("We specialize in helping medium to large-scale companies maximize their ROI through data-driven advertising strategies. Can I ask you a few quick questions to see how we can best help you?");
setStage('ask-name');
}, 1500);
return null;
case 'ask-name':
return (
First, what's your name?
handleInput(e.target.value, 'name')}
onKeyPress={(e) => {
if (e.key === 'Enter' && leadData.name) {
moveToNextStage('ask-company', leadData.name);
addMessage(`Great to meet you, ${leadData.name}! What's the name of your company?`);
}
}}
/>
{leadData.name && (
)}
);
case 'ask-company':
return (
What's the name of your company?
handleInput(e.target.value, 'company')}
onKeyPress={(e) => {
if (e.key === 'Enter' && leadData.company) {
moveToNextStage('ask-size', leadData.company);
addMessage(`Excellent! And what's the size of ${leadData.company}?`);
}
}}
/>
{leadData.company && (
)}
);
case 'ask-size':
return (
What's the size of your company?
{['50-200 employees', '200-500 employees', '500-1000 employees', '1000+ employees'].map(size => (
))}
);
case 'ask-budget':
return (
What's your current monthly marketing budget?
We specialize in partners investing ₦1,000,000+ monthly
);
case 'not-qualified':
return (
Let's Stay Connected
We focus on high-scale campaigns for ₦1M+ budgets. While we might not be the right fit today,
we'd love to follow your growth!
);
case 'ask-goal':
return (
What's your primary advertising goal?
{['Increase brand awareness', 'Generate more leads', 'Drive sales conversions', 'Expand market reach'].map(goal => (
))}
);
case 'ask-timeline':
return (
When would you like to start?
{['Immediately', 'Within 2 weeks', 'Within a month', 'Just exploring'].map(time => (
))}
);
case 'ask-contact':
return (
How can our strategy team reach you?
handleInput(e.target.value, 'email')}
/>
handleInput(e.target.value, 'phone')}
/>
{leadData.email && leadData.phone && (
)}
);
case 'schedule':
return (
You're Qualified! 🎉
Company: {leadData.company} ({leadData.companySize})
Goal: {leadData.mainGoal}
Book your 30-minute Discovery Call below to build your growth roadmap.
Book Discovery Call
Confirmation will be sent to {leadData.email}
);
default:
return null;
}
};
return (
{/* Header */}
The Borealit Company
Team is Online
{/* Chat Scroll Area */}
{messages.map((msg, idx) => (
{msg.text}
))}
{isTyping && (
)}
{renderStage()}
{/* Footer */}
Secure Lead Qualification System
);
};
export default LeadGenBot;