ServiceNow Integration | Jeli
Jeli Part of PagerDuty
Integrate Jeli and ServiceNow using the power of Jeli's webhooks and public API. With this integration you can:
- Automatically create a ticket in ServiceNow when an incident is opened in Jeli.
- Automatically update your ServiceNow ticket as the incident progresses.
- Trigger the creation of a Jeli incident from ServiceNow, moving from queue to coordination quickly and easily.
Create a ServiceNow Ticket From a Jeli Incident
In ServiceNow
ServiceNow Version
The following instructions are based on ServiceNow Vancouver. Configuration in your specific ServiceNow version and instance may vary.
Configuration Note
The
create_incident_in_servicenow
script has ajeliApiKey
variable that needs to be configured. See our API docs for instructions on generating an API key, then update this script to include that value.
-
First, you will add a new Jeli Incident ID field to your Incident object in ServiceNow. Navigate to System Definition Tables search for and select Incident.
-
Click New to add a new field to the Incident table:
- Type: Integer
- Column label: Jeli Incident ID
- Column name: u_jeli_incident_id
-
Navigate to System Web Services Scripted REST APIs and click New.
-
Create a new Scripted REST Service by providing a Name and API ID. You could name this service, "Jeli Incoming Webhooks", for example. Click Submit to save.
-
From your new Scripted REST Service, under the Resources tab, click New.
-
From your new Scripted REST Resource, enter the following information:
- Name: Open Incident
- HTTP Method: POST
- Relative path: /open
- Security tab: Uncheck
Requires authentication
- Script:
Configuration Note
The
create_incident_in_servicenow
script has ajeliApiKey
variable that needs to be configured. See our API docs for instructions on generating an API key, then update this script to include that value.
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var jeliApiKey = '<YOUR JELI API KEY>'; // https://docs.jeli.io/en/articles/8295161-the-jeli-api
var requestData = request.body.data;
var jeliIncidentId = requestData.incidentId;
var responseMessage = '';
// Optionally make an API call to get additional incident details
jeliApiRequest = new sn_ws.RESTMessageV2();
jeliApiRequest.setEndpoint('https://api.jeli.io/v0/incident/' + jeliIncidentId);
jeliApiRequest.setHttpMethod('GET');
jeliApiRequest.setRequestHeader('Accept','application/json');
jeliApiRequest.setRequestHeader('Content-Type','application/json');
jeliApiRequest.setRequestHeader('Authorization', 'Bearer ' + jeliApiKey);
jeliApiResponse = jeliApiRequest.execute();
var jeliApiResponseJSON = new global.JSON().decode(jeliApiResponse.getBody());
var slackChannel = 'https://app.jeli.io/api/slack?channel=' + jeliApiResponseJSON.channel.id + '&team=' + jeliApiResponseJSON.slack_team_id;
// Look for an existing ticket in ServiceNow
var existingIncident = new GlideRecord('incident');
existingIncident.addQuery('u_jeli_incident_id', jeliIncidentId);
existingIncident.query();
// Update existing ticket
if(existingIncident.next()) {
existingIncident.description = 'Jeli Incident: ' + jeliIncidentId + '\n' + 'Slack Channel: ' + slackChannel;
existingIncident.u_jeli_incident_id = jeliIncidentId;
responseMessage = 'Ticket number ' + existingIncident.number + ' has been updated.';
}
else {
// Create new ticket
var newIncident = new GlideRecord('incident');
newIncident.initialize();
newIncident.short_description = requestData.name;
newIncident.description = 'Jeli Incident: ' + jeliIncidentId + '\n' + 'Slack Channel: ' + slackChannel;
newIncident.u_jeli_incident_id = jeliIncidentId;
newIncident.insert();
responseMessage = 'Ticket number ' + newIncident.number + ' has been created.';
}
response.setStatus(200);
var response_body = {
'response': responseMessage,
};
var writer = response.getStreamWriter();
writer.writeString(JSON.stringify(response_body));response.setContentType('application/json');
})(request, response);
-
Click Update to save.
-
Navigate back to your newly created Scripted REST Service and note the Resource path for your Open Incident resource.
In Jeli
- In the Jeli web app, navigate to Settings Webhooks and select Add webhook.
- Create a new webhook with the following settings:
- Webhook URL:
https://<url of your servicenow instance>/<resource path from Step 8 above>
- For example, your webhook URL will look something like:
https://dev00000.service-now.com/api/1124078/jeli_incoming_webhooks/open
- For example, your webhook URL will look something like:
- Enabled Upon Creation: Enabled
- Event Type Filtering: Select
incident.created
- Webhook URL:
You can now test the webhook by creating an incident in Jeli. You shoud see a new ServiceNow incident ticket has been created.
Create a Jeli Incident from a ServiceNow ticket
In ServiceNow
- Navigate to System UI UI Actions and select New.
- Configure the UI Action:
- Name: Coordinate with Jeli
- Table: Incident
- Action name: Coordinate_With_Jeli
- Show insert: Disable
- Show update: Enable
- Client: Enable
- Form button: Enable
- Onclick: OpenJeliIncident()
- Script:
Configuration Note
The
open_jeli_incident_from_servicenow
script has ajeliApiKey
variable that needs to be configured. See our API docs for instructions on generating an API key, then update this script to include that value.
function OpenJeliIncident(){
gsftSubmit(null, g_form.getFormElement(), 'Coordinate_With_Jeli');//MUST call the 'Action name' set in this UI Action
}
if(typeof window == 'undefined')
callJeliAPI();
//Server-side function
function callJeliAPI(){
var jeliApiKey = '<YOUR JELI API KEY>'; // https://docs.jeli.io/en/articles/8295161-the-jeli-api
// Hard coding values for this for demonstration purposes
// you may use current.* to pull these values from the ServiceNow incident object
var email_of_incident_opener = '[email protected]';
var broadcast_channel = 'C032EFJTQ10';
var severity = '0';
var slack_team_id = 'T01NUHLDWC9';
var incident_stage = 'Investigating';
var requestBody = {};
requestBody.incident_name = current.short_description.toString();
requestBody.incident_stage = incident_stage;
requestBody.start_zoom = true;
requestBody.start_google_meet = false;
requestBody.email_of_incident_opener = email_of_incident_opener;
requestBody.broadcast_channels = [];
requestBody.broadcast_channels.push(broadcast_channel);
requestBody.severity_slack_command = severity;
requestBody.summary = 'TBD';
requestBody.slack_team_id = slack_team_id;
requestBody = new global.JSON().encode(requestBody);
incApiRequest = new sn_ws.RESTMessageV2();
incApiRequest.setEndpoint('https://api.jeli.io/v0/incident/');
incApiRequest.setHttpMethod('POST');
incApiRequest.setRequestHeader('Accept','application/json');
incApiRequest.setRequestHeader('Content-Type','application/json');
incApiRequest.setRequestHeader('Authorization', 'Bearer ' + jeliApiKey);
incApiRequest.setRequestBody(requestBody);
incApiResponse = incApiRequest.execute();
var responseJSON = new global.JSON().decode(incApiResponse.getBody());
current.u_jeli_incident_id = responseJSON.open_incident.vanity_id;
current.update();
action.setRedirectURL(current);
}
- Click Update to save.
- You will now see a Coordinate with Jeli button on your incident form. Clicking this will create an incident in Jeli and Slack, and update the ServiceNow record to include the Jeli incident ID.
Updated about 12 hours ago