Comment on page
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.
This will open the widget:
window.Tiledesk('open');
This will minimize the widget:
window.Tiledesk('close');
This will hide the widget:
window.Tiledesk('hide');
This will show the widget:
window.Tiledesk('show');
This will clear the widget html elements from the DOM:
window.Tiledesk('dispose');
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');
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');
This method make a signin anonymously
window.Tiledesk('signInAnonymous');
window.Tiledesk('signInWithCustomToken', customJwt);
This will logout the widget:
window.Tiledesk('logout');
This will show the widget callout if it is not open:
window.Tiledesk('showCallout');
This parameter configures the PreChatForm visibility:
window.Tiledesk('setPreChatForm', true|false);
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);
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);
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});
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});
You can programatically start a new conversation:
window.Tiledesk('startConversation');
Last modified 6mo ago