When Web SDK widget is created. Usually this happens when you click the
launcher.
You can use this event to send authentication token:
constujet=newUJET({//...//authenticate:getAuthToken})//whenyoudidn't use `authenticate` option, you need to call// `.authenticate` method manuallyujet.on('created,()=>{fetch('/token').then(resp=>{returnresp.json()}).then(data=>{ujet.authenticate({token:data.token})})})
authorized
This event happens when .authenticate method is called and responded
with a token to Web SDK.
ready
Web SDK has fetched company information, it is ready to use now.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eujet.on()\u003c/code\u003e and \u003ccode\u003eujet.off()\u003c/code\u003e are used to manage event listeners for the Web SDK.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecreated\u003c/code\u003e event is triggered when the Web SDK widget is created, and it can be used to send an authentication token.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eauthorized\u003c/code\u003e event occurs after the \u003ccode\u003e.authenticate\u003c/code\u003e method is called and responds with a token.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eready\u003c/code\u003e event indicates that the Web SDK has fetched company information and is fully functional.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eunread\u003c/code\u003e event is emitted to communicate the number of unread chat messages, while the \u003ccode\u003eclose\u003c/code\u003e event signifies that the Web SDK has been closed.\u003c/p\u003e\n"]]],[],null,["# Web SDK API events\n\n ujet.on(eventName, callback)\n\n ujet.off(eventName, callback)\n\ncreated\n-------\n\nWhen Web SDK widget is created. Usually this happens when you click the\nlauncher.\n\nYou can use this event to send authentication token: \n\n const ujet = new UJET({\n // ...\n // authenticate: getAuthToken\n })\n\n // when you didn't use `authenticate` option, you need to call\n // `.authenticate` method manually\n\n ujet.on('created, () =\u003e {\n fetch('/token').then(resp =\u003e {\n return resp.json()\n }).then(data =\u003e {\n ujet.authenticate({ token: data.token })\n })\n })\n\nauthorized\n----------\n\nThis event happens when `.authenticate` method is called and responded\nwith a `token` to Web SDK.\n\nready\n-----\n\nWeb SDK has fetched `company` information, it is **ready** to use now.\n\nunread\n------\n\nEmit `unread` chat message count: \n\n ujet.on('unread', function(num) {\n console.log('has ' + num + ' unread messages')\n })\n\nclose\n-----\n\nWhen Web SDK has been closed. This event happens when you click \"close\"\nbutton in the SDK, or click the launcher to close SDK."]]