Additional Webchat Script Controls

The Webchat widget can be customised further using the following Proto scripts to control its display and behaviour.

Check if the Widget is Open or Closed

You can monitor whether the widget is currently open or closed by adding event handlers to the script:

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

Use Case: This can be helpful for tracking widget interactions or triggering additional actions when the widget opens or closes.

Hide the Bot Avatar When the Widget Loads

To keep the bot avatar hidden initially and display only the toggle button, you can use the showToggleButton option:

htmlCopy code<script type="text/javascript">
  window.protoSettings = {
    id: 'CHANNEL ID',
    showToggleButton: false,
    onInit: function () {
      // Your custom initialisation logic
    },
  };
  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>

Use Case: This is useful if you want to minimise the widget's visibility on page load, especially for websites with limited screen space or specific user interface requirements.

These scripts provide added flexibility for managing the behaviour and display of the Webchat widget, enabling you to tailor the customer experience further.

Last updated