We have found a very easy solution. Watch the video to see the solution.
You can use the Javascript code below:
// logo-btn is ID for the element assigned with click event to show Hubspot chat window
// jQuery (ES6)
$('#logo-btn').on('click', () => {
// check if Hubspot chat is installed
if (window.hubspot_live_messages_running && window.hubspot && window.hubspot.messages) {
window.hubspot.messages.EXPERIMENTAL_API.requestWidgetOpen();
} else {
console.log('Please install HubSpot WordPress plugin');
}
});
// VanillaJs (ES5)
document.getElementById('logo-btn').addEventListener('click', function(event) {
// removef if it is no need to prevent default event such as url redirect in the <a> element
event.preventDefault(true);
// check if Hubspot chat is installed
if (window.hubspot_live_messages_running && window.hubspot && window.hubspot.messages) {
window.hubspot.messages.EXPERIMENTAL_API.requestWidgetOpen();
} else {
console.log('Please install HubSpot WordPress plugin');
}
});
Hi @batjaa,
There isn't currently any public API for the HubSpot chat tool. If you have the inclination, I would encourage you to check out the Ideas Forum on the HubSpot Community. There, you can create a post including your use case that product and other customers can see.