The ServiceNow integration enables you to trigger Torq workflows with ServiceNow incidents and interact with them 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.
Initiate Webhook SetUp: In Torq, go to Integrations > Triggers > ServiceNow.
Click Add.
Type a meaningful name for the integration instance, such as Service-Now-Webhook, and click Add.
Copy the webhook URL.
Create a Business Rule in ServiceNow
Go to System Definition > Business Rules and click New.
Create a business rule named 'Torq-Notifications' with the relevant information.
General Section:
Name: Torq-Notifications
Table: Incident
Advanced checkbox: select the checkbox
When to run:
When: after
Select: insert/update/delete (depending on the events you want to send to Torq)
Advanced:
Enter the sample code below or your organization's code to send to a webhook.
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
Go to System Security > Users and Groups > Users and click New.
Enter the user details and click Submit.
Edit the new user's properties.
Search for the new user in the list and click the name to edit its properties.
Click Roles > Edit.
Select the required role(s) and click Save. (Create an Incident, Update an Incident, Resolve an Incident).
Click Update.
Copy the following user details, which you'll need when you create the ServiceNow integration in Torq.
Username
Password
ServiceNow instance name
Create a ServiceNow Steps Integration in Torq
Go to the appropriate workspace within Torq.
Go to Build > Integrations > Steps > ServiceNow and click Add.
Fill in the integration fields.
Type a meaningful name for the integration instance, such as Service-Now-Torq.
ServiceNow Password: the password you created for the new user in ServiceNow.
ServiceNow Username: the username you created for the new user in ServiceNow.
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/.
Click Add.
Create a ServiceNow Integration Using OAuth 2.0
In ServiceNow, navigate to System OAuth > Application Registry.
Create a new application and select Create an OAuth API endpoint for external clients.
Configure the application with the below details. All other fields can be adjusted as needed or are automatically generated.
In Torq, go to Build > Integrations > OAuth 2.0 and click Add.
Give the integration a unique and meaningful name.
Under Service Now Auth URL enter
https://<INSTANCE>.service-now.com/oauth_auth.do
wherein <INSTANCE> is replaced with your specific ServiceNow instance.Under ClientID enter the ClientID generated earlier (step 3.d).
Under Client Secret enter the Client Secret generated earlier (step 3.d)
If you have any Scopes defined in the ServiceNow application, list them in a comma-separated list.
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