-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (21 loc) · 865 Bytes
/
script.js
File metadata and controls
24 lines (21 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function sendMessage() {
var userInput = document.getElementById("user-input").value;
if (userInput.trim() === "") return;
appendMessage(userInput, "user");
// Call BrainShopAPI to get response
// Example code to fetch response from API
fetch('https://api.brainshop.ai/get?bid=181436&key=sUP7pcyDi0iVhlG2&uid=[uid]&msg=' + userInput)
.then(response => response.json())
.then(data => {
var botResponse = data.cnt;
appendMessage(botResponse, "bot");
})
.catch(error => console.error('Error:', error));
}
function appendMessage(message, sender) {
var chatBox = document.getElementById("chat-box");
var messageElement = document.createElement("div");
messageElement.textContent = message;
messageElement.classList.add(sender);
chatBox.appendChild(messageElement);
}