Control the Webchat widget

The following table shows the Proto script that can be used to control the display of the widget:

Script
Description

window.proto.open()

To open the widget

window.proto.close()

To close the widget

window.proto.hide()

To hide the bot avatar and widget

window.proto.show()

To show the bot avatar and widget

window.proto.startchat()

To start the webchat directly

window.proto.isOpen()

To check if the widget is open

window.proto.hideToggleButton();

To hide bot avatar

If you want to check if the widget is open or closed, you can also use the following code:

window.protoSettings = {
      id,
      ...
      onOpen: () => console.log('Webchat opened'),
      onClose: () => console.log('Webchat closed'),
    };

To hide the bot avatar when the widget loads, you can use the showToggleButton option to keep it hidden:

<script type="text/javascript">
  window.protoSettings = {
        id: '',
	showToggleButton: false	
	onInit: function () {			
	}
  };
  var prs = document.createElement('script');
  prs.src = 'https://embed.proto.cx/index.umd.js';
  prs.type = 'text/javascript';
  prs.async = true;
  prs.onload = function () {	
    window.proto.init(window.protoSettings);	
  };  
  
  document.head.appendChild(prs);
</script>

Last updated