Reputation: 182
I have made a chat bot, right now i've hosted it on local server.
I want to embed it in my website, So what exactly I want to have is something like a button/icon hovering on right bottom side of website just like this example.
And on clicking it, it should pop open a chat bot window over the website. How should I proceed to do this
Upvotes: 0
Views: 3178
Reputation: 3856
Basically you're going to have your two things, the popup and the trigger:
<div class="popup">
... Popup Stuff
</div>
<button>Click Me</button>
If the popup is hosted off the page you're on, you can use an iframe in the popup to render it:
<div class="popup">
<iframe src="http://wherever"/>
</div>
<button>Click Me</button>
You want the button to toggle the display state of the popup
const button = document.querySelector('button');
const popup = document.querySelector('.popup');
button.addEventListener('click', ()=>{
popup.style.display === 'none' ? popup.style.display = 'block' : popup.style.display = 'none';
})
Upvotes: 1