-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.php
More file actions
38 lines (37 loc) · 1.64 KB
/
bot.php
File metadata and controls
38 lines (37 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/chatbot_style.css">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<div class="wrapper">
<div class="form">
<div class="bot-inbox inbox">
<div class="icon"><i class="fas fa-user"></i></div>
<div class="msg-header"><p>Welcome Nexis 365, How can I help you?</p></div>
</div>
</div>
<div class="typing-field"><div class="input-data">
<input id="data" type="text" placeholder="Type something here.." required><button id="send-btn">Send</button>
</div></div>
</div>
<script>
$(document).ready(function(){
$("#send-btn").on("click", function(){
$value = $("#data").val();
$msg = '<div class="user-inbox inbox"><div class="msg-header"><p>'+ $value +'</p></div></div>';
$(".form").append($msg);
$("#data").val('');
// start ajax code
$.ajax({
url: 'message.php',
type: 'POST',
data: 'text='+$value,
success: function(result){
$replay = '<div class="bot-inbox inbox"><div class="icon"><i class="fas fa-user"></i></div><div class="msg-header"><p>'+ result +'</p></div></div>';
$(".form").append($replay);
// when chat goes down the scroll bar automatically comes to the bottom
$(".form").scrollTop($(".form")[0].scrollHeight);
}
});
});
});
</script>