-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
155 lines (124 loc) · 5.08 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>tattaTeun</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link href="https://fonts.googleapis.com/css2?family=Raleway&display=swap" rel="stylesheet">
</head>
<script crossorigin="anonymous"
src="https://cdn.botframework.com/botframework-webchat/latest/webchat-minimal.js"></script>
<style>
html,
body {
height: 100%;
}
body {
margin: 0;
}
#webchat {
height: 90%;
width: 100%;
}
img {
margin-top: 20px;
margin-left: 20px;
}
p {
font-family: 'Raleway', sans-serif;
/* replace with your preferred font */
font-weight: bold;
font-size: 16PX;
color: #00116e;
margin-top: 55px;
margin-left: 25px;
}
/* rest of your styles */
</style>
</style>
</head>
<body>
<img src="logo.png" alt="Logo" width="200" />
<div id="webchat" role="main"></div>
<script>
(async function () {
const res = await fetch('https://europe.webchat.botframework.com/api/tokens', { method: 'POST' });
const { token } = await res.json();
const store = window.WebChat.createStore();
window.WebChat.renderWebChat(
{
directLine: window.WebChat.createDirectLine({ secret: 'r44Hw8495k0.P6cPwNzCecp8_RttRFSuBsygBn9I5u7c_61FAGFqRFE' }),
store,
styleOptions: {
hideUploadButton: true, // Hide the upload button
hideSendBox: true // Hide the send box
}
},
document.getElementById('webchat')
);
document.querySelector('#webchat > *').focus();
// Create a custom input box
const inputBox = document.createElement('input');
inputBox.type = 'text';
inputBox.id = 'customInputBox';
inputBox.style.width = 'auto%'; // Set the width
inputBox.style.height = '30px'; // Set the height
inputBox.style.marginLeft = '20px'; // Move the box to the right
inputBox.style.marginBottom = '20px';; // Move the box to the bottom
document.body.appendChild(inputBox);
// Create a send button
const sendButton = document.createElement('button');
sendButton.id = 'customSendButton';
sendButton.textContent = 'Vraag tattaTeun';
sendButton.style.marginLeft = '10px'; // Move the button to the right
document.body.appendChild(sendButton);
// Function to handle sending the message
function sendMessage() {
let inputText = inputBox.value;
// Remove spaces
inputText = inputText.replace(/\s+/g, '');
// If the input text is "start"
if (inputText.toLowerCase() === 'start') {
inputText = 'begin';
}
// If the input text is "voorbeeld"
if (inputText.toLowerCase() === 'voorbeeld') {
inputText = '#WatMoetIkDoen';
}
// If the input text is "performance"
if (inputText.toLowerCase() === 'performance') {
inputText = '#SnelSnellerSnelst';
}
// If the input text is "baseline"
if (inputText.toLowerCase() === 'baseline') {
inputText = '#SterkeBasis';
}
// If the input text is "functionaliteit"
if (inputText.toLowerCase() === 'functionaliteit') {
inputText = '#BesteProduct';
}
// If the input text is "vitaliteit"
if (inputText.toLowerCase() === 'vitaliteit') {
inputText = '#BeTheLimit';
}
// When the button is clicked, send the message
store.dispatch({
type: 'WEB_CHAT/SEND_MESSAGE',
payload: { text: `%${inputText}%` } // Use inputText here instead of event.target.value
});
// Clear the input box
inputBox.value = '';
}
// Handle the Enter key press event
inputBox.addEventListener('keydown', function (event) {
if (event.key === 'Enter') {
event.preventDefault(); // Prevent the default action (new line)
sendMessage(); // Call the sendMessage function
}
});
// Handle the click event
sendButton.addEventListener('click', sendMessage); // Call the sendMessage function
})().catch(err => console.error(err));
</script>
</body>
</html>