Skip to main content

How to connect ServiceNow to Tines Webhooks

Sending events to Tines webhooks via ServiceNow outbound requests.

Written by Jamie Gaynor
Updated today

Integrating ServiceNow with Tines allows you to automate workflows by sending real-time event data from your ServiceNow instance directly into your Tines stories. This article will guide you through the process of setting up ServiceNow webhooks using outbound requests.

For more information on creating webhooks, read our docs here.

Create a webhook in Tines

Within a Tines story, drag a webhook action onto the canvas. Name and copy the webhook URL for later.

Read this article for best practice on configuring your webhook names and paths.

Create a REST message in ServiceNow

Open your ServiceNow instance <<https://tenant-name.service-now.com/>.>

Open the “All” tab and navigate to “System Web Services” > “Outbound” > “REST Message”

Select “New” to create a new REST Message.

Name the REST message and paste in the Tines webhook URL from earlier. When finished, select “Submit”.

Create a HTTP method

From the list of REST message names, select the one you just created. Scroll to the bottom and navigate to the HTTP methods section. There will be one default method already created called “Default GET”.

Note: Delete this HTTP method

Create a new method for PUSH requests. Select “New”.

Name the new HTTP method something like “Post to Tines Webhook” and set the HTTP method to POST. Set the endpoint to the URL from your Tines webhook and click “Submit”.

On the HTTP Request tab, note the Content of the HTTP Query Parameters section. This is where you can specify the fields that you want to be sent over to the webhook. The following would be used for the incident table in ServiceNow, but you can customize based on your needs. Select “Submit” when finished.

{
"parent": "${current.parent}",
"made_sla": "${current.made_sla}",
"caused_by": "${current.caused_by}",
"watch_list": "${current.watch_list}",
"upon_reject": "${current.upon_reject}",
"sys_updated_on": "${current.sys_updated_on}",
"child_incidents": "${current.child_incidents}",
"hold_reason": "${current.hold_reason}",
"origin_table": "${current.origin_table}",
"task_effective_number": "${current.task_effective_number}",
"approval_history": "${current.approval_history}",
"number": "${current.number}",
"resolved_by": "${current.resolved_by}",
"sys_updated_by": "${current.sys_updated_by}",
"opened_by": "${current.opened_by}",
"user_input": "${current.user_input}",
"sys_created_on": "${current.sys_created_on}",
"sys_domain": "${current.sys_domain}",
"state": "${current.state}",
"route_reason": "${current.route_reason}",
"sys_created_by": "${current.sys_created_by}",
"knowledge": "${current.knowledge}",
"order": "${current.order}",
"calendar_stc": "${current.calendar_stc}",
"closed_at": "${current.closed_at}",
"cmdb_ci": "${current.cmdb_ci}",
"delivery_plan": "${current.delivery_plan}",
"contract": "${current.contract}",
"impact": "${current.impact}",
"active": "${current.active}",
"work_notes_list": "${current.work_notes_list}",
"business_service": "${current.business_service}",
"business_impact": "${current.business_impact}",
"priority": "${current.priority}",
"sys_domain_path": "${current.sys_domain_path}",
"rfc": "${current.rfc}",
"time_worked": "${current.time_worked}",
"expected_start": "${current.expected_start}",
"opened_at": "${current.opened_at}",
"business_duration": "${current.business_duration}",
"group_list": "${current.group_list}",
"work_end": "${current.work_end}",
"caller_id": "${current.caller_id}",
"reopened_time": "${current.reopened_time}",
"resolved_at": "${current.resolved_at}",
"approval_set": "${current.approval_set}",
"subcategory": "${current.subcategory}",
"work_notes": "${current.work_notes}",
"universal_request": "${current.universal_request}",
"short_description": "${current.short_description}",
"close_code": "${current.close_code}",
"correlation_display": "${current.correlation_display}",
"delivery_task": "${current.delivery_task}",
"work_start": "${current.work_start}",
"assignment_group": "${current.assignment_group}",
"additional_assignee_list": "${current.additional_assignee_list}",
"business_stc": "${current.business_stc}",
"cause": "${current.cause}",
"description": "${current.description}",
"origin_id": "${current.origin_id}",
"calendar_duration": "${current.calendar_duration}",
"close_notes": "${current.close_notes}",
"notify": "${current.notify}",
"service_offering": "${current.service_offering}",
"sys_class_name": "${current.sys_class_name}",
"closed_by": "${current.closed_by}",
"follow_up": "${current.follow_up}",
"parent_incident": "${current.parent_incident}",
"sys_id": "${current.sys_id}",
"contact_type": "${current.contact_type}",
"reopened_by": "${current.reopened_by}",
"incident_state": "${current.incident_state}",
"urgency": "${current.urgency}",
"problem_id": "${current.problem_id}",
"company": "${current.company}",
"reassignment_count": "${current.reassignment_count}",
"activity_due": "${current.activity_due}",
"assigned_to": "${current.assigned_to}",
"severity": "${current.severity}",
"comments": "${current.comments}",
"approval": "${current.approval}",
"sla_due": "${current.sla_due}",
"comments_and_work_notes": "${current.comments_and_work_notes}",
"due_date": "${current.due_date}",
"sys_mod_count": "${current.sys_mod_count}",
"reopen_count": "${current.reopen_count}",
"sys_tags": "${current.sys_tags}",
"escalation": "${current.escalation}",
"upon_approval": "${current.upon_approval}",
"correlation_id": "${current.correlation_id}",
"location": "${current.location}",
"category": "${current.category}"
}

Create a business rule in ServiceNow.

A business rule gives the REST message the context you want sent over to Tines.

In your ServiceNow instance, open the “All” tab and navigate to “System Web Services” > “System Definition” > “Business Rules”.

Select “New”.

Name the business rule something relevant to the data you will be sending to Tines and select the table from within ServiceNow that your data will be coming from.

In this example, we have “Tines Webhook” and “Incident [incident]” respectively. Toggle on the “Advanced” check-box.

The next steps depend on when you want the Tines webhook to receive data. Depending on your use case you may wish for the business rule to run when there is an ‘Insert’ or ‘Update’ to the underlying data. You may also want to specify filter conditions under which the business rule should run.

In this example, we specified ‘Insert’ only.

In the Advanced tab, you can also include a script. Paste in the following or something similar to use the fields that you’ve specified in your REST message.

Note: If using this script, make sure to modify the Tines webhook URL with the URL from the one you created earlier.

Select “Submit”.

(function executeRule(current, previous /*null when async*/) {
try {
// Create the payload to send to Tines
var payload = {
};

// Add relevant record fields to the payload
payload.number = current.number.toString();
payload.sys_id = current.sys_id.toString();
payload.short_description = current.short_description.toString();
payload.description = current.description.toString();
payload.priority = current.priority.toString();
payload.state = current.state.toString();
payload.assigned_to = current.assigned_to.toString();

// Convert the payload to JSON
var jsonString = JSON.stringify(payload);

// Set up the REST message to Tines webhook
var restMessage = new sn_ws.RESTMessageV2();

// Replace with your actual Tines webhook URL
restMessage.setEndpoint("<https://your-tenant-name.tines.com/webhook/path/secret>");
restMessage.setHttpMethod("POST");

// Set headers
restMessage.setRequestHeader("Content-Type", "application/json");

// Optional: Add authentication if required by your Tines webhook
// restMessage.setBasicAuth("username", "password");
// OR
// restMessage.setRequestHeader("Authorization", "Bearer your-token-here");

// Set the request body
restMessage.setRequestBody(jsonString);

// Execute the request
var response = restMessage.execute();

// Log the response
var responseBody = response.getBody();
var statusCode = response.getStatusCode();

gs.log("Tines webhook response status: " + statusCode, "Tines Integration");
gs.log("Tines webhook response body: " + responseBody, "Tines Integration");

} catch (ex) {
gs.log("Error sending data to Tines webhook: " + ex.message, "Tines Integration");
}

})(current, previous);

Verify the connection works.

In this case, I used the Incident table in ServiceNow and to test I created a new record and after submitting, viewed the data populated in the Tines webhook.

From there, continue building out the rest of your story!

Did this answer your question?