Skip to main content
ServiceNow

Integrate ServiceNow with Torq: Trigger workflows using ServiceNow incidents and manage them within Torq steps.

Updated over a week ago

The ServiceNow integration enables you to trigger Torq workflows with ServiceNow incidents and to interact with the incidents as workflow steps.

Trigger Torq Workflows with ServiceNow Incidents

To send ServiceNow notifications to Torq, you must create a Webhook integration in Torq, which generates a unique Torq endpoint. You'll use that endpoint to create a business rule in ServiceNow, which will define which notifications will be sent to Torq.

Create a ServiceNow Webhook Integration

Perform these steps in Torq.

  1. Initiate Webhook SetUp: In Torq, go to Integrations > Triggers > ServiceNow.

  2. Click Add.

  3. Type a meaningful name for the integration instance, such as Service-Now-Webhook, and click Add.

  4. Copy the webhook URL.

Create a Business Rule in ServiceNow

  1. Go to System Definition > Business Rules and click New.

    Screenshot of creating a new business rule in ServiceNow.
  2. Create a business rule named 'Torq-Notifications' with the relevant information.

    1. General Section:

      1. Name: Torq-Notifications

      2. Table: Incident

      3. Advanced checkbox: select the checkbox

    2. When to run:

      1. When: after

      2. Select: insert/update/delete (depending on the events you want to send to Torq)

    3. Advanced:

      1. Enter the sample code below or your organization's code to send to a webhook.

      2. Replace WEBHOOK_URL with the webhook URL you created in Torq (the Torq endpoint)

(function executeRule(current, previous /*null when async*/) {
try {
var r = new sn_ws.RESTMessageV2();
r.setEndpoint("WEBHOOK_URL");
r.setRequestHeader("MY HEADER NAME HERE","MY SECRET HERE");
r.setHttpMethod("post");
// Get user and email
var usr = new GlideRecord('sys_user');
usr.get('sys_id', current.getValue("caller_id"));
var reported_by_email = usr.getValue('email');
// Prep Values to Json
var number = current.getValue("number");
var opened_at = current.getValue("opened_at");
var impact = current.getValue("impact");
var urgency = current.getValue("urgency");
var short_description = current.getValue("short_description"); var description = current.getValue("description"); var category = current.getValue("category");
var priority = current.getValue("priority");
var sys_id = current.getValue("sys_id");
var subcategory = current.getValue("subcategory"); var state = current.getValue("state");
var obj = {
"number": number,
"reported_by_email": reported_by_email,
"opened_at": opened_at,
"impact": impact,
"urgency": urgency,
"short_description": short_description,
"description": description,
"category": category,
"priority": priority,
"sys_id": sys_id,
"subcategory": subcategory,
"state": state
};
var body = JSON.stringify(obj);
gs.info("Webhook body: " + body);
r.setRequestBody(body);
var response = r.execute();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
gs.error("Error message: " + message);
}
gs.info("Webhook target HTTP status response: " + httpStatus);
})(current, previous);

Use ServiceNow Steps in a Torq Workflow

As part of your Torq workflows, you can use ServiceNow steps to create, update, or read ticket/incident details.

You'll create a user in ServiceNow with the necessary permissions to perform these actions from within Torq. Then create a ServiceNow steps integration in Torq with the username, password, and ServiceNow instance where the user was created.

Permissions:

  • Create an Incident

  • Update an Incident

  • Resolve an Incident

Create a User in ServiceNow

  1. Go to System Security > Users and Groups > Users and click New.

    Screenshot showing how to create a new user in ServiceNow.
  2. Enter the user details and click Submit.

    1. User ID

    2. Password

    3. Select Web service access only.

      Screenshot showing how to set details for a new user in ServiceNow.
  3. Edit the new user's properties.

  4. Search for the new user in the list and click the name to edit its properties.

  5. Click Roles > Edit.

  6. Select the required role(s) and click Save. (Create an Incident, Update an Incident, Resolve an Incident).

  7. Click Update.

  8. Copy the following user details, which you'll need when you create the ServiceNow integration in Torq.

    1. Username

    2. Password

    3. ServiceNow instance name

Create a ServiceNow Steps Integration in Torq

Go to the appropriate workspace within Torq.

  1. Go to Build > Integrations > Steps > ServiceNow and click Add.

  2. Fill in the integration fields.

    1. Type a meaningful name for the integration instance, such as Service-Now-Torq.

    2. ServiceNow Password: the password you created for the new user in ServiceNow.

    3. ServiceNow Username: the username you created for the new user in ServiceNow.

    4. ServiceNow Instance: the server hostname of the ServiceNow instance where you created the new user. For example, in the following instance, the hostname is dev12345: https://dev12345.service-now.com/.

  3. Click Add.

Premade Steps

  • Add work note

  • Add public comment

  • Assign a user to an incident

  • Attach a file to an incident

  • Create an incident

  • Create an incident with custom fields

  • Delete an incident

  • Get attachment data

  • Get attachment file

  • Get comments and work notes

  • Get incident details

  • Resolve an incident

  • Search incidents

  • Search users

  • Update an incident

  • Update an incident with custom fields

Did this answer your question?