If you would like to add ServiceNow ITSM in order to collect incidents in Axify, here is a guideline on how to do it. Adding ServiceNow as an incident provider will unlock incidents for DORA metrics.
Guideline:
- First, go to Axify.
- Go to a project's settings.
- Select the Integration tabs, and scroll down to incidents
- Click on Add Integration and select Other providers
- You can specify a name (i.e. ServiceNow critical incidents), then click on Generate a webhook. It will provide you an URL and a secret token that you will need in ServiceNow.
- Go to Service Now studio in your instance (i.e. https://my-instance.service-now.com/now/servicenow-studio)
- Create a REST message.
- Give it a name (i.e. Axify critical incidents for project X)
- As for the endpoint, enter the URL provided from Axify in the previous step
- Within the message, create an HTTP method with "POST" as the HTTP method and no endpoint (see above screenshot).
- Create an asynchronous business rule triggered when an incident is inserted. This rule will be responsible for sending new incidents to Axify.
- In the Advanced section, you'll need to insert this script.
- IMPORTANT NOTE: at ligne 21, replace the string with the token Axify provided in the previous step!
-
(function executeRule(current, previous) {
gs.info("Sending incident to Axify");
var createdOn = current.getValue('sys_created_on');
var glideCreatedOn = new GlideDateTime(createdOn);
var dateCreatedOn = new Date(glideCreatedOn.getNumericValue());
var isoCreatedOn = dateCreatedOn.toISOString();
var body = JSON.stringify({
"status": "TRIGGERED",
"occurred_at": isoCreatedOn,
"title": current.getValue("short_description"),
"description": current.getValue("description"),
"id": current.getValue("sys_id")
});
// Calculate the HMAC-SHA256 code of the request body, which will be used to authenticate the request
var mac = new CertificateEncryption();
var key = gs.base64Encode("<INSERT WEBHOOK SECRET TOKEN>");
var signature = mac.generateMac(key, "HmacSHA256", body);
var message = new sn_ws.RESTMessageV2("Axify incidents", "Post incident");
message.setRequestHeader("X-Axify-Deployment-Event-Signature", "sha256+base64=" + signature);
message.setRequestBody(body);
var response = message.execute();
gs.info("Sent incident to Axify.");
})(current, previous); - Now you will receive incidents when they are created. We will need to receive an event when they are updated or resolved.
- Create a second asynchronous business rule triggered when an incident is modified. This rule will be responsible for sending resolved incidents to Axify.
- In the Advanced section, you'll need to insert this script.
- IMPORTANT NOTE: at ligne 24, replace the string with the token Axify provided in the previous step!
-
(function executeRule(current, previous) {
gs.info("Sending incident to Axify");
if (current.getValue("state") != 6) {
// Incident is not resolved, will not send to Axify
return;
}
// Calculate the HMAC-SHA256 code of the request body, which will be used to authenticate the request
var mac = new CertificateEncryption();
var key = gs.base64Encode("<INSERT WEBHOOK SECRET TOKEN>");
var signature = mac.generateMac(key, "HmacSHA256", body);
var message = new sn_ws.RESTMessageV2("Axify incidents", "Post incident");
message.setRequestHeader("X-Axify-Deployment-Event-Signature", "sha256+base64=" + signature);
message.setRequestBody(body);
var response = message.execute();
gs.info("Sent incident to Axify.");
})(current, previous);
- Save your script and it should be done!