Module: api

Ajax api managing the chat on the yalst server
Created on 22.09.2014 for the yalst-trunk project.
Version:
  • 1.0
Source:

Members

(static) enterStartForm :function|*

Reports the visitor entering the welcoming form page
Type:
  • function | *
Source:

(static) isConfiguredPromise :Promise

A promise which if resolved indicates that the api is ready to use by third-party custom JavaScript
Type:
Source:

(static) leaveStartForm :function|*

Reports the visitor leaving the welcoming form page
Type:
  • function | *
Source:

(static) leaveStartFormBlocking :function|*

Reports the visitor leaving the welcoming form page.
This call is a blocking (SJAX) network request!
Type:
  • function | *
Source:

Methods

(static) apiAjaxPromise(getParametersnon-null, postParametersopt, queryFragmentopt) → {Promise}

basic method to perform the ajax request to the Chat Api
Parameters:
Name Type Attributes Description
getParameters Object
postParameters Object <optional>
queryFragment string <optional>
key value pairs in HTML-form encoded format
Source:
Returns:
Type
Promise

(static) configure(options)

Set up the live support server. This method is called before any other methods by the web application and will resolve the module:api.isConfiguredPromise.
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
siteNumber string The yalst site number (live support access number)
apiUrl string The full url of the remote chat api of yalst live support server. E.g. "https://your-server.de/yalst/chat.api.php"
visitorId string <optional>
The tracking id for the visitor
deviceInfo string <optional>
Identifies the device. Possible values: 'phone', 'tablet' or desktop
Source:

(static) enter(pageId) → {Promise}

Reports the visitor entering a particular page or view
Parameters:
Name Type Description
pageId string
Source:
Returns:
Type
Promise

(static) hello() → {Promise}

Query the availability of the live support service
Source:
Returns:
Type
Promise
Example
// loading the module
require(['api'], function(serverApi)
{
	serverApi.isConfiguredPromise.then(function()
	{
		serverApi.hello().then(function(data)
		{
			switch (data.chat)
			{
				case "online":
					console.log("Chat available");
					break;
				case "busy":
					console.log("Agents are busy");
					break;
				case "offline":
					console.log("Try again later");
					break;
			}
		},
		function(error)
		{
			console.error(error.message);
		});
	});
});

(static) leave(pageId) → {Promise}

Reports the visitor leaving a particular page or view
Parameters:
Name Type Description
pageId string
Source:
Returns:
Type
Promise

(static) leaveBlocking(pageId) → {undefined}

Reports the visitor leaving a particular page or view.

This is done by a SJAX (blocking) network request. Therefore it is safe to call this method e.g. on pagehide
Parameters:
Name Type Description
pageId string
Source:
Returns:
Type
undefined

(static) start(options) → {Promise}

Request a chat with optionally with a department at the configured live support service
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
department string <optional>
The service department id.
name string The chat name of the visitor.
email string <optional>
The visitor's email if given.
query string <optional>
The visitor's concern if given.
"custom[0]" string <optional>
The value of the custom[0] field in the welcoming form
Source:
Returns:
Type
Promise

(static) startForm(departmentopt) → {Promise}

Retrieve the welcoming form for a particular department or the live support service in general
Parameters:
Name Type Attributes Description
department string <optional>
Source:
Returns:
Type
Promise

Type Definitions

Api

Ajax api managing the chat on the yalst server
Type:
  • Object
Properties:
Name Type Description
configure api.configure Set up the live support server.
apiAjaxPromise api.apiAjaxPromise basic method to perform the ajax request to the Chat Api
hello api.hello Query the availability of the live support service
Source: