dprat0821 commited on
Commit
3973817
·
verified ·
1 Parent(s): 0bc4603

add pop up and logic for the chat button, raise a AI chat flow

Browse files
Files changed (1) hide show
  1. index.html +96 -5
index.html CHANGED
@@ -155,22 +155,113 @@
155
  <p>&copy; 2023 Daniel's IT Consulting. All rights reserved.</p>
156
  </div>
157
  </footer>
158
- <!-- AI Chat Button -->
159
  <div class="fixed bottom-6 right-6">
160
  <button id="chatButton" class="bg-orange-500 hover:bg-orange-600 text-white rounded-full p-4 shadow-lg transition duration-300">
161
  <i data-feather="message-circle" class="w-6 h-6"></i>
162
  </button>
163
  </div>
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
166
  <script>
167
  feather.replace();
168
 
169
- // Chat button functionality
170
- document.getElementById('chatButton').addEventListener('click', function() {
171
- // Replace this with your actual chat implementation
172
- alert('AI Chat feature will be implemented here!');
 
 
 
 
 
 
 
 
 
 
 
173
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  </script>
175
  </body>
176
  </html>
 
155
  <p>&copy; 2023 Daniel's IT Consulting. All rights reserved.</p>
156
  </div>
157
  </footer>
158
+ <!-- AI Chat Button and Modal -->
159
  <div class="fixed bottom-6 right-6">
160
  <button id="chatButton" class="bg-orange-500 hover:bg-orange-600 text-white rounded-full p-4 shadow-lg transition duration-300">
161
  <i data-feather="message-circle" class="w-6 h-6"></i>
162
  </button>
163
  </div>
164
 
165
+ <!-- Chat Modal -->
166
+ <div id="chatModal" class="fixed bottom-24 right-6 w-80 bg-white rounded-lg shadow-xl hidden flex flex-col" style="height: 500px;">
167
+ <div class="bg-orange-500 text-white p-3 rounded-t-lg flex justify-between items-center">
168
+ <h3 class="font-semibold">AI Assistant</h3>
169
+ <button id="closeChat" class="text-white hover:text-orange-200">
170
+ <i data-feather="x"></i>
171
+ </button>
172
+ </div>
173
+
174
+ <div id="chatMessages" class="flex-1 p-4 overflow-y-auto">
175
+ <div class="mb-4">
176
+ <div class="bg-gray-100 p-3 rounded-lg max-w-xs">
177
+ <p>Hello! I'm your AI assistant. How can I help you with your IT consulting needs today?</p>
178
+ </div>
179
+ </div>
180
+ </div>
181
+
182
+ <div class="p-3 border-t">
183
+ <div class="flex">
184
+ <input id="chatInput" type="text" placeholder="Type your message..."
185
+ class="flex-1 px-3 py-2 border rounded-l-lg focus:outline-none focus:ring-1 focus:ring-orange-500">
186
+ <button id="sendMessage" class="bg-orange-500 text-white px-4 py-2 rounded-r-lg hover:bg-orange-600">
187
+ <i data-feather="send"></i>
188
+ </button>
189
+ </div>
190
+ </div>
191
+ </div>
192
+
193
  <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
194
  <script>
195
  feather.replace();
196
 
197
+ const chatButton = document.getElementById('chatButton');
198
+ const chatModal = document.getElementById('chatModal');
199
+ const closeChat = document.getElementById('closeChat');
200
+ const chatInput = document.getElementById('chatInput');
201
+ const sendMessage = document.getElementById('sendMessage');
202
+ const chatMessages = document.getElementById('chatMessages');
203
+
204
+ // Toggle chat modal
205
+ chatButton.addEventListener('click', function() {
206
+ chatModal.classList.toggle('hidden');
207
+ });
208
+
209
+ // Close chat
210
+ closeChat.addEventListener('click', function() {
211
+ chatModal.classList.add('hidden');
212
  });
213
+
214
+ // Send message
215
+ sendMessage.addEventListener('click', sendChatMessage);
216
+ chatInput.addEventListener('keypress', function(e) {
217
+ if (e.key === 'Enter') {
218
+ sendChatMessage();
219
+ }
220
+ });
221
+
222
+ function sendChatMessage() {
223
+ const message = chatInput.value.trim();
224
+ if (message) {
225
+ // Add user message
226
+ addMessage(message, 'user');
227
+ chatInput.value = '';
228
+
229
+ // Simulate AI response after delay
230
+ setTimeout(() => {
231
+ const responses = [
232
+ "I understand you're asking about " + message + ". Can you provide more details?",
233
+ "For " + message + ", we offer several solutions depending on your needs.",
234
+ "That's an interesting question about " + message + ". Let me check our knowledge base.",
235
+ "Many clients ask about " + message + ". Here's what we typically recommend..."
236
+ ];
237
+ const randomResponse = responses[Math.floor(Math.random() * responses.length)];
238
+ addMessage(randomResponse, 'ai');
239
+ }, 1000);
240
+ }
241
+ }
242
+
243
+ function addMessage(text, sender) {
244
+ const messageDiv = document.createElement('div');
245
+ messageDiv.className = 'mb-4 flex';
246
+
247
+ if (sender === 'user') {
248
+ messageDiv.classList.add('justify-end');
249
+ messageDiv.innerHTML = `
250
+ <div class="bg-orange-500 text-white p-3 rounded-lg max-w-xs">
251
+ <p>${text}</p>
252
+ </div>
253
+ `;
254
+ } else {
255
+ messageDiv.innerHTML = `
256
+ <div class="bg-gray-100 p-3 rounded-lg max-w-xs">
257
+ <p>${text}</p>
258
+ </div>
259
+ `;
260
+ }
261
+
262
+ chatMessages.appendChild(messageDiv);
263
+ chatMessages.scrollTop = chatMessages.scrollHeight;
264
+ }
265
  </script>
266
  </body>
267
  </html>