Javascript API: Methods
Tiledesk provides a Tiledesk JavaScript object that responds to a few methods. These allow you to update the 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:
Reinitialize the widget
If your app is characterized by very few page refreshes (i.e., 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.
Restart the widget
This method allows you to restart the widget with the same user's data without making a new authentication. This also maintains all the configurations.
Signin anonymously
This method signs in anonymously:
Signin with JWT Custom Token
This method signs in using a JWT Custom Token as described here: https://developer.tiledesk.com/widget/auth
Make a logout
This will logout the widget:
Show callout
This will show the widget callout if it is not open:
Show or hide the PreChatForm
This parameter configures the PreChatForm visibility:
Set custom PreChatForm JSON
This method allows you to customize preChatFormJson property, and change preChatForm structure if preChatForm is still active (ensure preChatForm value is set to true, otherwise use window.Tiledesk('setPreChatForm', true) before calling setPreChatFormJson). This method accepts an Array (see docs for more detail about customizing it): https://developer.tiledesk.com/widget/advanced/prechat-form-json
Get custom PreChatForm JSON
This method allows you to get the current preChatForm JSON array used in the preChatForm component when it is active (check preChatForm value is set to true):
Set new value to Widget parameter
You can change a value of a Tiledesk Widget parameter. Pass an object in the form of key/value, where key represents the name of the property you want to modify, and value is the new value you want to set:
Set new value to Widget attribute parameter
You can change a value of a Tiledesk Widget attribute parameter. Pass an object in the form of key/value, where key represents the name of the property you want to modify, and value is the new value you want to set:
Start a new conversation
You can programmatically start a new conversation:
Open a conversation from a specific ID
You can programmatically open an already existing conversation by id in the form of 'support-group-'+<project_id>+'-'+uuid
Clear site data
You can programmatically clear saved session data:
Related:
Previous: Widget SDK — https://developer.tiledesk.com/widget/web-sdk
Next: Javascript API: Attributes — https://developer.tiledesk.com/widget/attributes
Last updated 1 year ago