Spaces:
Running
Running
import gradio as gr | |
# β Simple rule-based chatbot logic | |
def chatbot_response(message): | |
message = message.lower() | |
if any(word in message for word in ["shipping", "deliver", "arrive"]): | |
return "Shipping usually takes 3-5 business days. You'll receive a tracking number via email." | |
elif any(word in message for word in ["return", "refund", "send back"]): | |
return "You can return the SmartHome Hub Pro within 30 days of delivery." | |
elif any(word in message for word in ["product", "smarthome", "hub"]): | |
return "The SmartHome Hub Pro is an AI-powered device that connects and automates all your smart home gadgets." | |
elif any(word in message for word in ["issue", "problem", "trouble", "not working"]): | |
return "Try restarting the device. If problems persist, contact our support team at [email protected]." | |
elif message in ["exit", "quit", "bye"]: | |
return "Goodbye! Thanks for chatting with us." | |
else: | |
return "I'm not sure how to help with that. Can you ask about shipping, returns, or the product?" | |
# β Usage instructions for testers | |
instructions = """ | |
### π‘ How to Use the Chatbot: | |
Ask about: | |
- **Shipping** β "When will my order arrive?" | |
- **Returns** β "How do I return the product?" | |
- **Product details** β "What does the SmartHome Hub Pro do?" | |
""" | |
with gr.Blocks() as demo: | |
gr.Markdown(instructions) | |
gr.Interface( | |
fn=chatbot_response, | |
inputs=gr.Textbox(placeholder="Ask me about the SmartHome Hub Pro..."), | |
outputs="text", | |
title="Tech Gadget Chatbot", | |
description="Ask about product features, returns, or shipping." | |
) | |
if __name__ == "__main__": | |
demo.launch() | |