SupportKit adds beautifully simple messaging to your app to keep your users engaged and coming back.
Add the following code towards the end of the body
section on your page. Placing it at the end allows the rest of the page to load first.
<script src="https://cdn.supportkit.io/supportkit.min.js"></script>
Initialize the plugin using this code snippet
<script>
SupportKit.init({appToken: 'your_app_token'});
</script>
Install from npm
npm install supportkit
Require and init
var SupportKit = require('supportkit');
SupportKit.init({appToken: 'your_app_token'});
Install from bower
bower install supportkit
Include in JS using preferred method and init
SupportKit.init({appToken: 'your_app_token'});
Initializes the SupportKit widget in the web page using the specified options. It returns a promise that will resolve when the widget is ready.
var skPromise = SupportKit.init({
appToken: 'your_app_token',
givenName: 'Cool',
surname: 'Person',
email: '[email protected]',
// For secure mode
jwt: 'your_jwt',
userId: 'user_id',
// Additional properties
properties: {
'anything': 'whatever_you_want'
}
});
skPromise.then(function() {
// do something
});
// pass it around...
skPromise.then(function() {
//do something else
});
Opens the conversation widget
SupportKit.open();
Closes the conversation widget
SupportKit.close();
Logs a user in the widget, retrieving the conversation that user already had on other browsers and/or devices. This will destroy and reinitialize the widget with the user's data. Note that you don't need to call this after init
, it's already done internally. This returns a promise that resolves when the widget is ready again.
SupportKit.login('some-id');
// in case you are using the jwt authentication
SupportKit.login('some-id', 'some-jwt');
Logs out the current user and reinitialize the widget with an anonymous user.This returns a promise that resolves when the widget is ready again.
SupportKit.logout();
Destroys the widget and makes it disappear. The widget has to be reinitialized with init
to be working again because it also clears up the app token from the widget.
SupportKit.destroy();
Sends a message on the user's behalf
SupportKit.message('hello');
Updates user information
SupportKit.updateUser({
givenName: 'Updated',
surname: 'Name',
email: '[email protected]',
properties: {
'justGotUpdated': true
}
});
Tracks an event for the current user.
SupportKit.track('item-in-cart');
If you want to make sure your events are triggered, try to bind them before calling SupportKit.init
.
// This event triggers when init completes successfully... Be sure to bind before calling init!
SupportKit.on('ready', function(){
console.log('the init has completed!');
});
SupportKit.init(...);
// This event triggers when init completes successfully... Be sure to bind before calling init!
SupportKit.on('destroy', function(){
console.log('the widget is destroyed!');
});
SupportKit.destroy();
git clone https://github.com/supportkit/supportkit-js
npm install
npm install -g grunt
grunt build
dumps a plain and a minified file from all files in the foldersrc
to dist/supportkit.min.jsgrunt clean
removes all files in the folderdist
grunt test:unit
runs karma tests