hi @evgen12
To initialize widget post destroy, we can have the initialization inside a method like this and call the function in the call back of the widget:destroyed function.
window.fcWidget.on("widget:destroyed", function() {
console.log('After widget destroyed');
initWidget();
// Do some clean-up here
});
function initWidget(){
window.fcWidgetMessengerConfig = {
// add your config here
}
var freshchatScript = document.createElement('script');
freshchatScript.src = '//fw-cdn/********/****.js'; // add the unified js here
freshchatScript.setAttribute('chat', 'true');
//freshchatScript.setAttribute('widgetId', 'widgetUUID');
freshchatScript.id = 'freshchatScript'; // Assign an id to the script
freshchatScript.onload = () => {
window.fwcrm.on('widget:loaded',function(){
// Add your custom code here
});
}
// Append the script to the head of the document
var head = document.head || document.getElementsByTagName('head')[0];
head.insertBefore(freshchatScript, head.firstChild);
}
Hope it helps with ur query shared.
Thanks