Javascript API: Methods

Tiledesk provides a Tiledesk JavaScript object that responds to a few methods. These allow you to update widget without a page refresh and interact with the messenger window.

Open the widget

This will open the widget:

window.Tiledesk('open');

Minimize the widget

This will minimize the widget:

window.Tiledesk('close');

Hide the widget

This will hide the widget:

window.Tiledesk('hide');

Show the widget

This will show the widget:

window.Tiledesk('show');

Dispose the widget

This will clear the widget html elements from the DOM:

window.Tiledesk('dispose');

Reinitialize the widget

If your app is characterized by very few page refreshes (ie., content is swapped out on the client side but no page refresh happens, Angular, React, jQuery, etc..) and lots of asynchronous JS, you'll need to update Tiledesk when your user's data changes. A reInit call simulates a page refresh, causing Tiledesk to reload the widget and all the configurations.

window.Tiledesk('reInit');

Restart the widget

This method allow you to restart widget with the same user's data without make a new authentication. This also mantein all the configurations.

window.Tiledesk('restart');

Signin with anonymously

This method make a signin anonymously

window.Tiledesk('signInAnonymous');

Signin with JWT Custom Token

This method make a signin using a JWT Custom Token as described here.

window.Tiledesk('signInWithCustomToken', customJwt);

Make a logout

This will logout the widget:

window.Tiledesk('logout');

Show callout

This will show the widget callout if it is not open:

window.Tiledesk('showCallout');

Show or hide the PreChatForm

This parameter configures the PreChatForm visibility:

window.Tiledesk('setPreChatForm', true|false);

Set custom PreChatForm Json

This method allow you to customize preChatFormJson property, and change preChatForm structure if preChatForm is still active (ensure preChatForm value is set to true, otherwize use window.Tiledesk('setPreChatForm', true) method before call setPreChatFormJson ). This method accept an Array (see docs for more detail about customize it):

window.Tiledesk('setPreChatFormJson', customFormArray);

Get custom PreChatForm Json

This method allow you to get current preChatForm Json array used in the preChatForm component when is active (check preChatForm value is set to true):

window.Tiledesk('setPreChatFormJson', customFormArray);

Set new value to Widget parameter

You can change a value to the Tiledesk Widget parameter. Pass an object in the form of key/value, where key represent che name of the property you want to modify, and value is the new value you want to set:

window.Tiledesk('setParameter', {key: string, value: string});

Set new value to Widget attribute parameter

You can change a value to the Tiledesk Widget attribute parameter. Pass an object in the form of key/value, where key represent che name of the property you want to modify, and value is the new value you want to set:

window.Tiledesk('setAttributeParameter', {key: string, value: string});

Start a new conversation

You can programatically start a new conversation:

window.Tiledesk('startConversation');

Last updated