-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
83 lines (74 loc) · 2.42 KB
/
index.html
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Student Counselor - SINTEF</title>
</head>
<body>
<h1 id="loading">Loading…</h1>
<script src="https://botpress.sintef.cloud/assets/modules/channel-web/inject.js"></script>
<script type="text/javascript">
(function () {
// Load the userId from the hash fragment
// Format is #{userId}.{flow}
const hash = window.location.hash;
const match = hash.match(/^#([^.]+)\.?([^.]*)$/);
const userId = (match && match[1]) ? match[1] : window.localStorage.getItem('userId');
const flow = (match && match[2]) ? match[2] : 'none';
if (!userId) {
document.getElementById('loading').innerText = 'No userId found. Please use the link you should have received.';
return;
}
window.localStorage.setItem('userId', userId);
window.location.hash = '';
window.botpressWebChat.init({
host: "https://botpress.sintef.cloud",
botId: "marita",
hideWidget: true,
// showPoweredBy: false,
closeOnEscape: false,
containerWidth: "100%",
layoutWidth: "100%",
disableAnimations: true,
extraStylesheet: "/assets/modules/channel-web/my-student-counselor.css",
userId,
});
window.addEventListener('message', message => {
const messageName = message.data.name;
// Show the chat widget all the time
if (messageName === 'webchatLoaded') {
window.botpressWebChat.sendEvent({ type: 'show' })
} else if (messageName === 'webchatClosed') {
window.close();
} else if (messageName === "webchatReady") {
document.getElementById("loading").style.display = "none";
window.botpressWebChat.sendEvent({
type: "proactive-trigger",
channel: "web",
payload: {
flow,
}
});
}
});
})();
</script>
<style type="text/css">
#loading {
position: absolute;
top: 1em;
left: 1em;
right: 1em;
bottom: 1em;
display: flex;
text-align: center;
justify-content: center;
align-items: center;
font-size: 2em;
font-weight: bold;
font-family: sans-serif;
color: #000;
}
</body></html>