JavaScript API Overview
By using our JavaScript API you can adapt our core library for you needs in your application. For example you can build your own UI snippet to start our join the session if you need it.
The Chatvisor library adds an global CV object to the window object. This object contains the public API which is described in the several sections in this documentation.
window['CV']
JavaScript File
You can configure your Chatvisor tenant with plugins (i.e. WebChat, LiveView...). To be able to use these plugins, it is necessary to include a JavaScript file into your webpage where you want to use it. For that, Chatvisor generates one JavaScript file depending on your plugins what you have selected.
https://cdn.chatvisor.com/cdn/js/<ID>.js
You get only one file which is automatically generated regarding your plugin configuration. It doesn't matter how many plugins you have activated, the JavaScript is automatically compiled and deployed to our CDN.
Implementation
Initialization
If the JavaScript file is loaded async or deferred it is necessary to wait until the script is initialized. To realize this, it is possible to register a window['CVLOADED']
on the window object.
function initFunction() {
// your code
}
if (!window.CVLoaded) {
window.CVLoaded = initFunction;
} else {
initFunction();
}
CDN
We leverage the CDN of AWS (https://aws.amazon.com/de/cloudfront/). The JavaScript file is automatically distributed over several datacenters around the world which guarantees you an optimal performance for the JavaScript all over the world.
Regeneration time
If you update the plugin configuration the JavaScript file is automatically regenerated and uploaded to the CDN. This can take up to ~1min. In general your browser caches the JavaScript file for a maximum of two hours. So if your want to test it immediately, please reload your page with an empty cache (i.e. reload with ctrl + f5).