-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
41 lines (32 loc) · 1.2 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
(async function () {
// Note, for the simplicity of this example, we are fetching the DirectLine token here;
// however, it is recommended that you create a backend REST API to generate and manage
// your tokens.
const res = await fetch(
"https://directline.botframework.com/v3/directline/tokens/generate",
{
method: "POST",
headers: {
Authorization: `bearer KjxuizIBOs4.eEHCXAPCHENIQWJnn6oq1yYGjOpcMDtbspX_MGDIZcI`,
"Content-Type": "application/json",
},
body: {
// The user id must start with `dl` and should be unique for each user.
User: { Id: "dl_user_id" },
},
}
);
const { token } = await res.json();
const styleOptions = {
botAvatarInitials: 'Nio',
userAvatarInitials: 'You'
};
window.WebChat.renderWebChat(
{
directLine: window.WebChat.createDirectLine({ token }),
styleOptions,
webSpeechPonyfillFactory: window.WebChat.createBrowserWebSpeechPonyfillFactory({ token }),
},
document.getElementById("webchat")
);
})().catch((err) => console.log(err));