Spaces:
Running
Running
Update static/index.html
Browse files- static/index.html +16 -1
static/index.html
CHANGED
@@ -135,7 +135,19 @@
|
|
135 |
});
|
136 |
document.getElementById("close-button").addEventListener("click", closeChat);
|
137 |
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
const input = document.getElementById("user-input");
|
140 |
const userId = document.getElementById("user-id").value;
|
141 |
const message = input.value.trim();
|
@@ -168,6 +180,9 @@
|
|
168 |
}
|
169 |
}
|
170 |
|
|
|
|
|
|
|
171 |
|
172 |
async function closeChat() {
|
173 |
const userId = document.getElementById("user-id").value;
|
|
|
135 |
});
|
136 |
document.getElementById("close-button").addEventListener("click", closeChat);
|
137 |
|
138 |
+
window.addEventListener('DOMContentLoaded', () => {
|
139 |
+
sendInitialBotMessage(); // Trigger initial message when chatbot opens
|
140 |
+
});
|
141 |
+
|
142 |
+
function sendInitialBotMessage() {
|
143 |
+
const userId = document.getElementById("user-id").value;
|
144 |
+
const initialMessage = "Hello! How can I assist you today?"; // Initial bot message
|
145 |
+
|
146 |
+
addMessage("Bot", initialMessage, "bot-message"); // Display the initial bot message
|
147 |
+
chatHistoryArray.push({ userId, sender: "Bot", message: initialMessage }); // Save to chat history
|
148 |
+
}
|
149 |
+
|
150 |
+
async function sendMessage() {
|
151 |
const input = document.getElementById("user-input");
|
152 |
const userId = document.getElementById("user-id").value;
|
153 |
const message = input.value.trim();
|
|
|
180 |
}
|
181 |
}
|
182 |
|
183 |
+
|
184 |
+
|
185 |
+
|
186 |
|
187 |
async function closeChat() {
|
188 |
const userId = document.getElementById("user-id").value;
|