File size: 1,713 Bytes
f3afae8
 
099c756
f3afae8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
099c756
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3afae8
 
099c756
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
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()