|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Chatbot</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/admin-lte@3.1/dist/css/adminlte.min.css">
|
|
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js"></script>
|
|
</head>
|
|
<body class="hold-transition sidebar-mini">
|
|
<div class="wrapper">
|
|
|
|
{% include 'sidepane.html' %}
|
|
<form id="myform">
|
|
|
|
<div class="content-wrapper">
|
|
<section class="content">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Chat History</h5>
|
|
<textarea class="form-control" id="chatHistory" readonly></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
|
|
<div class="container-fluid">
|
|
<div class="row" style="width:50%">
|
|
<div class="col-md-3"></div>
|
|
<div class="col-md-6" style="margin-left: 90px;">
|
|
<div class="input-group">
|
|
<input type="text" class="form-control" name="user_question" id="user_question" placeholder="Enter your question">
|
|
<button type="button" class="btn btn-primary" onclick="submitQuestion()">Submit</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<script>
|
|
function submitQuestion() {
|
|
|
|
var question = document.getElementById("user_question").value;
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
var myForm = document.getElementById('myform');
|
|
var formData = new FormData(myForm);
|
|
xhr.open("POST", "/chat_with_agent", true);
|
|
xhr.send(formData);
|
|
|
|
|
|
xhr.onreadystatechange = function() {
|
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
if (xhr.status === 200) {
|
|
|
|
|
|
console.log(xhr.responseText);
|
|
|
|
var chatHistory = document.getElementById("chatHistory");
|
|
chatHistory.value += "User: " + question + "\n";
|
|
chatHistory.value += "Chatbot: " + xhr.responseText + "\n";
|
|
|
|
|
|
document.getElementById("user_question").value = "";
|
|
|
|
} else {
|
|
|
|
alert('There was a problem with the request.');
|
|
console.error('Error:', xhr.statusText);
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|