Srinivasulu kethanaboina commited on
Commit
c374992
·
verified ·
1 Parent(s): 0a8cf62

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +153 -83
index.html CHANGED
@@ -15,6 +15,7 @@
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>
@@ -24,6 +25,7 @@
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>
@@ -70,12 +72,46 @@
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>
@@ -87,109 +123,143 @@
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>
195
  </html>
 
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
+
19
  <div>
20
  <!-- Country Code Dropdown -->
21
  <select id="country-code" required>
 
25
  </select>
26
  <input type="tel" id="phone" placeholder="Your Phone Number" required>
27
  </div>
28
+
29
  <button type="submit">Start Chat</button>
30
  </form>
31
  </div>
 
72
  userMessage.className = 'message user-message';
73
  userMessage.textContent = input;
74
  chatBody.appendChild(userMessage);
 
75
  // Create bot response
76
  const botMessage = document.createElement('div');
77
  botMessage.className = 'message bot-message';
 
78
  switch (input) {
79
+ case 'Know more about RedFerns Tech':
80
+ botMessage.innerHTML = `
81
+ RedFerns Tech is a leading technology solutions provider specializing in Salesforce consultancy, Zoho services, ServiceNow implementation, and Data Science solutions.
82
+ <button onclick="handleUserInput('Menu')">Menu</button>
83
+ `;
84
+ break;
85
+ case 'Our services':
86
+ botMessage.innerHTML = `
87
+ We offer a range of services tailored to your needs. Please choose one:
88
+ <button onclick="handleUserInput('Salesforce')">Salesforce</button>
89
+ <button onclick="handleUserInput('Zoho')">Zoho</button>
90
+ <button onclick="handleUserInput('Machine Learning')">Machine Learning</button>
91
+ <button onclick="handleUserInput('Data Science')">Data Science</button>
92
+ <button onclick="handleUserInput('Menu')">Menu</button>
93
+ `;
94
+ break;
95
+ case 'Salesforce':
96
+ botMessage.innerHTML = `
97
+ We offer a range of services tailored to your needs. Please choose one:
98
+ <button onclick="handleUserInput('Lightning Service')">Lightning Service</button>
99
+ <button onclick="handleUserInput('Admin Support')">Admin Support</button>
100
+ <button onclick="handleUserInput('App Development')">App Development</button>
101
+ <button onclick="handleUserInput('Sites and Communities')">Sites and Communities</button>
102
+ <button onclick="handleUserInput('Menu')">Menu</button>
103
+ `;
104
+ break;
105
+ case 'Our products':
106
+ botMessage.innerHTML = `
107
+ We offer a range of services tailored to your needs. Please choose one:
108
+ <button onclick="handleUserInput('currency conversion app')">Currency Conversion App</button>
109
+ <button onclick="handleUserInput('mass approvals app')">Mass Approvals App</button>
110
+ <button onclick="handleUserInput('thumbnail viewer app')">Thumbnail Viewer App</button>
111
+ <button onclick="handleUserInput('product filter app')">Product Filter App</button>
112
+ <button onclick="handleUserInput('Menu')">Menu</button>
113
+ `;
114
+ break;
115
  case 'Menu':
116
  botMessage.innerHTML = `
117
  <p>Hi! Welcome to RedFerns Tech! I'm FernAI, here to help you explore our innovative solutions and services. Please select from below:</p>
 
123
  <button onclick="handleUserInput('Appointment Booking')">Appointment Booking</button>
124
  `;
125
  break;
126
+ case 'Appointment Booking':
127
+ botMessage.innerHTML = `
128
+ Please provide the following details to book an appointment:
129
+ <br><br>
130
+ <label for="phoneNumber">Phone Number:</label>
131
+ <input type="text" id="phoneNumber" placeholder="Enter your phone number" />
132
+ <br>
133
+ <label for="appointmentDate">Preferred Date:</label>
134
+ <input type="date" id="appointmentDate" />
135
+ <br>
136
+ <label for="appointmentTime">Preferred Time:</label>
137
+ <input type="time" id="appointmentTime" />
138
+ <br><br>
139
+ <button onclick="submitAppointment()">Submit Appointment</button>
140
+ `;
141
+ break;
142
+ case 'Zoho':
143
+ botMessage.textContent = 'Link is Opening';
144
+ window.open('https://redfernstech.com/services-list/zoho-crm/', '_blank');
145
  break;
146
+ case 'Machine Learning':
147
+ botMessage.textContent = 'Link is Opening';
148
+ window.open('https://redfernstech.com/services-list/machine-learning/', '_blank');
149
+ break;
150
+ case 'Data Science':
151
+ botMessage.textContent = 'Link is Opening';
152
+ window.open('https://redfernstech.com/services-list/data-science/', '_blank');
153
+ break;
154
+ case 'Lightning Service':
155
+ botMessage.textContent = 'Link is Opening';
156
+ window.open('https://redfernstech.com/services-list/salesforce-lightning-services/', '_blank');
157
+ break;
158
+ case 'App Development':
159
+ botMessage.textContent = 'Link is Opening';
160
+ window.open('https://redfernstech.com/services-list/salesforce-app-development/', '_blank');
161
+ break;
162
+ case 'Sites and Communities':
163
+ botMessage.textContent = 'Link is Opening';
164
+ window.open('https://redfernstech.com/services-list/salesforce-sites-communities/', '_blank');
165
+ break;
166
+ case 'Admin Support':
167
+ botMessage.textContent = 'Link is Opening';
168
+ window.open('https://redfernstech.com/services-list/salesforce-admin-and-support/', '_blank');
169
+ break;
170
+ case 'career opportunities':
171
+ botMessage.textContent = 'Link is Opening';
172
+ window.open('https://redfernstech.com/careers/', '_blank');
173
  break;
174
+ case 'product filter app':
175
+ botMessage.textContent = 'Link is Opening';
176
+ window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000K23xNUAR', '_blank');
177
+ break;
178
+ case 'thumbnail viewer app':
179
+ botMessage.textContent = 'Link is Opening';
180
+ window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000K8u1dUAB', '_blank');
181
+ break;
182
+ case 'mass approvals app':
183
+ botMessage.textContent = 'Link is Opening';
184
+ window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000K24EdUAJ', '_blank');
185
+ break;
186
+ case 'currency conversion app':
187
+ botMessage.textContent = 'Link is Opening';
188
+ window.open('https://appexchange.salesforce.com/appxListingDetail?listingId=a0N4V00000K23oVUAR', '_blank');
189
+ break;
190
+ default:
191
+ botMessage.textContent = 'Sorry, I didn\'t understand that.';
192
  }
 
193
  chatBody.appendChild(botMessage);
194
+ chatBody.scrollTop = chatBody.scrollHeight; // Scroll to the bottom
195
  }
196
 
197
+ // Handle the form submission
198
+ userForm.addEventListener('submit', async (event) => {
199
+ event.preventDefault(); // Prevent default form submission
200
+
201
+ // Gather form data
202
+ const name = document.getElementById('name').value;
203
+ const company = document.getElementById('company').value;
204
+ const email = document.getElementById('email').value;
205
+ const countryCode = document.getElementById('country-code').value;
206
+ const phone = document.getElementById('phone').value;
207
 
208
+ // Prepare data to send to the server
209
+ const formData = {
210
+ name,
211
+ company,
212
+ email,
213
+ countryCode,
214
+ phone
215
+ };
216
 
217
+ try {
218
+ // Send data to the new server URL
219
+ const response = await fetch('http://your-new-server-url.com/submit-form', {
220
  method: 'POST',
221
  headers: {
222
+ 'Content-Type': 'application/json',
223
  },
224
  body: JSON.stringify(formData)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  });
 
 
 
 
 
 
 
 
 
 
 
 
226
 
227
+ if (!response.ok) {
228
+ throw new Error('Network response was not ok');
229
+ }
230
+
231
+ const result = await response.json();
232
+ // Assuming the response contains a unique ID
233
+ const uniqueID = result.uniqueID; // Update according to your server response structure
234
+
235
+ // Open Gradio URL with unique ID
236
+ gradioFrame.src = `https://srinuksv-srunu.hf.space/?uniqueID=${uniqueID}`;
237
+
238
+ // Hide form container and show Gradio iframe
239
+ formContainer.style.display = 'none';
240
+ gradioIframe.style.display = 'block';
241
+
242
+ } catch (error) {
243
+ console.error('There was a problem with the fetch operation:', error);
244
+ // Handle error gracefully
245
  }
246
  });
247
 
248
+ // Event listeners for chat icon and buttons
249
+ chatIcon.addEventListener('click', () => {
250
+ formContainer.style.display = 'block';
251
+ chatBox.style.display = 'none';
252
  });
253
 
254
+ closeChat.addEventListener('click', () => {
 
255
  chatBox.style.display = 'none';
256
+ formContainer.style.display = 'block';
 
257
  });
258
 
259
+ backButton.addEventListener('click', () => {
260
+ gradioIframe.style.display = 'none';
261
+ formContainer.style.display = 'block';
262
+ });
 
 
 
 
263
  </script>
 
264
  </body>
265
  </html>