Skip to main content

ServiceNow

Integrate ServiceNow with Torq to use ServiceNow steps in your workflows.

Updated over 2 weeks ago

ServiceNow is a cloud-based platform designed for IT service management.

Torq enables quick and easy integration with ServiceNow so that you can automate anything and everything within moments. Torq's public ServiceNow steps include:

  • Attach File to Incident

  • Create Incident

  • Assign Group to Incident

  • Get incident details

  • +13 more...

If you don't see a step you need, you can create your own in various ways, such as using the Send an HTTP Request step or Torq’s Step Builder, and share it across your organization.

To trigger a Torq workflow based on events sent from ServiceNow, look here.

To use ServiceNow steps in Torq workflows, look here.

Use ServiceNow to Trigger Workflows in Torq

Step One: Create a ServiceNow Trigger Integration in Torq

  1. Navigate to Integration: Go to Build > Integrations > Triggers > ServiceNow and click Add.

  2. Fill in the Details:

    1. Give the integration a unique and meaningful name.

    2. Under Authentication Headers, click Add.

      1. Give the secret a name.

      2. Click Generate Random Secret.

  3. Finalize: Click Add.

Step Two: Create a Business Rule in ServiceNow

  1. Navigate to Business Rules: Go to All > System Definition > Business Rules and in the top right of the page, click New.

  2. Create a Business rule: Fill in the relevant details for your rule:

    1. General Section:

      1. Give your rule a logical name

      2. In the Table dropdown, select Incident [incident]

      3. Select the Advanced checkbox

    2. When to run tab:

      1. In the When dropdown, select after

      2. In the list of checkboxes on the right, select the relevant options for the events you want to send to Torq (insert/update/delete)

    3. Advanced tab:

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

      2. Replace WEBHOOK_URL with the webhook URL you created in Torq in step one.

  3. Finalize: Click Submit

(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);

Now that you've successfully created a ServiceNow trigger, you can build your first ServiceNow-initiated workflow!

In Torq, go to Build > Workflows > Create a Workflow > New Blank Workflow, and select the trigger type: Integrations > ServiceNow. Find your new trigger, and automate away!

Use ServiceNow Steps in Torq

Step One: Create a Dedicated User in ServiceNow

It is best practice to add a new user to your ServiceNow account to create a dedicated user for the integration.

  1. Navigate to User Groups: Go to System Security > Users and Groups > Users and in the top right of the page, click New.

  2. Define New User:

    1. Enter the user details:

      1. User ID

      2. Select Web service access only.

      3. Password needs reset must be unselected.

  3. Finalize: Click Submit.

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

    1. Click Set Password and generate a user password. Click Save and then Copy to use it in Torq later.

    2. Click Roles > Edit.

    3. Select the itil role and add it to the Roles List, by clicking the right-pointing arrow.

    4. Click Save.

    5. Click Update to save the edits.

Step Two: Create a ServiceNow Steps Integration in Torq

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

  2. Fill in the Details: Give the integration a unique and meaningful name.

    1. ServiceNow Instance: Enter your ServiceNow instance.

    2. ServiceNow Username: Enter the ServiceNow User ID that you created in step one (2a.).

    3. ServiceNow Password: enter the ServiceNow password that you generated in step one (4a.).

  3. Test: Click Test Integration to verify the integration is configured correctly.

  4. Finalize: Click Add.

Create a ServiceNow Integration Using OAuth 2.0

Step One: Create a ServiceNow Application

  1. Navigate to Application Registry: In ServiceNow, go to System OAuth > Application Registry.

  2. Create a New Application: Select Create an OAuth API endpoint for external clients.

  3. Configure the Application: Fill in the details for the following fields:

    1. Give the application a unique and meaningful name

    2. Unlock the Redirect URL field and enter the callback URL from Torq: https://redir.torq.io/integrations/oauth_2

      Lock the Redirect URL field.

    3. Check the Active box.

    4. Finalize: Click Submit.

  4. Generate Application Secret: Search for the new application in the list and click the name to access the generated client secret.

    1. Unlock the Client Secret field to view and copy the client secret.

    2. Save the automatically generated ClientID and Client Secret to use in Torq.

  5. Finalize: Click Update.

Step Two: Create an OAuth Integration in Torq

  1. Navigate to Integration: Go to Build > Integrations > OAuth 2.0 and click Add.

  2. Fill in the Details: Give the integration a unique and meaningful name.

    1. Grant Type: select Authorization code in the dropdown menu.

    2. Callback URL: copy the redirect link to insert in step one above (3b.).

    3. Auth URL: enter https://<INSTANCE>.service-now.com/oauth_auth.do, where <INSTANCE> is replaced with your specific ServiceNow instance.

    4. Token URL: enter https://<INSTANCE>.service-now.com/oauth_token.do, where <INSTANCE> is replaced with your specific ServiceNow instance.

    5. Client ID: enter the ClientID generated in step one (4.).

    6. Client Secret: enter the Client Secret generated in step one (4.).

    7. If you have any Scopes defined in the ServiceNow application, list them in a comma-separated list.

  3. Click Test Integration to verify the integration is configured correctly.

  4. Finalize: Click Continue.

  5. Log in to ServiceNow: You will be redirected to log in to your ServiceNow account.

  6. Connect account: To connect your Torq integration with your ServiceNow account, click Allow.

  7. Redirect to Torq: Your integration will appear in the list of OAuth 2.0 integrations.

Templates

Now that you've added your integrations check out these specially crafted templates by Torq's security experts. Visit Torq's template library for more.

Did this answer your question?