-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.html
More file actions
137 lines (123 loc) · 4.7 KB
/
Copy pathchat.html
File metadata and controls
137 lines (123 loc) · 4.7 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Automation Chatbot</title>
<link rel="icon" type="image/png" href="favicon.png" />
<style>
body {
font-family: 'Poppins', sans-serif;
text-align: center;
background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
color: white;
margin: 0;
padding: 0;
}
.chat-container {
max-width: 400px;
margin: 50px auto;
padding: 20px;
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
min-height: 500px;
display: flex;
flex-direction: column;
justify-content: space-between;
position: relative;
}
.chat-box {
text-align: left;
min-height: 400px;
padding: 10px;
overflow-y: auto;
display: flex;
flex-direction: column;
}
.message {
max-width: 80%;
padding: 10px;
border-radius: 10px;
margin: 5px 0;
}
.bot-message {
background: #459ca7;
color: white;
align-self: flex-start;
}
.user-message {
background: #34d399;
color: white;
align-self: flex-end;
}
.button-container {
display: flex;
flex-direction: column;
gap: 10px;
margin-top: 20px;
}
.chat-btn {
padding: 10px;
background: #ff4b5c;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: 0.3s;
}
.chat-btn:hover {
background: #e63946;
}
</style>
</head>
<body>
<div class="chat-container">
<h1>🤖 Home Automation ChatBot</h1>
<div class="chat-box" id="chat-box">
<div class="message bot-message"><strong>Bot:</strong> Welcome! How can I assist you?</div>
</div>
<div class="button-container">
<button class="chat-btn" onclick="showOptions('how-to-use')">📱 How to Use App</button>
<button class="chat-btn" onclick="showOptions('customer-support')">📞 Customer Support</button>
<button class="chat-btn" id="back-btn" onclick="goBack()" style="display:none;">🔙 Back</button>
</div>
</div>
<script>
const chatBox = document.getElementById('chat-box');
let previousContent = [];
function appendMessage(text, sender) {
const messageDiv = document.createElement('div');
messageDiv.classList.add('message', sender === 'bot' ? 'bot-message' : 'user-message');
messageDiv.innerHTML = `<strong>${sender === 'bot' ? 'Bot' : 'You'}:</strong> ${text}`;
chatBox.appendChild(messageDiv);
chatBox.scrollTop = chatBox.scrollHeight;
}
function showOptions(option) {
previousContent.push(chatBox.innerHTML);
document.getElementById('back-btn').style.display = 'block';
let content = '';
if (option === 'how-to-use') {
appendMessage("Here’s how to use the app:", 'bot');
setTimeout(() => appendMessage("1️⃣ Step 1: Connect your smart home devices.", 'bot'), 1000);
setTimeout(() => appendMessage("2️⃣ Step 2: Open the app and go to settings.", 'bot'), 2000);
setTimeout(() => appendMessage("3️⃣ Step 3: Configure your preferences.", 'bot'), 3000);
setTimeout(() => appendMessage("4️⃣ Step 4: Start controlling your home!", 'bot'), 4000);
} else if (option === 'customer-support') {
appendMessage("Customer support options:", 'bot');
setTimeout(() => appendMessage("📧 Email: support@example.com", 'bot'), 1000);
setTimeout(() => appendMessage("📞 Call: +1234567890", 'bot'), 2000);
}
}
function goBack() {
if (previousContent.length > 0) {
chatBox.innerHTML = previousContent.pop();
if (previousContent.length === 0) {
document.getElementById('back-btn').style.display = 'none';
}
}
}
</script>
</body>
</html>