New JavaScript Visitor Api for Chat Events and Actions

Since yalst 8.0 it has been easy to drive a text chat on the visitor side using the remote-call Chat API. The Chat API has methods for sending and getting text, starting, pausing and quitting a chat, checking the availability and so forth.

The Chat API is however defined as a pure server side API therefore it requires a comparably large effort on the client side – the visitor’s browser – to learn something trivial like if an operator is available for the chat: That is preparing the call parameters, performing a CORS capable AJAX request and parsing the JSON encoded response.

To alleviate the pain to obtain such frequently needed information on the client’s browser we decided to wrap it together with other publicly available functionality in the JavaScript Visitor API for Chat:

  • Availability of a support department
  • Triggering a chat
  • On-Demand user tracking
  • Observing the progress of a running chat

The VisitorAPI provides a greater flexibility in integrating yalst into your web pages. E.g. you

  • have full control over the chat launch buttons,
  • can defer the user tracking for „not important“ visitors, 
  • can change the layout and contents of the page dynamically depending on the state of the live support and progress of a support chat, and
  • can track the progress (opened, started, joined by operator, finished) of a support chat incident.


To find out if a chat is available

		case LiveSupport.VisitorAPI.Availability.AVAILABLE:{
			// department "C" has operators available for a chat
		case LiveSupport.VisitorAPI.Availability.BUSY:{
			// all operators of department "C" are currently busy
}, "C");

To start a chat with the click on a button


To disable the chat button as soon as the chat begins

	if (observer instanceof Error){
		observer.onChatEvent = function(evtOrError){
			if (evtOrError =={
				startButton.setAttribute("disabled", "disabled");

The VisitorAPI can be used in conjunction with the regular yalst integration code or on its own.

The documentation of the current version can be found here.

The VisitorAPI replaces previously available but unrelated query interfaces like online.js.php and makes them accessible in the Javascript execution context of the visitor’s browser bundled under the unique namespace LiveSupport.VisitorAPI.

Browser Compatibility

FeatureChromeFirefoxInternet ExplorerOperaSafari
Basic support20122012Version 8
Version 7 limited