API methods provided by chat
The chat widget provides several API methods to help you customize it to your specific needs.
Important...⚠️
To be able to use the following methods, you must first initialize the API by calling the following code:
window._tc=window._tc||function(){(_tc.q=_tc.q||[]).push(arguments)};
List of methods:
-
Opening the chat
-
Method allows you to open the chat widget.
_tc('open_chat');
-
Method allows you to open the chat form.
_tc('open_chat_form');
-
Method allows you to open a minimized window or open a new widget window.
_tc('open');
-
Opening a callback
Method allows you to open the callback widget.
_tc('open_callback');
Method allows you to open the callback widget form.
_tc('open_callback_form');
-
Opening an email message
Method allows you to open the email widget.
_tc('open_email');
-
Closing the widget
Method allows you to close an open widget.
_tc('close');
-
Minimizing the conversation window
Method allows you to minimize the conversation window.
_tc('minimalize');
-
Set default customer data (Name, email address, chat queue, phone number, callback queue)
Method allows you to set the customer's default name, email and phone number and select a queue for chats and callbacks.
_tc('set_user', 'name', 'email_address', topicId, 'phone', queueId);
-
Setting the element in which the widget will be placed
Method allows you to select the element to which the widget will be attached (by default BODY). It takes as parameter the identifier (id) of the corresponding element.
_tc('set_container', 'element-id');
-
Listening for events (such as the start of a conversation)
Method allows you to run the code after a specific event (such as starting a conversation).
_tc('event_listener', function(event) { alert('Zdarzenie: ' + event); });
Supported events:
conversation_created
- conversation start,conversation_finished
- end of conversation,callback_created
- ordered callback for now,callback_finished
- completed callback,callback_scheduled
- ordered callback for the date of your choice,ticket_created
- message left,poke_showed
- poke shown,minimized
- minimized the widget window via the button "_",closed
- window closed with "x",opened
- minimized or closed widget opened.
Example use:
Set customer data and open chat after clicking on a link on the page
HTML:
<a href="#" id="open-chat-link">open chat</a>
JavaScript:
window.addEventListener('load', function () {
window._tc = window._tc || function () {
(_tc.q = _tc.q || []).push(arguments);
};
document
.getElementById('open-chat-link')
.addEventListener('click', function () {
_tc('set_user', 'Janko Walski', 'janko@wals.ki');
_tc('open_chat');
});
});
Share your opinion with us