...
Go to System Definition > Script Includes
(available at https://YOURTENANT.service-now.com/nav_to.do?uri=%2Fsys_script_include_list.do ).Click the [New] button.
Provide
Name: Readibot
Application: Global
Accessible from: All application scopes
Active: checked
Paste the following class definition Glide script into the Script editor
Code Block language js var Readibot = Class.create(); Readibot.prototype = { enableLogging: true, baseBotUrl: 'https://cloudbridge.ucclearly.com/storageapi/api/ExecuteScript/', callMethod: 'POST', dataFormat: 'application/json', initialize: function() { //empty initializer }, deploy: function deploy(botId,botToken) { //automatically uses the current sys_id and number var dataObj = { sysid: current.sys_id.toString(), number: current.number.toString() }; this.deployWithObject(botId,botToken,dataObj); }, deployWithRecorddeployWithNumber: function deployWithRecorddeployWithNumber(botId,botToken,recordNumber) { //automatically uses the current sys_id and number var dataObj = { number: recordNumber }; this.deployWithObject(botId,botToken,dataObj); }, deployWithSysId: function deployWithSysId(botId,botToken,sysId) { //automatically uses the current sys_id and number var dataObj = { sysId: sysId.toString() }; this.deployWithObject(botId,botToken,dataObj); }, deployWithObject: function deployWithObject(botId,botToken,dataObject) { //NOTE: the properties of dataObject can onlybe simple types; // complex types will send as empty string //force property values to be strings (work around weaknesses in JSON.stringify() function) var newObject={}; for (prop in dataObject) { newObject[prop] = dataObject[prop].toString(); } this.deployWithJson(botId,botToken,JSON.stringify(newObject)); }, deployWithJson: function deployWithJson(botId,botToken,jsonString) { var request; var responseBody; var responseStatusCode; var response; //this log message string may not always work depending on caller type/context this.log('Readibot '+botId+' deployed for '+current.number+' ['+current.sys_id+']'); try { request = new sn_ws.RESTMessageV2(); request.setEndpoint(this.baseBotUrl+botId); request.setHttpMethod(this.callMethod); request.setRequestHeader('Content-type',this.dataFormat); request.setRequestHeader('rb-ReadibotsToken',botToken); request.setRequestBody(jsonString); response = request.execute(); responseStatusCode = response.getStatusCode(); responseBody = response.haveError() ? response.getErrorMessage() : JSON.parse(response.getBody()); } catch(ex) { responseBody = ex.getMessage(); responseStatusCode = 500; } //this log message string may not always work depending on caller type/context this.log('Readibot for '+current.number+' ['+current.sys_id+'] returned: '+responseBody); }, log: function log(msg) { if (this.enableLogging) { var timestamp = new GlideDateTime().getNumericValue(); gs.log(msg, 'Readibots'); } }, type: 'Readibot' };
Click the [Submit] button to save the Readibot class
...