Spaces:
Running
Running
Srinivasulu kethanaboina
commited on
Update index.html
Browse files- index.html +128 -338
index.html
CHANGED
@@ -10,28 +10,22 @@
|
|
10 |
|
11 |
<!-- Form Container -->
|
12 |
<div id="form-container">
|
13 |
-
|
14 |
<form id="user-form">
|
15 |
<h2>We need basic information to guide you</h2>
|
16 |
<input type="text" id="name" placeholder="Your Name" required>
|
17 |
<input type="text" id="company" placeholder="Company Name" required>
|
18 |
<input type="email" id="email" placeholder="Your Email" required>
|
19 |
-
|
20 |
<div>
|
21 |
<!-- Country Code Dropdown -->
|
22 |
<select id="country-code" required>
|
23 |
<option value="">Select a country</option>
|
24 |
<option value="AF">Afghanistan (+93)</option>
|
25 |
<option value="AL">Albania (+355)</option>
|
26 |
-
|
27 |
</select>
|
28 |
<input type="tel" id="phone" placeholder="Your Phone Number" required>
|
29 |
</div>
|
30 |
-
|
31 |
<button type="submit">Start Chat</button>
|
32 |
</form>
|
33 |
-
|
34 |
-
|
35 |
</div>
|
36 |
|
37 |
<!-- Chatbox -->
|
@@ -59,346 +53,142 @@
|
|
59 |
|
60 |
<script>
|
61 |
// Elements
|
62 |
-
|
63 |
-
|
64 |
-
const
|
65 |
-
const
|
66 |
-
const
|
67 |
-
const
|
68 |
-
const
|
69 |
-
const
|
70 |
-
const
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
//
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
// Create bot response
|
83 |
-
const botMessage = document.createElement('div');
|
84 |
-
botMessage.className = 'message bot-message';
|
85 |
-
|
86 |
-
// Define bot responses based on user input
|
87 |
-
switch (input) {
|
88 |
-
case 'Know more about RedFerns Tech':
|
89 |
-
botMessage.innerHTML = `
|
90 |
-
RedFerns Tech is a leading technology solutions provider specializing in Salesforce consultancy, Zoho services, ServiceNow implementation, and Data Science solutions.
|
91 |
-
<button onclick="handleUserInput('Menu')">Menu</button>
|
92 |
-
`;
|
93 |
-
break;
|
94 |
-
case 'Our services':
|
95 |
-
botMessage.innerHTML = `
|
96 |
-
We offer a range of services tailored to your needs. Please choose one:
|
97 |
-
<button onclick="handleUserInput('Salesforce')">Salesforce</button>
|
98 |
-
<button onclick="handleUserInput('Zoho')">Zoho</button>
|
99 |
-
<button onclick="handleUserInput('Machine Learning')">Machine Learning</button>
|
100 |
-
<button onclick="handleUserInput('Data Science')">Data Science</button>
|
101 |
-
<button onclick="handleUserInput('Menu')">Menu</button>
|
102 |
-
`;
|
103 |
-
break;
|
104 |
-
case 'Salesforce':
|
105 |
-
botMessage.innerHTML = `
|
106 |
-
We offer a range of services tailored to your needs. Please choose one:
|
107 |
-
<button onclick="handleUserInput('Lightning Service')">Lightning Service</button>
|
108 |
-
<button onclick="handleUserInput('Admin Support')">Admin Support</button>
|
109 |
-
<button onclick="handleUserInput('App Development')">App Development</button>
|
110 |
-
<button onclick="handleUserInput('Sites and Communities')">Sites and Communities</button>
|
111 |
-
<button onclick="handleUserInput('Menu')">Menu</button>
|
112 |
-
`;
|
113 |
-
break;
|
114 |
-
case 'Our products':
|
115 |
-
botMessage.innerHTML = `
|
116 |
-
We offer a range of services tailored to your needs. Please choose one:
|
117 |
-
<button onclick="handleUserInput('currency conversion app')">Currency Conversion App</button>
|
118 |
-
<button onclick="handleUserInput('mass approvals app')">Mass Approvals App</button>
|
119 |
-
<button onclick="handleUserInput('thumbnail viewer app')">Thumbnail Viewer App</button>
|
120 |
-
<button onclick="handleUserInput('product filter app')">Product Filter App</button>
|
121 |
-
<button onclick="handleUserInput('Menu')">Menu</button>
|
122 |
-
`;
|
123 |
-
break;
|
124 |
-
case 'Menu':
|
125 |
-
botMessage.innerHTML = `
|
126 |
-
<p>Hi! Welcome to RedFerns Tech! I'm FernAI, here to help you explore our innovative solutions and services. Please select from below:</p>
|
127 |
-
<button onclick="handleUserInput('Know more about RedFerns Tech')">Know more about RedFerns Tech</button>
|
128 |
-
<button onclick="handleUserInput('Our services')">Our services</button>
|
129 |
-
<button onclick="handleUserInput('Our products')">Our products</button>
|
130 |
-
<button onclick="handleUserInput('career opportunities')">Career Opportunities</button>
|
131 |
-
<button onclick="handleUserInput('chat with expert')">Chat With Expert</button>
|
132 |
-
<button onclick="handleUserInput('Appointment Booking')">Appointment Booking</button>
|
133 |
-
`;
|
134 |
-
break;
|
135 |
-
|
136 |
-
case 'Appointment Booking':
|
137 |
-
botMessage.innerHTML = `
|
138 |
-
Please provide the following details to book an appointment:
|
139 |
-
<br><br>
|
140 |
-
<label for="phoneNumber">Phone Number:</label>
|
141 |
-
<input type="text" id="phoneNumber" placeholder="Enter your phone number" />
|
142 |
-
<br>
|
143 |
-
<label for="appointmentDate">Preferred Date:</label>
|
144 |
-
<input type="date" id="appointmentDate" />
|
145 |
-
<br>
|
146 |
-
<label for="appointmentTime">Preferred Time:</label>
|
147 |
-
<input type="time" id="appointmentTime" />
|
148 |
-
<br><br>
|
149 |
-
<button onclick="submitAppointment()">Submit Appointment</button>
|
150 |
-
`;
|
151 |
-
break;
|
152 |
-
|
153 |
-
case 'Zoho':
|
154 |
-
botMessage.textContent = 'Link is Opening';
|
155 |
-
window.open('https://redfernstech.com/services-list/zoho-crm/', '_blank');
|
156 |
-
break;
|
157 |
-
case 'Machine Learning':
|
158 |
-
botMessage.textContent = 'Link is Opening';
|
159 |
-
window.open('https://redfernstech.com/services-list/machine-learning/', '_blank');
|
160 |
-
break;
|
161 |
-
case 'Data Science':
|
162 |
-
botMessage.textContent = 'Link is Opening';
|
163 |
-
window.open('https://redfernstech.com/services-list/data-science/', '_blank');
|
164 |
-
break;
|
165 |
-
case 'Lightning Service':
|
166 |
-
botMessage.textContent = 'Link is Opening';
|
167 |
-
window.open('https://redfernstech.com/services-list/salesforce-lightning-services/', '_blank');
|
168 |
-
break;
|
169 |
-
case 'App Development':
|
170 |
-
botMessage.textContent = 'Link is Opening';
|
171 |
-
window.open('https://redfernstech.com/services-list/salesforce-app-development/', '_blank');
|
172 |
-
break;
|
173 |
-
case 'Sites and Communities':
|
174 |
-
botMessage.textContent = 'Link is Opening';
|
175 |
-
window.open('https://redfernstech.com/services-list/salesforce-sites-communities/', '_blank');
|
176 |
-
break;
|
177 |
-
case 'Admin Support':
|
178 |
-
botMessage.textContent = 'Link is Opening';
|
179 |
-
window.open('https://redfernstech.com/services-list/salesforce-admin-and-support/', '_blank');
|
180 |
-
break;
|
181 |
-
case 'career opportunities':
|
182 |
-
botMessage.textContent = 'Link is Opening';
|
183 |
-
window.open('https://redfernstech.com/careers/', '_blank');
|
184 |
-
break;
|
185 |
-
case 'product filter app':
|
186 |
-
botMessage.textContent = 'Link is Opening';
|
187 |
-
window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000K23xNUAR', '_blank');
|
188 |
-
break;
|
189 |
-
case 'thumbnail viewer app':
|
190 |
-
botMessage.textContent = 'Link is Opening';
|
191 |
-
window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000K8u1dUAB', '_blank');
|
192 |
-
break;
|
193 |
-
case 'mass approvals app':
|
194 |
-
botMessage.textContent = 'Link is Opening';
|
195 |
-
window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000K24EdUAJ', '_blank');
|
196 |
-
break;
|
197 |
-
case 'currency conversion app':
|
198 |
-
botMessage.textContent = 'Link is Opening';
|
199 |
-
window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000Is77CUAR', '_blank');
|
200 |
-
break;
|
201 |
-
case 'chat with expert':
|
202 |
-
// Show the iframe with the Gradio chatbot URL
|
203 |
-
gradioIframe.style.display = 'flex';
|
204 |
-
chatBox.style.display = 'none';
|
205 |
-
formContainer.style.display = 'none';
|
206 |
-
chatIcon.style.display = 'none'; // Hide chat icon
|
207 |
-
gradioFrame.src = 'https://srinuksv-fastapi.hf.space/'; // Replace with your Gradio chatbot URL
|
208 |
-
botMessage.textContent = 'Loading Salesforce chatbot...'; // Optional: Notify the user
|
209 |
-
break;
|
210 |
-
default:
|
211 |
-
botMessage.textContent = 'Sorry, I didn’t understand that. Can you please choose another option?';
|
212 |
-
break;
|
213 |
-
}
|
214 |
-
chatBody.appendChild(botMessage);
|
215 |
-
chatBody.scrollTop = chatBody.scrollHeight;
|
216 |
-
}
|
217 |
-
|
218 |
-
// Show form container
|
219 |
-
function showForm() {
|
220 |
-
formContainer.style.display = 'flex';
|
221 |
-
chatBox.style.display = 'none';
|
222 |
-
gradioIframe.style.display = 'none'; // Hide Gradio iframe if visible
|
223 |
-
chatIcon.style.display = 'flex'; // Hide chat icon
|
224 |
-
}
|
225 |
-
|
226 |
-
// Show chat box
|
227 |
-
function showChat() {
|
228 |
-
formContainer.style.display = 'none';
|
229 |
-
chatBox.style.display = 'flex';
|
230 |
-
gradioIframe.style.display = 'none'; // Hide Gradio iframe if visible
|
231 |
-
chatIcon.style.display = 'flex';
|
232 |
-
initializeChat();
|
233 |
-
}
|
234 |
-
|
235 |
-
// Show Gradio iframe
|
236 |
-
function openGradioChat() {
|
237 |
-
const chatbots = ["Lily", "Clara"];
|
238 |
-
const selectedChatbot = chatbots[Math.floor(Math.random() * chatbots.length)];
|
239 |
-
|
240 |
-
// Hide form and chat box, display Gradio iframe
|
241 |
-
formContainer.style.display = 'none';
|
242 |
-
chatBox.style.display = 'none';
|
243 |
-
gradioIframe.style.display = 'flex';
|
244 |
-
|
245 |
-
// Set the iframe source based on the selected chatbot
|
246 |
-
if (selectedChatbot === "Clara") {
|
247 |
-
gradioIframe.src = "https://srinuksv-fastapi.hf.space/";
|
248 |
-
} else {
|
249 |
-
gradioIframe.src = "https://srinuksv-fastapi.hf.space/";
|
250 |
-
}
|
251 |
-
|
252 |
-
// Display the chat icon
|
253 |
-
chatIcon.style.display = 'flex';
|
254 |
-
}
|
255 |
-
|
256 |
-
|
257 |
-
// Hide Gradio iframe and show chat box
|
258 |
-
function goBackToChat() {
|
259 |
-
formContainer.style.display = 'none';
|
260 |
-
chatBox.style.display = 'flex';
|
261 |
-
gradioIframe.style.display = 'none';
|
262 |
-
chatIcon.style.display = 'flex';
|
263 |
-
initializeChat();
|
264 |
-
}
|
265 |
-
|
266 |
-
function submitAppointment() {
|
267 |
-
const phoneNumber = document.getElementById('phoneNumber').value;
|
268 |
-
const appointmentDate = document.getElementById('appointmentDate').value;
|
269 |
-
const appointmentTime = document.getElementById('appointmentTime').value;
|
270 |
-
|
271 |
-
// Split the date into year, month, and day
|
272 |
-
const dateParts = appointmentDate.split('-'); // Assuming the format is YYYY-MM-DD
|
273 |
-
const year = dateParts[0];
|
274 |
-
const month = dateParts[1]; // Google Forms uses 1-indexed months (January is 1, not 0)
|
275 |
-
const day = dateParts[2];
|
276 |
-
|
277 |
-
// Split the time into hour and minute
|
278 |
-
const timeParts = appointmentTime.split(':'); // Assuming the format is HH:MM
|
279 |
-
const hour = timeParts[0];
|
280 |
-
const minute = timeParts[1];
|
281 |
-
|
282 |
-
if (phoneNumber && appointmentDate && appointmentTime) {
|
283 |
-
// Google Form submission URL and entry IDs
|
284 |
-
const googleFormURL = 'https://docs.google.com/forms/u/0/d/e/1FAIpQLSdLLMPObehQAPIJe26ALLP-uGiR_rTbFomaQ6jrYSDKDpC53Q/formResponse';
|
285 |
-
const formData = new FormData();
|
286 |
-
formData.append('entry.399768569', phoneNumber); // Phone number
|
287 |
-
formData.append('entry.524576831_hour', hour); // Appointment hour
|
288 |
-
formData.append('entry.524576831_minute', minute); // Appointment minute
|
289 |
-
formData.append('entry.277009627_year', year); // Appointment year
|
290 |
-
formData.append('entry.277009627_month', month); // Appointment month
|
291 |
-
formData.append('entry.277009627_day', day); // Appointment day
|
292 |
-
|
293 |
-
// Send data to Google Form
|
294 |
-
fetch(googleFormURL, {
|
295 |
-
method: 'POST',
|
296 |
-
body: formData,
|
297 |
-
mode: 'no-cors' // To avoid CORS issues
|
298 |
-
}).then(() => {
|
299 |
-
const botMessage = document.createElement('div');
|
300 |
-
botMessage.className = 'message bot-message';
|
301 |
-
botMessage.innerHTML = `
|
302 |
-
Appointment booked for ${appointmentDate} at ${appointmentTime}. We will contact you at ${phoneNumber}.
|
303 |
-
<br><br>What would you like to do next?
|
304 |
-
<button onclick="handleUserInput('Menu')">Return to Menu</button>
|
305 |
-
`;
|
306 |
-
chatBody.appendChild(botMessage);
|
307 |
-
}).catch(() => {
|
308 |
const botMessage = document.createElement('div');
|
309 |
botMessage.className = 'message bot-message';
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
chatBody.appendChild(botMessage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
});
|
317 |
-
} else {
|
318 |
-
const botMessage = document.createElement('div');
|
319 |
-
botMessage.className = 'message bot-message';
|
320 |
-
botMessage.innerHTML = `
|
321 |
-
Please fill in all the details.
|
322 |
-
<br><br>What would you like to do next?
|
323 |
-
<button onclick="handleUserInput('Menu')">Return to Menu</button>
|
324 |
-
`;
|
325 |
-
chatBody.appendChild(botMessage);
|
326 |
-
}
|
327 |
-
|
328 |
-
chatBody.scrollTop = chatBody.scrollHeight;
|
329 |
-
}
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
// Initialize chat
|
334 |
-
// Initialize chat
|
335 |
-
function initializeChat() {
|
336 |
-
chatBody.innerHTML = '';
|
337 |
-
const welcomeMessage = document.createElement('div');
|
338 |
-
welcomeMessage.className = 'message bot-message';
|
339 |
-
welcomeMessage.innerHTML = `
|
340 |
-
<p>Hi! Welcome to RedFerns Tech! I'm FernAI, here to help you explore our innovative solutions and services. Please select from below:</p>
|
341 |
-
<button onclick="handleUserInput('Know more about RedFerns Tech')">Know more about RedFerns Tech</button>
|
342 |
-
<button onclick="handleUserInput('Our services')">Our services</button>
|
343 |
-
<button onclick="handleUserInput('Our products')">Our products</button>
|
344 |
-
<button onclick="handleUserInput('career opportunities')">Career Opportunities</button>
|
345 |
-
<button onclick="handleUserInput('chat with expert')">Chat With Expert</button>
|
346 |
-
<button onclick="handleUserInput('Appointment Booking')">Appointment Booking</button>
|
347 |
-
`;
|
348 |
-
chatBody.appendChild(welcomeMessage);
|
349 |
-
chatBody.scrollTop = chatBody.scrollHeight;
|
350 |
-
}
|
351 |
-
|
352 |
-
|
353 |
-
// Event Listeners
|
354 |
-
|
355 |
-
chatIcon.addEventListener('click', function() {
|
356 |
-
if (localStorage.getItem('formShown') === 'true') {
|
357 |
-
showChat(); // Show the chat box if form has been shown
|
358 |
-
} else {
|
359 |
-
showForm(); // Show the form if it hasn't been shown
|
360 |
-
}
|
361 |
-
});
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
userForm.addEventListener('submit', function(event) {
|
370 |
-
event.preventDefault();
|
371 |
-
localStorage.setItem('formShown', 'true');
|
372 |
-
showChat();
|
373 |
-
});
|
374 |
-
|
375 |
-
closeChat.addEventListener('click', function() {
|
376 |
-
formContainer.style.display = 'none';
|
377 |
-
chatBox.style.display = 'none';
|
378 |
-
gradioIframe.style.display = 'none';
|
379 |
-
chatIcon.style.display = 'flex';
|
380 |
-
});
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
backButton.addEventListener('click', goBackToChat);
|
386 |
-
|
387 |
-
// Initialize on load
|
388 |
-
if (localStorage.getItem('formShown') === 'true') {
|
389 |
-
showChat();
|
390 |
-
} else {
|
391 |
-
chatIcon.style.display = 'flex'; // Ensure the chat icon is visible initially
|
392 |
-
}
|
393 |
-
// Select the div with class 'component-2 block svelte-12'
|
394 |
-
// Select the div with class 'component-2 block svelte-12'
|
395 |
-
// Select the element with the specific class
|
396 |
-
// Select the element with the specific class
|
397 |
-
// Select the element with the specific class
|
398 |
|
|
|
|
|
|
|
|
|
|
|
399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
|
|
|
401 |
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
</script>
|
403 |
|
404 |
</body>
|
|
|
10 |
|
11 |
<!-- Form Container -->
|
12 |
<div id="form-container">
|
|
|
13 |
<form id="user-form">
|
14 |
<h2>We need basic information to guide you</h2>
|
15 |
<input type="text" id="name" placeholder="Your Name" required>
|
16 |
<input type="text" id="company" placeholder="Company Name" required>
|
17 |
<input type="email" id="email" placeholder="Your Email" required>
|
|
|
18 |
<div>
|
19 |
<!-- Country Code Dropdown -->
|
20 |
<select id="country-code" required>
|
21 |
<option value="">Select a country</option>
|
22 |
<option value="AF">Afghanistan (+93)</option>
|
23 |
<option value="AL">Albania (+355)</option>
|
|
|
24 |
</select>
|
25 |
<input type="tel" id="phone" placeholder="Your Phone Number" required>
|
26 |
</div>
|
|
|
27 |
<button type="submit">Start Chat</button>
|
28 |
</form>
|
|
|
|
|
29 |
</div>
|
30 |
|
31 |
<!-- Chatbox -->
|
|
|
53 |
|
54 |
<script>
|
55 |
// Elements
|
56 |
+
const chatIcon = document.getElementById('chat-icon');
|
57 |
+
const formContainer = document.getElementById('form-container');
|
58 |
+
const chatBox = document.getElementById('chat-box');
|
59 |
+
const gradioIframe = document.getElementById('gradio-iframe');
|
60 |
+
const gradioFrame = document.getElementById('gradio-frame');
|
61 |
+
const closeChat = document.getElementById('close-chat');
|
62 |
+
const backButton = document.getElementById('back-button');
|
63 |
+
const userForm = document.getElementById('user-form');
|
64 |
+
const chatBody = document.getElementById('chat-body');
|
65 |
+
|
66 |
+
// Function to handle user input and display chat responses
|
67 |
+
function handleUserInput(input) {
|
68 |
+
// Display user message
|
69 |
+
const userMessage = document.createElement('div');
|
70 |
+
userMessage.className = 'message user-message';
|
71 |
+
userMessage.textContent = input;
|
72 |
+
chatBody.appendChild(userMessage);
|
73 |
+
|
74 |
+
// Create bot response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
const botMessage = document.createElement('div');
|
76 |
botMessage.className = 'message bot-message';
|
77 |
+
|
78 |
+
switch (input) {
|
79 |
+
case 'Menu':
|
80 |
+
botMessage.innerHTML = `
|
81 |
+
<p>Hi! Welcome to RedFerns Tech! I'm FernAI, here to help you explore our innovative solutions and services. Please select from below:</p>
|
82 |
+
<button onclick="handleUserInput('Know more about RedFerns Tech')">Know more about RedFerns Tech</button>
|
83 |
+
<button onclick="handleUserInput('Our services')">Our services</button>
|
84 |
+
<button onclick="handleUserInput('Our products')">Our products</button>
|
85 |
+
<button onclick="handleUserInput('career opportunities')">Career Opportunities</button>
|
86 |
+
<button onclick="handleUserInput('chat with expert')">Chat With Expert</button>
|
87 |
+
<button onclick="handleUserInput('Appointment Booking')">Appointment Booking</button>
|
88 |
+
`;
|
89 |
+
break;
|
90 |
+
case 'chat with expert':
|
91 |
+
// Show the iframe with the Gradio chatbot URL
|
92 |
+
gradioIframe.style.display = 'flex';
|
93 |
+
chatBox.style.display = 'none';
|
94 |
+
formContainer.style.display = 'none';
|
95 |
+
chatIcon.style.display = 'none'; // Hide chat icon
|
96 |
+
gradioFrame.src = 'https://srinuksv-fastapiyes.hf.space/ch/' + localStorage.getItem('userId');
|
97 |
+
botMessage.textContent = 'Loading Salesforce chatbot...';
|
98 |
+
break;
|
99 |
+
default:
|
100 |
+
botMessage.textContent = 'Sorry, I didn’t understand that.';
|
101 |
+
break;
|
102 |
+
}
|
103 |
+
|
104 |
chatBody.appendChild(botMessage);
|
105 |
+
chatBody.scrollTop = chatBody.scrollHeight;
|
106 |
+
}
|
107 |
+
|
108 |
+
function submitAppointment() {
|
109 |
+
const phoneNumber = document.getElementById('phoneNumber').value;
|
110 |
+
const appointmentDate = document.getElementById('appointmentDate').value;
|
111 |
+
const appointmentTime = document.getElementById('appointmentTime').value;
|
112 |
+
|
113 |
+
if (phoneNumber && appointmentDate && appointmentTime) {
|
114 |
+
const formData = {
|
115 |
+
phoneNumber: phoneNumber,
|
116 |
+
appointmentDate: appointmentDate,
|
117 |
+
appointmentTime: appointmentTime
|
118 |
+
};
|
119 |
+
|
120 |
+
fetch('https://srinuksv-fastapiyes.hf.space/webhook', {
|
121 |
+
method: 'POST',
|
122 |
+
headers: {
|
123 |
+
'Content-Type': 'application/json'
|
124 |
+
},
|
125 |
+
body: JSON.stringify(formData)
|
126 |
+
})
|
127 |
+
.then(response => response.json())
|
128 |
+
.then(data => {
|
129 |
+
localStorage.setItem('userId', data.id); // Store the ID for future use
|
130 |
+
const botMessage = document.createElement('div');
|
131 |
+
botMessage.className = 'message bot-message';
|
132 |
+
botMessage.innerHTML = `
|
133 |
+
Appointment booked! We will contact you shortly.
|
134 |
+
<br><br>What would you like to do next?
|
135 |
+
<button onclick="handleUserInput('Menu')">Return to Menu</button>
|
136 |
+
`;
|
137 |
+
chatBody.appendChild(botMessage);
|
138 |
+
})
|
139 |
+
.catch(() => {
|
140 |
+
const botMessage = document.createElement('div');
|
141 |
+
botMessage.className = 'message bot-message';
|
142 |
+
botMessage.innerHTML = `
|
143 |
+
There was an error booking your appointment. Please try again.
|
144 |
+
<br><br>What would you like to do next?
|
145 |
+
<button onclick="handleUserInput('Menu')">Return to Menu</button>
|
146 |
+
`;
|
147 |
+
chatBody.appendChild(botMessage);
|
148 |
+
});
|
149 |
+
} else {
|
150 |
+
const botMessage = document.createElement('div');
|
151 |
+
botMessage.className = 'message bot-message';
|
152 |
+
botMessage.innerHTML = `
|
153 |
+
Please fill in all the details.
|
154 |
+
<br><br>What would you like to do next?
|
155 |
+
<button onclick="handleUserInput('Menu')">Return to Menu</button>
|
156 |
+
`;
|
157 |
+
chatBody.appendChild(botMessage);
|
158 |
+
}
|
159 |
+
chatBody.scrollTop = chatBody.scrollHeight;
|
160 |
+
}
|
161 |
+
|
162 |
+
// Event Listeners
|
163 |
+
chatIcon.addEventListener('click', function() {
|
164 |
+
if (localStorage.getItem('formShown') === 'true') {
|
165 |
+
showChat(); // Show the chat box if form has been shown
|
166 |
+
} else {
|
167 |
+
showForm(); // Show the form if it hasn't been shown
|
168 |
+
}
|
169 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
+
userForm.addEventListener('submit', function(event) {
|
172 |
+
event.preventDefault();
|
173 |
+
localStorage.setItem('formShown', 'true');
|
174 |
+
showChat();
|
175 |
+
});
|
176 |
|
177 |
+
closeChat.addEventListener('click', function() {
|
178 |
+
formContainer.style.display = 'none';
|
179 |
+
chatBox.style.display = 'none';
|
180 |
+
gradioIframe.style.display = 'none';
|
181 |
+
chatIcon.style.display = 'flex';
|
182 |
+
});
|
183 |
|
184 |
+
backButton.addEventListener('click', goBackToChat);
|
185 |
|
186 |
+
// Initialize on load
|
187 |
+
if (localStorage.getItem('formShown') === 'true') {
|
188 |
+
showChat();
|
189 |
+
} else {
|
190 |
+
chatIcon.style.display = 'flex'; // Ensure the chat icon is visible initially
|
191 |
+
}
|
192 |
</script>
|
193 |
|
194 |
</body>
|