You can show up Mailcastr bot when someone clicks on a button on your website.


When Mailcastr widget is initialized it will trigger an event called `mailcastr-bot-loaded`. You can listen for this event and set-up your custom logic for showing chat widget. 


Following example will show you how to open the widget popup when clicking on a button with id `button_to_open_mailcastr_widget`. Place this code before Mailcastr bot snippet.


<script>
  window.addEventListener('mailcastr-bot-loaded', function (botEvent) {
    var button = document.getElementById('button_to_open_mailcastr_widget');
    button.addEventListener('click', function () {
      botEvent.detail.show();
    });
  });
</script>

Use `botEvent.detail.hide()` if you want to hide widget popup when clicking on a button.