Spaces:
Sleeping
Sleeping
File size: 10,763 Bytes
d245a81 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | """
Lead.AI Business Chatbot Demo β Live Demo
AI customer service chatbot trained for small business use cases.
Visit https://www.lead-ai.us for a custom deployment on your business data.
"""
import gradio as gr
import json
import re
from datetime import datetime
# ββ Demo knowledge base (replace with real business data in production) βββββββ
DEMO_BUSINESS = {
"name": "Lead.AI Demo Business",
"type": "AI Automation Services",
"hours": "MondayβFriday, 9amβ6pm EST",
"phone": "+1 (555) 000-0000",
"email": "hello@lead-ai.us",
"website": "https://www.lead-ai.us",
"location": "Remote β serving businesses worldwide",
}
FAQ_DATABASE = {
"hours": {
"triggers": ["hours", "open", "close", "when", "schedule", "available", "time"],
"response": f"We're open **{DEMO_BUSINESS['hours']}**. Outside those hours, leave a message and we'll reply the next business day."
},
"pricing": {
"triggers": ["price", "cost", "pricing", "how much", "fee", "charge", "rate", "pay", "package"],
"response": """Here are our main service packages:
π° **Starter β $499** (one-time)
Website chatbot + lead capture + 30-day support
π° **Business β $999** (one-time)
Chatbot + WhatsApp + appointment booking + dashboard
π° **Advanced AI β $1,999+**
Predictive analytics + fraud detection + custom deployment
π
**Monthly Support β $99β$499/month**
Want a personalized quote? **[Book a free consultation β](https://www.lead-ai.us)**"""
},
"services": {
"triggers": ["service", "offer", "provide", "build", "create", "help", "do", "what"],
"response": """We build AI automation systems for small businesses:
π€ **Website AI Chatbot** β captures leads 24/7
π± **WhatsApp Lead Assistant** β qualifies prospects automatically
π
**AI Appointment Booking** β no more scheduling back-and-forth
π‘ **Fraud Detection Dashboard** β flags risky transactions with explanations
π **Customer Predictor** β identifies who's about to leave
β **Review Sentinel** β monitors your reputation in real time
Which one are you most interested in?"""
},
"demo": {
"triggers": ["demo", "try", "see", "example", "test", "sample", "show"],
"response": """You can try our AI systems live right now β no signup needed:
π‘ [Fraud Shield Demo](https://huggingface.co/spaces/lead-ai-labs/fraud-shield)
π― [Customer Predictor Demo](https://huggingface.co/spaces/lead-ai-labs/customer-predictor)
β [Review Sentinel Demo](https://huggingface.co/spaces/lead-ai-labs/review-sentinel)
Or you're already talking to a chatbot demo! π"""
},
"contact": {
"triggers": ["contact", "reach", "call", "email", "talk", "speak", "human", "person", "agent"],
"response": f"""Here's how to reach a real person:
π§ **Email:** {DEMO_BUSINESS['email']}
π **Website:** {DEMO_BUSINESS['website']}
π **Phone:** {DEMO_BUSINESS['phone']}
Or **[book a free 30-minute consultation](https://www.lead-ai.us)** β we'll call you."""
},
"consultation": {
"triggers": ["book", "appointment", "consultation", "meeting", "call", "schedule", "chat"],
"response": """I'd love to connect you with our team!
**[π
Book a Free 30-Minute AI Consultation](https://www.lead-ai.us)**
During the call, we'll:
β Review your business needs
β Show you what AI can automate
β Give you a no-pressure recommendation and quote
What type of business do you run?"""
},
"setup_time": {
"triggers": ["long", "fast", "quick", "days", "weeks", "timeline", "when", "ready", "live"],
"response": """**Setup timelines:**
π Basic chatbot: **48β72 hours**
π¦ Business package: **5β7 business days**
π§ Advanced AI systems: **10β14 business days**
All systems include testing and a walkthrough before handoff.
Want to get started? **[Book a consultation β](https://www.lead-ai.us)**"""
},
"custom": {
"triggers": ["custom", "specific", "my business", "tailored", "personalized", "train", "data"],
"response": """Yes, every Lead.AI system is custom-built for your business:
β Trained on **your** FAQs, products, and policies
β Integrated with **your** existing tools
β Deployed on **your** website or platform
β Supported by Lead.AI on an ongoing basis
We don't use generic bots. Every system learns your business.
**[Request a Custom Setup β](https://www.lead-ai.us)**"""
},
"refund": {
"triggers": ["refund", "guarantee", "money back", "cancel", "return"],
"response": """We stand behind our work:
β If a deliverable doesn't match what was agreed, we fix it β no charge
β Digital products: 7-day refund if the product doesn't open or run as documented
β Custom setups: milestone-based payment β you approve each stage before we continue
Questions? Email **hello@lead-ai.us** β we respond within 24 hours."""
},
}
LEAD_CAPTURE_STAGE = {}
CONVERSATION_LOG = []
def capture_lead_info(message: str, stage: dict) -> tuple[str, dict]:
if "name" not in stage:
return "Great! What's your name?", {**stage, "name": None, "awaiting": "name"}
if stage.get("awaiting") == "name":
stage["name"] = message.strip().title()
stage["awaiting"] = "email"
return f"Nice to meet you, {stage['name']}! What's your email address?", stage
if stage.get("awaiting") == "email":
if "@" not in message:
return "That doesn't look like an email. Could you try again?", stage
stage["email"] = message.strip().lower()
stage["awaiting"] = "business"
return "Perfect! And what type of business do you run?", stage
if stage.get("awaiting") == "business":
stage["business"] = message.strip()
stage["awaiting"] = "done"
name = stage.get("name", "there")
email = stage.get("email", "")
biz = stage.get("business", "your business")
return (
f"Thank you, {name}! We'll be in touch at **{email}** within 24 hours.\n\n"
f"A Lead.AI specialist will reach out to discuss AI automation options for **{biz}**.\n\n"
f"In the meantime, [book a free consultation](https://www.lead-ai.us) if you'd like to connect sooner. π"
), stage
return None, stage
def get_faq_response(message: str) -> str | None:
lower = message.lower()
for faq_key, faq in FAQ_DATABASE.items():
if any(trigger in lower for trigger in faq["triggers"]):
return faq["response"]
return None
def chatbot_response(message: str, history: list, lead_stage: dict):
if not message.strip():
return history, lead_stage
lower = message.lower()
response = None
# Lead capture flow
if lead_stage.get("awaiting") in ("name", "email", "business"):
response, lead_stage = capture_lead_info(message, lead_stage)
# Greetings
elif any(g in lower for g in ["hello", "hi", "hey", "good morning", "good afternoon"]):
hour = datetime.now().hour
greeting = "Good morning" if hour < 12 else ("Good afternoon" if hour < 17 else "Good evening")
response = (
f"{greeting}! π I'm the Lead.AI assistant.\n\n"
"I can help you with:\n"
"β’ **Our services and pricing**\n"
"β’ **Live AI demos**\n"
"β’ **Booking a consultation**\n"
"β’ **Getting a quote for your business**\n\n"
"What brings you here today?"
)
# Lead capture trigger
elif any(kw in lower for kw in ["interested", "get started", "sign up", "quote", "start"]):
response, lead_stage = capture_lead_info(message, lead_stage)
# FAQ match
else:
response = get_faq_response(message)
# Fallback
if not response:
response = (
"That's a great question! Let me connect you with a specialist who can give you "
"a proper answer.\n\n"
"π§ **Email:** hello@lead-ai.us\n"
"π **Or book a free call:** [www.lead-ai.us](https://www.lead-ai.us)\n\n"
"Is there anything else I can help you with β services, pricing, or demos?"
)
history.append((message, response))
return history, lead_stage
with gr.Blocks(
title="Lead.AI Business Chatbot",
theme=gr.themes.Soft(primary_hue="violet"),
css="""
.chatbot-container { max-height: 500px; }
.footer { text-align:center; margin-top:20px; color:#666; }
"""
) as demo:
gr.Markdown("""
# π¬ Lead.AI Business Chatbot Demo
### AI Customer Service That Captures Leads While You Sleep
This is a live demo of the Lead.AI chatbot engine.
In production, it's trained on **your** business: your FAQs, services, hours, and pricing.
Try asking: *"What are your prices?"* or *"Can I see a demo?"* or *"I'm interested"*
> πΌ This is a proof-of-concept demo. [Get this for your business β](https://www.lead-ai.us)
""")
chatbot = gr.Chatbot(height=400, label="Lead.AI Assistant", bubble_full_width=False)
lead_state = gr.State({})
with gr.Row():
msg_box = gr.Textbox(
placeholder="Type your question here... (e.g. 'What services do you offer?')",
label="",
scale=4,
container=False,
)
send_btn = gr.Button("Send β", variant="primary", scale=1)
with gr.Row():
gr.Examples(
examples=[
["What services do you offer?"],
["How much does it cost?"],
["Can I see a live demo?"],
["How long does setup take?"],
["I'm interested in getting started"],
["How do I contact a real person?"],
],
inputs=msg_box,
label="Quick Questions",
)
send_btn.click(
fn=chatbot_response,
inputs=[msg_box, chatbot, lead_state],
outputs=[chatbot, lead_state],
).then(fn=lambda: "", outputs=msg_box)
msg_box.submit(
fn=chatbot_response,
inputs=[msg_box, chatbot, lead_state],
outputs=[chatbot, lead_state],
).then(fn=lambda: "", outputs=msg_box)
gr.Markdown("""
---
<div class="footer">
π <a href="https://www.lead-ai.us">www.lead-ai.us</a> |
π» <a href="https://github.com/Lead-AI-US/lead-ai-chatbot-platform">GitHub</a> |
π€ <a href="https://huggingface.co/lead-ai-labs">Hugging Face</a>
<br><br>
<strong>Need this chatbot trained on your business?</strong>
<a href="https://www.lead-ai.us">Request a Custom Lead.AI Setup β</a>
</div>
""")
if __name__ == "__main__":
demo.launch()
|