Overview

This JavaScript API is available on every page that has the widget. All methods reside in window.widgetformapi object.

Methods

All the methods are available on widnow.widgetformapi object.

Open Form/Widget

window.widgetformapi.open(form_id_or_name: string|undefined) - opens the widget. Can be used to open the widget manually (e.g. on button click). If form_id_or_name passed, opens form with matching id or name (case insensitive). If no form with given form_id_or_name was found, opens the widget as if the parameter was not passed.

Close Widget

window.widgetformapi.close() - closes the widget.

Change Bubble Text

window.widgetformapi.changeBubbleText(text: string|null) - changes the text in the bubble next to the widget form. If null is passed, hides the message container.

image.png

Get Current Configuration

window.widgetformapi.getConfiguration() => Website - returns current configuration for the widget. The configuration is fetched asynchronously, thus it may return undefined if the configuration is not fetched as the moment of a call.

On Ready

window.widgetformapi.onReady((cb: (config: Website) => void)) - method allows you to register a callback function that will be executed when the configuration is ready.