-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (45 loc) · 1.1 KB
/
index.js
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
39
40
41
42
43
44
45
46
47
48
49
50
const firstUser = {
id: "1",
name: "User"
};
const secondUser = {
id: "2",
name: "Feedback Bot",
avatarUrl: "./bot.png"
};
const initialMessages = [{
timestamp: Date.now(),
author: secondUser,
text: `Hello! We'd love to hear your feedback. Please share your thoughts below!`
}];
const alert = [{
id: 1,
message: "Session expired"
}];
$(() => {
function sendToBackend() {
setTimeout(() => {
chat.option("typingUsers", []);
chat.renderMessage({
text: "Thanks for helping us improve!",
author: secondUser,
timestamp: Date.now()
});
chat.option("alerts", alert);
chat.option("disabled", true);
}, 1000);
}
const chat = $("#chat")
.dxChat({
width: 400,
height: 450,
user: firstUser,
onMessageEntered: ({ component, message }) => {
component.renderMessage(message);
chat.option("typingUsers", [secondUser]);
sendToBackend();
},
items: initialMessages
})
.dxChat("instance");
});