Widget Reference

How to use

We have 3 types of the widget:

  • Launcher (the widget window with floating button)

  • Messenger (only the widget window)

  • Chat (only the chat window)

Launcher

If you want to use this type you just need copy your code snippet from https://dashboard.askhandle.com/widgets/ and place this code snippet on your website.

Messenger

To use this type you need set widgetType and root html element where the widget will be inserted. And if you want to use the close button you can add event handler onClosingWindow:

window.webchatConfig = {
  ...
  widgetType: 'messenger',
  rootElement: document.getElementById('your_element_id'),
  actions: {
    onClosingWindow: function() {
      // do something when a user clicks on the close button
    }
  }
  ...
}

See example

Chat

To use the chat type you need set widgetType and root html element where the widget will be inserted:

window.webchatConfig = {
  ...
  widgetType: 'chat',
  rootElement: document.getElementById('your_element_id'),
  actions: {
    init: function(obj) {
      window.ao_widget_api = obj; // so we can use the widget object everywhere
    }
  }
  ...
}

// now we can use following methods
window.ao_widget_api.setUsername(username:string);
window.ao_widget_api.setEmail(email:string);
window.ao_widget_api.sendMessage(text:string, onsuccess:function, onfail:function, showUserMessage:boolean);

See example