Webhook Integration : ServiceNow Tickets
24min
The Nile Service Block (NSB) integrates with ServiceNow, via Webhook, to provide Nile users the ability to create helpdesk tickets from my.nilesecure.com page, destined to their Nile Portal Administrator.
- ServiceNow cloud instance with access from Nile cloud
- Administrator rights to the Nile Portal.
- Log into ServiceNow. You can create a new account if you don’t have one yet.
- ServiceNow provides the capability to create a developer instance, for free, that is useful for NSB integrations testing. This document describes how to create such a developer instance for this purpose. The steps will be the same in the production ServiceNow instance.
- To create a developer instance, go to
- To create a developer instance, click on
Click Request an Instance.
- After building the developer instance, you will be provided with the
Important Note: If you do not access the developer instance for a few days, the instance state will be changed to hibernate. After some time, it will be deleted.
- Switch to the admin role by clicking on the account at the top right to view the instance actions, and select ‘Change User Role’
- Log in to the new instance using your admin account
- ServiceNow provides default fields for
- From “
- The list of tables (model) in the ServiceNow is shown below:
- Search for Tables “
Add to the Label field the string “Incident”. Add to the Name field the string “incident”. Click the Columns button. Click the New button .
- In the
- Click “
- Repeat the above action to create the “
- The next step is to create a “Scripted Rest APIs”, which handles the Webhooks requests from Nile.
- In the ServiceNow navigation bar, type “Scripted Rest APIs” and click the link. It shows a list of existing REST APIs
- Click
- Search the created RESP API and click it. Under “Resources” tab, click ‘
- In the “Script” section, copy and paste this script:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var incident = request.body.data;
var inc = new GlideRecord('incident');
inc.initialize();
inc.u_external_id = incident.request_id;
inc.short_description = incident.title;
inc.u_user_email = incident.email;
inc.u_external_id = incident.id;
inc.u_user_name = incident.name;
var description = incident.description;
// append details to the description
description = description.concat("\n\n", "SSID: ", incident.ssid);
description = description.concat("\n", "MAC: ", incident.mac);
description = description.concat("\n", "IP: ", incident.ip_address);
description = description.concat("\n", "Device Type: ", incident.device_type);
description = description.concat("\n", "Segment: ", incident.segment);
description = description.concat("\n", "Location: ", incident.location);
description = description.concat("\n", "Incident Reported Time: ", incident.time);
inc.description = description;
var sys_id = inc.insert();
gs.print("Newly created incident sys id is " +sys_id);
// Now save the attachments
var StringUtil = new GlideStringUtil();
for(var i = 0; i < incident.attachments.length; i++) {
var sa = new GlideSysAttachment();
sa.write(inc, incident.attachments[i].attachment_name, incident.attachments[i].content_type, StringUtil.base64DecodeAsBytes(incident.attachments[i].data));
}
var queried_inc = new GlideRecord('incident');
queried_inc.addQuery('sys_id', '=', sys_id);
queried_inc.query();
var res = {};
if (queried_inc.next()) {
res['incident_id'] = queried_inc.number;
} else {
res["incident_id"] = sys_id;
}
response.setStatus(200);
response.setContentType('application/json');
response.setBody(res);
- Under the Security tab, make sure that “
- Once submitted, the resource name “
- This completes the ServiceNow setup.
- To set up the Webhook in the Nile Portal, the REST API authorization token is required.
- Postman would be used to collect the token as follows:
- Launch Postman
- Enter the REST API URL as a POST
- Select the ‘Authorization’ tab.
- Select
- Enter the admin credentials as
- Click theHeaders
- Into the Authorization field, enter the value. In this example, “Basic YWRtaW46Q3ctWC96ZzI0dkpX”
- Log into Nile Portal using an admin account.
- Click on (Settings icon) on the left side.
- Click onGlobal Settings
- Click on Integration tab (second row)
- Click on the“
- Fill out the ServiceNow Webhooks info:
- Name
- URL
- Token: Basic Authentication token generated by Postman.in our example: “Basic YWRtaW46Q3ctWC96ZzI0dkpX”
- Click on
- The Nile Portal has the option to send user generated incidents from the nilesecure.com page to the Nile Portal admin via Webhooks to ServiceNow.
- Login to the Nile Portal using an admin account
- Click on (Settings icon) on the left side.
- Click onGlobal Settings
- Click on
- Select the Webhooks URL created earlier “MM Nile Incidents” from the dropdown list as the option to the “My Nile Incidents” feature.
- As a user connected to the Nile service, launch a browser and connect to
- Click on the “Need more help?” link in the top right of the browser screen to launch the “Report incident” window.
- Fill in the incident details to report to your Nile Admin. Attach a screenshot or another file as needed. Click the ‘SUBMIT” button to submit the incident.
- Login to ServiceNow instance as an admin.
- Display the ServiceNow Incidents underAll
- Filter on
- Click on
The Incidents table is then displayed. Verify your incident is shown here.
Updated 24 May 2024
Did this page help you?