Thank you for the response, I checked lot of documentations and blogs but i couldn't find anything on how can we reset the conversation on button click , if there is any related documentation or CSS or JS scripts that will help to reset conversation when button is clicked?
<!DOCTYPE html>
<html>
<head>
<title>My Bot</title>
<style>
html,
body {
height: 100%;
}
body {
margin: 0;
}
h1 {
color: whitesmoke;
font-family: Segoe UI;
font-size: 16px;
line-height: 20px;
margin: 0;
padding: 0 20px;
}
#webchat {
height: calc(100% - 50px);
overflow: hidden;
position: fixed;
top: 50px;
width: 100%;
}
</style>
<meta></head>
<body onfocusout="parent.setEmailRange();" style="overflow-wrap: break-word;">
<div>
<div id="banner">
<h1></h1>
</div>
<div id="webchat" role="main"></div>
</div>
<script>
const styleSet = window.WebChat.createStyleSet({
// Add styleOptions to customize Web Chat canvas
bubbleBackground: "rgba(0, 0, 255, .1)",
bubbleFromUserBackground: "rgba(0, 255, 0, .1)",
rootHeight: "100%",
rootWidth: "100%",
backgroundColor: "white",
hideUploadButton: false,
userAvatarBackgroundColor: "white",
botAvatarBackgroundColor: "white",
suggestedActionLayout: 'stacked'
});
styleSet.textContent = {
...styleSet.textContent,
fontFamily: "'Comic Sans MS', 'Arial', sans-serif",
fontWeight: 'bold'
};
// Set the avatar options.
const avatarOptions = {
accent: '#0079bb',
botAvatarBackgroundColor: '#6D31A2',
botAvatarImage: '',
botAvatarInitials: 'BT',
hideUploadButton: true,
botAvatarBackground: '#6D31A2',
userAvatarBackground: '#6D31A2',
suggestedActionLayout: 'stacked',
userAvatarInitials: 'WC'
};
// Add your BOT ID below
const BOT_ID = "my_bot_id";
const theURL =" ****"
const directLineTokenString = "directLineToken";
const getDirectLineToken = async () => {
if (!sessionStorage) return undefined;
const now = Date.now();
let tokenItem = undefined;
try {
tokenItem = JSON.parse(sessionStorage.getItem(directLineTokenString));
} catch (err) {
console.error("An error occurred: " + err);
}
// If there is no token in storage or the token has expired
if (!tokenItem || (tokenItem && now > tokenItem.expiration)) {
try {
const res = await fetch(theURL);
const result = await res.json();
const tokenStorageItem = {
token: result.token,
expiration: now + result.expires_in * 1000,
};
sessionStorage.setItem(
directLineTokenString,
JSON.stringify(tokenStorageItem)
);
return result.token;
} catch (err) {
sessionStorage.removeItem(directLineTokenString);
console.error("An error occurred: " + err);
return undefined;
}
} else {
return tokenItem.token;
}
};
(async function () {
const token = await getDirectLineToken();
window.WebChat.renderWebChat(
{
directLine: window.WebChat.createDirectLine({ token }),
styleSet, styleOptions: avatarOptions
},
document.getElementById("webchat")
);
})().catch(async (err) => {
console.error("An error occurred: " + err);
});
</script>
</body>
</html>