JavaScript API - General API
Action rule matched
Get an array of matched ActionRules.
This array will only include rules which contain a 'Javascript Event' condition and have matched.
The name shown can be specified in the 'Javascript Event' condition itself.
An implementation example can be found here.
CV.api.hasActionRuleMatched(function(result) {
// result is an array of matched action rules
console.log(result);
});
Agents online
Checks whether agents are online and available
CV.api.isAgentOnline(function(result) {
// result is either true or false
});
WebChat should be shown
Checks whether the WebChat should be visible according to rules
Once
This method checks once if the chat should be visible and calls the callback function if true
CV.api.shouldShowWebchat(function(){
// Chat should be visible
}, function() {
// Chat should not be visible or an error happened while checking
});
Continously
This method checks if the chat should be visible continously and calls the callback function once a rule evaluates to true
CV.api.shouldShowWebchatInterval(function(){
// Chat should be visible
}, function() {
// Chat should not be visible or an error happened while checking
});
Authentication
In order to authenticate against the Chatvisor API for certain requests (e.g. list of active users) it is required to set a user token before the request.
CV.rest.auth("my-user-token", true)
Property | Type | Description |
---|---|---|
token | string | Token generated for this user in the settings |
persist | boolean | Authentication is saved in the localStorage object instead of sessionStorage (optional; default: false) |