forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
49 lines (44 loc) · 1.88 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
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Web Chat: Customizing thru style options</title>
<script type="text/javascript" src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
html, body { height: 100% }
body { margin: 0 }
#webchat,
#webchat > * {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="webchat"></div>
<script>
const styleOptions = {
backgroundColor: 'Black',
bubbleBackground: '#222',
bubbleBorder: 'solid 1px #444',
bubbleBorderRadius: 20,
bubbleFromUserBackground: '#222',
bubbleFromUserBorder: 'solid 1px #444',
bubbleFromUserBorderRadius: 20,
bubbleFromUserTextColor: 'White',
bubbleTextColor: 'White'
};
// In this demo, we are showing how to initialize Web Chat with a secret. This is NOT RECOMMENDED for deployed bots.
// Your client code must provide either a secret or a token to talk to your bot.
// Tokens are more secure. To learn about the differences between secrets and tokens
// and to understand the risks associated with using secrets, visit https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-authentication?view=azure-bot-service-4.0
// The code commented out below exemplifies how to implement the same page while fetching a token from your own token server.
// const res = await fetch('https:YOUR_TOKEN_SERVER.NET/API', { method: 'POST' });
// const { token } = await res.json();
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ secret: 'YOUR_BOT_SECRET_FROM_AZURE' }),
// directLine: window.WebChat.createDirectLine({ token }),
styleOptions
}, document.getElementById('webchat'));
</script>
</body>
</html>