Hi All,
I am getting the below error when i initiates chat second time. i couldn't find out the root cause of this issue. any help is really appreciated to solve this issue. i am expecting to start the chat without issue every time when i click start chat button.my entire code is listed below the error details.
jsapi-v1.js-async-97913554.js:37 Uncaught Error: Webchat already rendered
at n. (jsapi-v1.js-async-97913554.js:37)
at n.F.load (jsapi-v1.js:1)
at d (jsapi-v1.js:1)
at a (jsapi-v1.js:1)
at jsapi-v1.js:217
at jsapi-v1.js:12
at t (jsapi-v1.js:12)
at r (jsapi-v1.js:12)
at r.s (jsapi-v1.js:11)
at r.emit (jsapi-v1.js:11)
my code:
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Web chat schedules example</title>
<style type="text/css">
#chatButton {
display: none;
}
#chatButton.purecloud-chat-available {
display: inline;
}
</style>
</head>
<body>
<h1>Web chat schedules example</h1>
<form>
<button type="button" id="chat-button">Start Chat</button>
</form>
<div id="chat-container" style="height:600px"></div>
<script src="https://apps.mypurecloud.com/webchat/jsapi-v1.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
let chatConfig = {
"webchatAppUrl": "https://apps.mypurecloud.com/webchat",
"webchatServiceUrl": "https://realtime.mypurecloud.com:443",
"orgId": "1233",
"orgName": "dev",
"queueName": "Chat Queue",
"logLevel": "DEBUG",
"locale": "en",
"data": {
"firstName": "Vernon",
"lastName": "Abbott",
"addressStreet": "250 Dufza Drive",
"addressCity": "Kamnoda",
"addressPostalCode": "46880",
"addressState": "ME",
"phoneNumber": "(817) 211-6371"
},
"companyLogo": {
"width": 600,
"height": 149,
"url": "https://d3a63qt71m2kua.cloudfront.net/developer-tools/788/assets/images/PC-blue-nomark.png"
},
"companyLogoSmall": {
"width": 25,
"height": 25,
"url": "https://d3a63qt71m2kua.cloudfront.net/developer-tools/788/assets/images/companylogo.png"
},
"agentAvatar": {
"width": 462,
"height": 462,
"url": "https://d3a63qt71m2kua.cloudfront.net/developer-tools/788/assets/images/agent.jpg"
},
"welcomeMessage": "Thanks for chatting using the dev tools chat page.",
"cssClass": "webchat-frame",
"css": {
"width": "100%",
"height": "100%"
}
};
var chatButton = document.getElementById('chat-button');
ININ.webchat.create(chatConfig)
.then(function (webchat) {
chatButton.onclick = function () {
webchat.renderFrame({
containerEl: 'chat-container'
});
};
})
.catch(function (err){
console.log(err);
});
</script>
</body>
</html>