# Using IdentityNow Workflows to Send a List of Uncorrelated Accounts After Aggregation

**URL:** <https://developer.sailpoint.com/discuss/t/using-identitynow-workflows-to-send-a-list-of-uncorrelated-accounts-after-aggregation/24010>\
**Category:** Community Blog\
**Tags:** workflows, identity-security-cloud, aggregation\
**Created:** [January 11, 2024, 2:19pm UTC](https://developer.sailpoint.com/discuss/t/using-identitynow-workflows-to-send-a-list-of-uncorrelated-accounts-after-aggregation/24010 "2024-01-11T14:19:06Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![baoussounda](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/baoussounda/32/13095_2.png) [@baoussounda](https://developer.sailpoint.com/discuss/u/baoussounda)\
**Post date:** [January 11, 2024, 2:19pm UTC](https://developer.sailpoint.com/discuss/t/using-identitynow-workflows-to-send-a-list-of-uncorrelated-accounts-after-aggregation/24010/1 "2024-01-11T14:19:06Z")

</div>

![Tutorials-Blue](https://global.discourse-cdn.com/sailpoint/original/2X/5/500e0e1b78aa237f647b036e505fbb503d76ded9.png)

# Introduction

The goal of this blog is to show how create a workflow that will send an email with a list of uncorrelated accounts to a source owner after each aggregation. This workflow can keep the source owner informed about uncorrelated accounts after each aggregation.

The notification will contain the following information:

- Source Name
- Number of uncorrelated accounts
- A preview of the first ten uncorrelated accounts in table format
- A direct link to the source uncorrelated export page

# Workflow implementation

Here is the functional flow of the workflow steps :

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/f/f4085de5f949864d5e599f30a4678bdd3a7d6b2e.png)

Create a new workflow called “Send notification with uncorrelated accounts” and add the “Account Aggregation Completed” trigger as the first step.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/8/814408f75f67aa3247b829fda94abfb35326319c.png)

As you can see in screenshot above, it possible to add an optional filter if you want to send notification only for specific sources.

```auto
$[?((@.source.name in ["My source 1", "My source 2", "My source 3"]) && (@.status == "Success"))]

```

- This filter means a workflow will process only for the sources : “My source 1”, “My source 2”, “My source 3” and if the aggregation status is **Success**
- You can replace “My source 1”, “My source 2”, “My source 3” with your source names and add more sources if you want.

Next, add an **HTTP Request** action beneath the trigger. This action will be used to fetch the list of uncorrelated accounts using the [Accounts List](https://developer.sailpoint.com/idn/api/v3/list-accounts) endpoint. Configure it as follows

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/9/97a4d6339018320b4389916f93370ee2abceb1ff.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/a/abba9581fd05541fc64d282db76f231eb8c766df.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/0/06e30083507de9a866ce39e8a1fe835dd3ade6eb.png)

- **Token URL** is in the following format: `https://{tenant}.api.identitynow.com/oauth/token`
- **Client ID and Client Secret** are the obtained from your personal access token. See [this guide](https://developer.sailpoint.com/idn/api/authentication#generate-a-personal-access-token) for more information on generating a PAT.
- **Request URL** is `https://{{tenant}}.api.identitynow.com/v3/accounts?filters=sourceId%20eq%20%22{{$.trigger.source.id}}%22%20and%20uncorrelated%20eq%20true&count=true&limit=10`
- Leave the **Request Content Type** empty

After the HTTP Request, add a **Verify Data Type** operator to check if uncorrelated accounts are returned or not. If an item was returned, then we continue with next steps. If there was no item returned, we will terminate with “End Step — Success” operator. Configure the **Verify Data Type** operator as follows.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/4/4ac8457c93848ee8bf7c3cf805528420928cb5c8.png)

Connect the **Verify Data Type** “False” output to the “End Step — Success” operator and the “True” output to a new **HTTP Request** action.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/1/120d2667eb67aa7b53036efc87a8df532a99fd36.png)

This second **HTTP Request** action will be used to retrieve the source owner using the [Get Source by ID](https://developer.sailpoint.com/idn/api/v3/get-source) endpoint. Configure it as follows

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/3/3dfa2e6880b6face8f220b9d3ac9dcdad5ab3fe4.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/9/9e658e4fc6169c7459b63c4ae9ea2b468a6ba7b3.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/1/1120abefbe2222847f83750a9ead8163c4265813.png)

- **Token URL** is in the following format: `https://{tenant}.api.identitynow.com/oauth/token`
- **Client ID and Client Secret** are the obtained from your personal access token. See [this guide](https://developer.sailpoint.com/idn/api/authentication#generate-a-personal-access-token) for more information on generating a PAT.
- **Request URL** is `https://{tenant}.api.identitynow.com/v3/sources/{{$.trigger.source.id}}`
- Leave the **Request Content Type** empty

After the second HTTP Request, add another **Verify Data Type** operator to check if the source informations is retrieved correctly. Configure it as follow

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/e/e219201f9da5a4765a313cb9848b2acf98f0420b.png)

Connect the **Verify Data Type 1** operator “False” output to the new “End Step — Success” operator and the “True” output to the **Get Identity** action.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/f/f7f043aa12c15110c90d6c930903fd7b1f82f2b7.png)

This **Get Identity** action will be used to retrieve the source owner email. Configure it as follow.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/9/9500c5060f95ef6dc7ef11351781d852528e55b5.png)

Next, add a **Send Email** action beneath the **Get Identity** action and connect its output to the new “End Step — Success” operator. This **Send Email** action will be used to send an email to the source owner. Configure it as follow.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/5/5aa4cba7d83b7790ad6deac93b82e0cb34509f4e.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/b/b33f22bac3a987f28dddc67c516233914400b3e5.png)

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/8/851df086a83ec287161c75dd65f38f95d2c04211.png)

- **Recipient Email Addresses** : must contain recipients email addresses. In this case we use the source owner email with following JSONpath variable : `$.getIdentity.attributes.email`
- Leave the **Reply To Email Address** and **From** empty.
- **Templating Context** : is used to define variables that can be used in an email subject and body template. In our case we defining following variables:

```json
{
	"accounts.$": "$.hTTPRequest.body",
	"aggregationCompletedDate.$": "$.trigger.completed",
	"ownerName.$": "$.getIdentity.attributes.displayName",
	"sourceName.$": "$.trigger.source.name",
	"totalAccounts.$": "$.hTTPRequest.headers['X-Total-Count'][0]",
	"uncorrelatedAccountsLink": "https://{{tenant}}.identitynow.com/ui/admin#admin:connections:sources:{{$.trigger.source.id}}:uncorrelatedAccounts"
}

```

In the value of `uncorrelatedAccountsLink` variable you must replace `{{tenant}}` with your tenant URL.

- **Subject** : must contain an email subject. In this case we use: `Uncorrelated accounts on source ${sourceName}`
- **Body** : Use the following template:

```html
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	</head>
	<body style="font-family: Arial, sans-serif; margin: 20px">
		<p>Hello <strong>${ownerName}</strong>,</p>

		<p>
			After aggregation on source <strong>${sourceName}</strong> at
			<strong>${aggregationCompletedDate}</strong>, <strong>
				${totalAccounts}</strong
			>
			uncorrelated accounts are detected.
		</p>
		<p>
			You can access export of uncorrelated accounts page
			<a
				href="${uncorrelatedAccountsLink}"
				style="color: blue; text-decoration: underline"
				>here</a
			>
		</p>

		#if($totalAccounts <= 10)
		<p>Below list of uncorrelated accounts :</p>
		#else
		<p>Below list of the 10 first uncorrelated accounts :</p>
		#end

		<table style="width: 100%; margin-top: 20px; border-collapse: collapse">
			<thead>
				<tr>
					<th style="border: 2px solid grey; background-color: #f2f2f2">
						account
					</th>
					<th style="border: 2px solid grey; background-color: #f2f2f2">
						displayName
					</th>
				</tr>
			</thead>
			<tbody>
				#foreach($account in $accounts)
				<tr>
					<td style="border: 2px solid grey; padding: 8px; text-align: center">
						${account.nativeIdentity}
					</td>
					<td style="border: 2px solid grey; padding: 8px; text-align: center">
						${account.name}
					</td>
				</tr>
				#end
			</tbody>
		</table>

		<p>Best regards</p>
		<p>IdentityNow Team</p>
	</body>
</html>

```

As you can see in the template we use different variables defined in the **Templating Context**.

# Complete workflow and JSON file

Here is the complete workflow

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/7/73f304592cb81dea02b20107294d872f08154805.png)

And you can download the JSON file here:  
[SendNotificationForUncorrelatedAccountsV2.json](https://developer.sailpoint.com/discuss/uploads/short-url/ggYB2ODTsfkFURZIbVfonCXHYvl.json) (5.3 KB)

# Testing the workflow

For testing this workflow, you can use the “Test workflow” button available in the UI :

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/e/e2f81a34c67f5c2e8fa56a092526be2770cadb06.png)

This default input is provided as:

```json
{
  "source": {
    "id": "4e4d982dddff4267ab12f0f1e72b5a6d",
    "name": "Corporate Active Directory",
    "type": "SOURCE"
  },
  "status": "Success",
  "started": "2020-06-29T22:01:50.474Z",
  "completed": "2020-06-29T22:02:04.090Z",
  "errors": [],
  "warnings": [
    "Account skipped"
  ],
  "stats": {
    "scanned": 200,
    "unchanged": 190,
    "changed": 6,
    "added": 4,
    "removed": 3
  }
}

```

Replace the `id` and `name` properties in the source object per your source `id` and `name` which you will use for testing.

Next , click on “Start workflow test” button and you should see a result like this:

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/7/7e355815e8be5b12e5567fd0845ed71d96cec53e.png)

The owner of the source should receive an email similar to this.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/f/fd479bc3ed02e4a7d2a62357e10906455efcab90.png)

---

_[View the full topic](https://developer.sailpoint.com/discuss/t/using-identitynow-workflows-to-send-a-list-of-uncorrelated-accounts-after-aggregation/24010)._
