"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { MessageCircle, X, Send } from "lucide-react"; import { motion, AnimatePresence } from "framer-motion"; export function Chatbot() { const [isOpen, setIsOpen] = useState(false); const [messages, setMessages] = useState([ { role: "bot", text: "Hi! I'm the Apex Assistant. I'm powered by AI to help you while I'm out detailing cars. How can I help you today?" } ]); const [input, setInput] = useState(""); const handleSend = () => { if (!input.trim()) return; const newMessages = [...messages, { role: "user", text: input }]; setMessages(newMessages); setInput(""); // Simple automated responses setTimeout(() => { let response = "I'm not sure about that, but you can book a detail and I'll answer all your questions in person!"; const lowerInput = input.toLowerCase(); if (lowerInput.includes("price") || lowerInput.includes("cost")) response = "Our prices vary by car size: Full Interior starts at $80, Exterior Hand Wash at $40, and Full Detail at $110!"; if (lowerInput.includes("where") || lowerInput.includes("location")) response = "I'm based in Cedar Rapids and I'm mobile—I come right to your driveway!"; if (lowerInput.includes("equipment") || lowerInput.includes("tools")) response = "I use professional-grade pressure washers, steam cleaners, and industrial vacuums to get that better-than-pro finish."; if (lowerInput.includes("who") || lowerInput.includes("old")) response = "I'm a 13-year-old entrepreneur saving up for my first car and college!"; if (lowerInput.includes("book") || lowerInput.includes("schedule")) response = "You can book directly on our site using the 'Book a Detail' button. We accept Stripe for secure payments!"; setMessages([...newMessages, { role: "bot", text: response }]); }, 1000); }; return (
{!isOpen ? ( ) : (
Apex AI Assistant
setIsOpen(false)} />
{messages.map((m, i) => (
{m.text}
))}
(setInput(e.target.value))} onKeyDown={(e) => e.key === "Enter" && handleSend()} />
)}
); }