-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
90 lines (84 loc) · 2.56 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
<!DOCTYPE html>
<html lang="ja-JP">
<head>
<meta charset="utf-8"/>
<title>Web Chat: Markdown</title>
<script src="https://cdn.botframework.com/botframework-webchat/4.2.1-master.14eebbb/webchat-es5.js"></script>
<script src="https://unpkg.com/[email protected]/lib/marked.js"></script>
<script src="https://unpkg.com/[email protected]/dist/sanitize-html.min.js"></script>
<style>
html, body { height: 100% }
body { margin: 0 }
#webchat,
#webchat > * {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="webchat" role="main"></div>
<script>
fetch('https://directline.botframework.com/v3/directline/tokens/generate', {
method: 'POST',
headers:{
'Authorization': 'Bearer YOUR_SECRET_KEY'
}
})
.then(function (res) { return res.json(); })
.then(function (json) {
const token = json.token;
const SANITIZE_HTML_OPTIONS = {
allowedAttributes: {
a: ['href', 'name', 'target', 'title'],
img: ['alt', 'src']
},
allowedSchemes: ['file', 'http', 'https'],
allowedTags: [
'a',
'b',
'blockquote',
'br',
'caption',
'code',
'div',
'em',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'i',
'img',
'li',
'nl',
'ol',
'p',
'pre',
'span',
'strike',
'strong',
'table',
'tbody',
'td',
'tfoot',
'th',
'thead',
'tr',
'ul'
]
};
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token: token }),
renderMarkdown: function (markdown) {
const html = window.marked(markdown);
return sanitizeHtml(html, SANITIZE_HTML_OPTIONS);
}
}, document.getElementById('webchat'));
document.querySelector('#webchat > *').focus();
})
</script>
</body>
</html>