-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
137 lines (127 loc) · 4.89 KB
/
Copy pathindex.html
File metadata and controls
137 lines (127 loc) · 4.89 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Contoso Sample Web Chat</title>
<!-- This styling is for the canvas demonstration purposes. It is recommended
that style is moved to separate file for organization in larger projects -->
<style>
html, body {
height: 100%;
}
body {
margin: 0;
}
h1 {
font-size: 16px;
font-family: Segoe UI;
line-height: 20px;
color: whitesmoke;
display: table-cell;
margin-left: 10px;
}
.heading {
background-color: rgb(0, 46, 96);
height: 50px;
display: flex;
align-items: center;
padding-left: 10px;
}
.main {
margin: 18px;
border-radius: 4px;
}
div[role="form"]{
background-color: rgb(223, 223, 223);
}
#webchat {
position: fixed;
height: calc(100% - 50px);
width: 100%;
top: 50px;
overflow: hidden;
}
.logo {
height: 30px;
width: 30px;
}
a {
color: rgb(255, 255, 255);
}
a:visited {
color:blueviolet;
}
</style>
</head>
<body>
<div>
<div class="heading">
<!-- Add logo image link here -->
<img src="/logo.png" class="logo">
<!-- Change the h1 text to change the bot name -->
<h1>ASTRABot</h1>
</div>
<div id="webchat" role="main"></div>
</div>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<script>
const styleOptions = {
// Add styleOptions to customize web chat canvas#
backgroundColor: 'rgb(255,255,255)',
bubbleBackground: 'rgb(0, 46, 96)',
bubbleTextColor: 'white',
botAvatarInitials: 'AB',
// add the BotAvatar image link here
botAvatarImage: "/AstraBotAvatar.png",
userAvatarInitials: 'U',
// add the userAvatar image link here
userAvatarImage: "/UserAvatar.png",
suggestedActionTextColor: 'rgb(0, 46, 96)',
suggestedActionBorderColor: 'rgb(0, 46, 96)',
hideUploadButton: true
};
// Add your BOT ID below (this can be found in the Mobile App chanel)
var BOT_ID = "ecb6d61a-81d8-454e-9ed5-1046e3cc238b";
var theURL = "https://powerva.microsoft.com/api/botmanagement/v1/directline/directlinetoken?botId=" + BOT_ID;
const store = window.WebChat.createStore(
{},
({ dispatch }) => next => action => {
if (action.type === "DIRECT_LINE/CONNECT_FULFILLED") {
dispatch({
meta: {
method: "keyboard",
},
payload: {
activity: {
channelData: {
postBack: true,
},
//Web Chat will show the 'Greeting' System Topic message which has a trigger-phrase 'hello'
name: 'startConversation',
type: "event"
},
},
type: "DIRECT_LINE/POST_ACTIVITY",
});
}
return next(action);
}
);
fetch(theURL)
.then(response => response.json())
.then(conversationInfo => {
window.WebChat.renderWebChat(
{
directLine: window.WebChat.createDirectLine({
token: conversationInfo.token,
}),
store: store,
styleOptions: styleOptions
},
document.getElementById('webchat')
);
document.querySelector('#webchat > *').focus();
})
.catch(err => console.error("An error occurred: " + err));
</script>
</body>
</html>