# Setting up ServiceNow to Work with Ticket Concierge

This topic discusses the ServiceNow setup if you plan to use ServiceNow with Aisera's Ticket Concierge

## Prerequisite:&#x20;

Ask your Aisera team to provide you with an .XML file that contains the Update Set (data you want to upload) to ServiceNow.

## ServiceNow Setup:

1. Log into your ServiceNow system.
2. Navigate to **System Update Sets → Retrieve Update Sets** and upload the .xml file.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FSApWmFruDz3hbLrLORJB%2Fupdate_set.png?alt=media&#x26;token=85d9c16a-3684-45fb-bd56-f5f77e6e6bd8" alt=""><figcaption><p>ServiceNow Upload of Retrieved Update Set</p></figcaption></figure>

3. Click Upload.
4. After the file is uploaded, open the **Update Set**.
5. Click **Preview Update Set**, followed by **Commit Update Set**.
6. After committing the update set, verify that the following elements exist:

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FZLplIbBO3PcHoQCLCxO7%2Fsn_elements.png?alt=media&#x26;token=bddbf6fe-5087-4273-b864-5f6b0d40232c" alt=""><figcaption><p>Verify Elements</p></figcaption></figure>

7. Navigate to the ServiceNow **System Properties** page and perform the following steps.
   1. Search for name **aisera**
   2. This should bring up two results: an app token and a url

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FOGRriAZ9gkgmxfIJNs18%2Fsys_props.png?alt=media&#x26;token=dd71cdc3-0a1d-486c-b0ef-865d238002e7" alt=""><figcaption><p>ServiceNow System Properties</p></figcaption></figure>

&#x20;     c. Click on the **app token**.

&#x20;     d. Insert the value of the **app token** given to you by your Aisera Team.

&#x20;     e. Click **Update**.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2Fr0uLkRwLEGWATopLbR3D%2FSNOWapp_key.png?alt=media&#x26;token=8fdb84d7-2817-4e8a-984e-52cd32f4fa08" alt="" width="563"><figcaption><p>Setting ServiceNow App Token</p></figcaption></figure></div>

&#x20;     f. Navigate back to the prior page and click on the instance url.

&#x20;    g. Insert the value of the **app url** given to you by your Aisera Team.

&#x20;    h. Click **Update**.

8. To verify, this setup, create an incident manually.Then check the system logs by choosing the **All** tab and then typing `system logs`.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FGqkPPIesxh5RBfm9Q5O1%2Fsn_clip.png?alt=media&#x26;token=4aee931f-0803-4a96-b006-b17c36c77f39" alt="" width="319"><figcaption><p>View All System Logs</p></figcaption></figure></div>

8. Then look for the phrase, **Ticket Concierge Payload**.

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FlDTxw4VKddvuQF9p7KzZ%2Fpayload.png?alt=media&#x26;token=092a17ba-4488-4ac9-bfa1-21f04d4e96c8" alt=""><figcaption><p>Find the Ticket Concierge Payload in the System Logs</p></figcaption></figure>

8. Observe the webhook response above it for numbers like 201,500.

## Creating Business Rules

In your ServiceNow environment, on your uploaded **Update Set**, (Example: `TC event trigger_04/02/25`) click on the associated business rule (**Event Studio TC Business Rule**).

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FarSkwrfn02Ar6e12YukE%2Fbr1.png?alt=media&#x26;token=8bdcebd5-e437-4903-b4f4-3bfa008f3e5f" alt=""><figcaption><p>Customer Updates Lists in ServiceNow</p></figcaption></figure>

This will take you to a sys script page like the one shown below (depends on your ServiceNow version/setup).

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2Fg0qjvWHtTTIGhwbVos3S%2Fbr2.png?alt=media&#x26;token=90eb92e0-8255-41df-b31c-d6aa76b6558c" alt=""><figcaption><p>ServiceNow Script Editor</p></figcaption></figure>

Click **Show Related Record** on the bottom right side of the page.

<div align="left"><figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2F3MZld9fOsUd9pjoD8Q4S%2Fshow_related_record.png?alt=media&#x26;token=db597dbf-f1c7-4671-911a-bd3e5f1c3c40" alt="" width="319"><figcaption><p>Show Related Record</p></figcaption></figure></div>

Modify the logic that controls when the rule script will run. Specifically, you want it to ensure that your rule is set to run after both **Insert** AND **Update** are checked.&#x20;

Add two filter conditions:

1. Set **Assignment Group** to `Tech Aisera` (not the same as the screenshot, this is a test instance).
2. Set **State** to `New` (Identical to screenshot below).

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FSjbh17YidGKvlbZozUTc%2Fbr3.png?alt=media&#x26;token=0e0e8a3b-def7-4e7b-a0c3-83b95e5fe8cf" alt="" width="563"><figcaption><p>ServiceNow When to Run Tab for Business Rules</p></figcaption></figure>

## Scheduling the Job

To schedule a script execution job:

1. In your ServiceNow instance, navigate to: **System Definition → Scheduled Jobs → Scheduled Script Executions.**
2. Click **New** to create a new **Scheduled Script Execution**.
3. Fill Out the Scheduled Script Execution Form:

   • **Name:** Reassign Stale App Engine Admin Tickets

   • **Active:** ✅

   • **Run:** Periodically

   • **Repeat Interval:** Every 5 minutes (or what suits your load)

   • **Script:** (see below)

Replace all **group** names **(**&#x73;uch as **old group** and **new group)** in the following example with your own variables.&#x20;

```
(function() {
 var now = new GlideDateTime();


 var gr = new GlideRecord('incident');
 gr.addQuery('assignment_group.name', 'old group'); 
 gr.addQuery('state', '2'); // "In Progress"
 gr.addQuery('sys_created_on', '<=', gs.minutesAgo(15));
 gr.query();

 while (gr.next()) {
   var originalSysId = gr.getValue('sys_id');
   var number = gr.getValue('number');

   var dbGroup = new GlideRecord('sys_user_group');
   dbGroup.addQuery('name', 'new group'); replace this with your field and label

   dbGroup.query();

   if (dbGroup.next()) {
     gr.assignment_group = dbGroup.sys_id;
     gr.work_notes = 'Ticket re-routed from old group to new group due to inactivity after 15 minutes.';
     gr.update();

     gs.log('Moved incident ' + number + ' (sys_id: ' + originalSysId + ') to "new group" group.');
   } else {
     gs.logError('Could not find "Database" group. Incident ' + number + ' not updated.');
   }
 }
})();

```

You may have to change the field on the Assignment Group Name and you will definitely have to change the name of the old and new assignment group.&#x20;

The end result should look like the screenshot below:

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FEfW6F9lsUCkij3MJGktF%2Fend_script.png?alt=media&#x26;token=7f98adaa-e73d-4d79-87d9-012131bc7a49" alt=""><figcaption><p>Business Rule Script</p></figcaption></figure>

After you set up this business rule, test it by creating an INC ticket in the correct assignment group, with a status of `In  Progress` . Then leave the ticket and check back 20 minutes later.&#x20;

Observe how long it takes from the time the ticket gets created to the time the scheduled job updates the assignment group.&#x20;

In the following screenshot, the first activity is at the bottom and the assignment group update happened roughly 18 minutes later. &#x20;

<figure><img src="https://3281977978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvBFXjH9S1CAy9f5hzg5Q%2Fuploads%2FbmF41XCT4aJjXhNJIlIB%2Fbr5.png?alt=media&#x26;token=8ae448a0-ffca-4b00-ac6f-cf4c41c56d08" alt="" width="563"><figcaption><p>Activity Window</p></figcaption></figure>

If the assignment group never gets updated, check the system logs to see if an error occurred.&#x20;

\ <br>

<br>
