/
Examples
Examples
ButtonClickWidget
If you like to engage a chat when clicking a button with id myElement, you have to:
upload a JS document into customDocument section or directly into the filesystem hosting ctlive, with the following content (remember to change the #myElement at line 17) with name buttonClickWidget.js
(function(define) { define(['widget/widget.js'], function(WIDGET) { // Built in implementation used for creation of overridable instance of widget class var CHILD = function(serviceConfig, serverDomain) { WIDGET.call(this, serviceConfig, serverDomain); }; CHILD.prototype = Object.create(WIDGET.prototype); // Override init method CHILD.prototype.init = function() { var self = this; // bind the fire method to the click on the DOM element with id myElement and set the property enableAutostartChat to true window.lichaJQuery("#myElement").on("click", function() { WIDGET.prototype.fire.apply(self, arguments); window.lichaJQuery('#' + self.id).find(".licha_engagement_trigger").click(); }); // call native implementation of init method WIDGET.prototype.init.apply(self, arguments); // stop the checkmedia in order to bypass the engagement box visibility based on agent availability WIDGET.prototype.stopCheckMedia.apply(self, arguments); }; // Override checkAgentAvailability method CHILD.prototype.checkAgentAvailability = function() { var self = this; // call native implementation of hideEngagement method in order to hide engagement box WIDGET.prototype.hideEngagement.apply(self, arguments); // Force internal widget state to AVAILABLE that is mandatory to start a new chat self.state = "AVAILABLE"; }; return CHILD; }); }(__ctliveDefine));
create a new widget clickButton overriding the require filed with the path of the previous js file (e.g. customDocument/buttonClickWidget.js)
create a service using clickButton widget
, multiple selections available,
Related content
CTLive integration through events
CTLive integration through events
More like this
Agent SDK Integration
Agent SDK Integration
More like this
Configuration
Configuration
More like this
How to use the CTLive Agent SDK
How to use the CTLive Agent SDK
More like this