# ServiceNow

## Overview

The ServiceNow Integration enables seamless connectivity between your platform and ServiceNow to synchronize tickets, customer data, and operational workflows. This integration supports **Helpdesk**, **CRM**, and **Content Management** capabilities, allowing organizations to centralize service operations, improve visibility, and ensure real-time data synchronization through APIs and webhooks.

### Prerequisites & Access Requirements (ServiceNow OAuth App) <a href="#prerequisites-and-access-requirements-servicenow-oauth-app" id="prerequisites-and-access-requirements-servicenow-oauth-app"></a>

To enable integration, ensure access to the following:

* **APIs Access:**
  * Case API (Read & Write)
  * Account API (Read)
  * Table API (Read)
  * Attachment API (Read)
* **Table Access:**
  * sn\_customerservice\_case (Read)
  * kb\_knowledge (Read & Write)
  * sys\_user (Read)
  * customer\_contact (Read)
  * sys\_journal\_field (Read)
  * sys\_audit / sys\_audit\_delete (Read)
  * customer\_account (Read)
  * sn\_customerservice\_escalation (Read)

### Capability-Specific Notes <a href="#capability-specific-notes" id="capability-specific-notes"></a>

* **Helpdesk Capability:**\
  Requires full configuration including all authentication fields and “Pull Record By”.
* **CRM Capability:**\
  Same as Helpdesk. Only select **CRM** in Configuration.
* **Content Management Capability:**\
  Same as Helpdesk except **“Pull Record By”** is not required.

### Best practices

* **Leverage Browser Session Authentication:**\
  If already logged into ServiceNow, authentication may complete automatically.
* **Ensure Proper API & Table Access:**\
  Verify required permissions are granted to avoid failures.
* **Validate Webhook Configuration:**\
  Ensure all business rules are properly configured for real-time updates.
* **Select Correct Data Sync Option:**\
  Choose appropriate “Pull Record By” option based on use case.
* **Proactive Token Management:**\
  Monitor token expiry and refresh proactively.
* **Maintain Security Compliance:**\
  Secure Client ID, Secret, and credentials as per organizational policies.

## Setup instructions <a href="#setup-instructions" id="setup-instructions"></a>

### Create OAuth Application in ServiceNow <a href="#section-1-create-oauth-application-in-servicenow" id="section-1-create-oauth-application-in-servicenow"></a>

{% stepper %}
{% step %}
Log in to your **ServiceNow instance**.
{% endstep %}

{% step %}
Open the **Application Navigator**.
{% endstep %}

{% step %}
Search for and navigate to **Inbound Integrations**.
{% endstep %}

{% step %}
Click on **New Integration**.
{% endstep %}

{% step %}
Select **OAuth – Authorization Code Grant** as the connection type.
{% endstep %}

{% step %}
Configure the integration details:

1. Provide a unique **Name** (e.g., TheLoops Integration).
2. Set **Active = True**.
3. Enter the appropriate **Redirect URL** (based on your environment).
   1. **Prod US:** <https://app.prod1.theloops.ai/v1/oauth/callback>
   2. **Prod EU:** <https://app.eu.prod1.theloops.ai/v1/oauth/callback>
      {% endstep %}

{% step %}
(Optional) Configure **Auth Scopes** if access restriction is required.

1. Select an existing scope OR click **Create Auth Scope**.
2. Assign the APIs listed in the requirements table above.
   {% endstep %}

{% step %}
Configure **Enforce Token Restriction**:

* If enabled → Configure REST API Access Policies.
* If disabled → You can skip the configuration of REST API Access Policies.
  {% endstep %}

{% step %}
Save the integration.
{% endstep %}
{% endstepper %}

### (Optional) REST API Access Policy Configuration <a href="#optional-rest-api-access-policy-configuration" id="optional-rest-api-access-policy-configuration"></a>

{% hint style="info" %}
Applicable only if token restriction is enabled
{% endhint %}

{% stepper %}
{% step %}
Create **Inbound Authentication Profile**.
{% endstep %}

{% step %}
Click on **New**
{% endstep %}

{% step %}
Click on **Create standard http authentication profiles**

1. **Name:** Give unique name.
2. **Type:** Select **OAuth**
3. **OAuth entity:** Select the inbound integration created in above step.
   {% endstep %}

{% step %}
Click **Submit.**
{% endstep %}
{% endstepper %}

#### **Define the Access Policy**

{% stepper %}
{% step %}
Navigate to **REST API Access Policies.**
{% endstep %}

{% step %}
Click **New**. Configure the policy with the following settings.

1. **Name**: e.g., TheLoops Case API Access
2. **Active**: true
3. **REST API**: Select **Case API**
4. **Apply to all methods**: Enabled (Required for Read/Write)
5. **Apply to all resources**: true
6. **Apply to all versions**: true
7. **Inbound auth profiles**: Select the profile created in Step 6.1
   {% endstep %}

{% step %}
Ensure:

* “Apply to all versions” and “Apply to all resources” are enabled.
* Appropriate read/write access is configured.
  {% endstep %}

{% step %}
Click on **Submit**.
{% endstep %}

{% step %}
Repeat steps 1-4 for all other APIs required for TheLoops.

1. &#x20;For each policy, make sure “**Apply to all versions**” and “**Apply to all resources**” are enabled and select **Apply to all methods** based on the level of access you want to grant
2. &#x20;For Table API access, include all the tables you want to grant access to in the policy. If some tables need both read and write access (for example, 2 out of 8 tables), create a separate policy for those 2  tables and enable Apply to all methods for read and write access.
   {% endstep %}

{% step %}
Repeat steps 1-5 for **Account,** and **Attachment API**
{% endstep %}
{% endstepper %}

### Integration Setup in Platform

{% stepper %}
{% step %}
Log in to **TheLoops** platform using an **Admin** account.
{% endstep %}

{% step %}
Navigate to **Settings → Integrations** module.
{% endstep %}

{% step %}
Click on the **“+ Add Integration”** button.
{% endstep %}

{% step %}
Search for **ServiceNow** and open the integration setup.
{% endstep %}
{% endstepper %}

### **Configuration**

{% stepper %}
{% step %}
In the **Configuration** tab, enter a suitable name.
{% endstep %}

{% step %}
Select the required **Capability**:

* Helpdesk
* CRM
* Content Management
  {% endstep %}

{% step %}
Click **Next**.
{% endstep %}
{% endstepper %}

### **Authentication**

{% stepper %}
{% step %}
Enter your **ServiceNow domain** (core domain only).
{% endstep %}

{% step %}
Enter **Client ID**.
{% endstep %}

{% step %}
Enter **Client Secret**.
{% endstep %}

{% step %}
Select **Environment** (Production/Sandbox).
{% endstep %}

{% step %}
Select **Pull Record By**:

* Created Time
* Updated Time\
  \&#xNAN;*(Not required for Content Management)*
  {% endstep %}

{% step %}
Select **Refresh Token Expiry Date**.
{% endstep %}

{% step %}
Click on **Connect**.
{% endstep %}

{% step %}
Enter ServiceNow credentials and click **Login**.
{% endstep %}

{% step %}
Click **Allow** to authorize access.
{% endstep %}
{% endstepper %}

### Validation & Verification <a href="#validation-and-verification" id="validation-and-verification"></a>

{% stepper %}
{% step %}
Upon successful authentication:

1. Integration will be added successfully.
2. A success message will be displayed.
   {% endstep %}

{% step %}
Verify the integration in the **Integrations list**.
{% endstep %}

{% step %}
Click on **Test Connection**:

1. A success message confirms correct setup
   {% endstep %}
   {% endstepper %}

## Webhook Setup (ServiceNow)

### Overview <a href="#overview.1" id="overview.1"></a>

Webhooks in ServiceNow enable real-time synchronization of ticket activities such as **case creation, updates, comments, and attachments**. This ensures that all changes are instantly reflected in the platform without delay.

### Configuration Steps <a href="#configuration-steps" id="configuration-steps"></a>

{% stepper %}
{% step %}
**Open Integration:** Click on the **Edit** button for the ServiceNow integration you want to configure.
{% endstep %}

{% step %}
**Copy URL:** Copy the **webhook URL** by clicking on the copy icon.
{% endstep %}
{% endstepper %}

#### **Ticket Comment Webhook**

{% stepper %}
{% step %}
Open **Business Rules** in ServiceNow.
{% endstep %}

{% step %}
Click **New** and configure:

1. Name: Provide a descriptive name (e.g., *TheLoops Ticket Comment Webhook*).
2. Table: `Select the sys_journal_field table.`
3. When: select **After**
4. **Advanced:** Check this checkbox.
5. Trigger: Insert & Update
   {% endstep %}

{% step %}
**Add Script:** Click on the **Advanced** tab and replace the existing code with the following snippet:
{% endstep %}

{% step %}
Replace webhook URL with the one copied from **TheLoops** platform.
{% endstep %}

{% step %}
Click on **Submit**.
{% endstep %}
{% endstepper %}

#### **Case Webhook**

{% stepper %}
{% step %}
Create a new Business Rule.
{% endstep %}

{% step %}
Configure:

1. **Name:** Provide a descriptive name (e.g., *TheLoops - Case Created or Updated*).
2. **Table:** Select the **sn\_customerservice\_case** table.
3. **Advanced:** Check this checkbox.
4. **When:** Select **After**.
5. **Insert/Update:** Check both the **Insert** and **Update** checkboxes.
   {% endstep %}

{% step %}
**Add Script:** Click on the **Advanced** tab and replace the existing code with the following snippet:
{% endstep %}

{% step %}
Replace webhook URL with the one copied from **TheLoops** platform and Click on **Submit**.
{% endstep %}
{% endstepper %}

#### **Attachment Webhook (Optional)**

{% stepper %}
{% step %}
Create a new Business Rule.
{% endstep %}

{% step %}
Configure:

1. **Name:** Provide a descriptive name (e.g., *TheLoops Attachment Webhook*).
2. **Table:** Select the **sys\_attachment** table.
3. **Advanced:** Check this checkbox.
4. **When:** Select **After**.
5. **Insert:** Check the **Insert** checkbox.
   {% endstep %}

{% step %}
**Add Script:** Click on the **Advanced** tab and replace the code with the following snippet.
{% endstep %}

{% step %}
Replace webhook URL with the one copied from **TheLoops** platform and Click on **Submit**.
{% endstep %}
{% endstepper %}

## Token Management (OAuth Integration) <a href="#token-management-oauth-integration" id="token-management-oauth-integration"></a>

### Overview <a href="#overview.2" id="overview.2"></a>

ServiceNow integration uses OAuth authentication. Tokens expire after a defined duration, causing **Test Connection** failures. Tokens can be regenerated without recreating the integration.

### Token Regeneration <a href="#token-regeneration-steps" id="token-regeneration-steps"></a>

{% stepper %}
{% step %}
Navigate to **Integrations** module.
{% endstep %}

{% step %}
Click the **Test Connection** icon; if it fails, it indicates that the token has expired.
{% endstep %}

{% step %}
Click on the **Edit** icon (beside the delete icon) for the integration requiring token refresh.
{% endstep %}

{% step %}
Go to **Authentication** tab.
{% endstep %}

{% step %}
Click **Re-generate Token**.
{% endstep %}

{% step %}
Login again via authentication window.
{% endstep %}

{% step %}
Click **Allow** to authorize access.
{% endstep %}

{% step %}
Token will be refreshed with a success message.
{% endstep %}

{% step %}
Return to the **Integrations** list and click on **Test Connection**.

1. A successful response confirms that the token has been refreshed correctly.
   {% endstep %}
   {% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kb.theloops.io/cxplatform/ifs-loops-cx-platform/integrations/servicenow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
