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 a jeliApiKey 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.

  1. 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.

  2. Click New to add a new field to the Incident table:

    1. Type: Integer
    2. Column label: Jeli Incident ID
    3. Column name: u_jeli_incident_id
  3. Navigate to System Web Services Scripted REST APIs and click New.

  4. 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.

  5. From your new Scripted REST Service, under the Resources tab, click New.

  6. From your new Scripted REST Resource, enter the following information:

    1. Name: Open Incident
    2. ​HTTP Method: POST
    3. Relative path: /open
    4. Security tab: Uncheck Requires authentication
    5. Script:

📘

Configuration Note

The create_incident_in_servicenow script has a jeliApiKey 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);
  1. Click Update to save.

  2. Navigate back to your newly created Scripted REST Service and note the Resource path for your Open Incident resource.

In Jeli

  1. In the Jeli web app, navigate to Settings Webhooks and select Add webhook.
  2. Create a new webhook with the following settings:
    1. Webhook URL: https://<url of your servicenow instance>/<resource path from Step 8 above>
      1. For example, your webhook URL will look something like: https://dev00000.service-now.com/api/1124078/jeli_incoming_webhooks/open
    2. Enabled Upon Creation: Enabled
    3. Event Type Filtering: Select incident.created

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

  1. Navigate to System UI UI Actions and select New.
  2. Configure the UI Action:
    1. Name: Coordinate with Jeli
    2. Table: Incident
    3. ​Action name: Coordinate_With_Jeli
    4. Show insert: Disable
    5. Show update: Enable
    6. Client: Enable
    7. Form button: Enable
    8. Onclick: OpenJeliIncident()
    9. Script:

📘

Configuration Note

The open_jeli_incident_from_servicenow script has a jeliApiKey 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);	
}
  1. Click Update to save.
  2. 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.