Send personalized alerts to operators

Last update: 2022-11-09

In this example, we want to send an alert to an operator that will contain the name of profiles who opened a newsletter but did not click the link it contains.

The profiles’ first and last name fields are linked to the Recipients targeting dimension, whereas the Alert activity is linked to the Operator targeting dimension. As a result, there is no field available between the two targeting dimensions to perform a reconciliation and retrieve the first and last name fields, and display them in the Alert activity.

The process is to build a workflow as below:

  1. Use a Query activity to target data.
  2. Add a JavaScript code activity into the workflow to save the population form the query to the instance variable.
  3. Use a Test activity to check the population count.
  4. Use an Alert activity to send an alert to an operator, depending on the Test activity result.

Saving the population to the instance variable

Add the code below into the JavaScript code activity.

var query = xtk.queryDef.create(
    <queryDef schema="temp:query" operation="select">
       <node expr="[target/recipient.@firstName]"/>
       <node expr="[target/recipient.@lastName]"/>
  var items = query.ExecuteQuery();

Make sure that the Javascript code corresponds to your workflow information:

  • The queryDef schema tag should corresponds to the name of the targeting dimension used in the query activity.
  • The node expr tag should correspond to the name of the fields you want to retrieve.

To retrieve these information, follow the steps below:

  1. Right-click the outbound transition from the Query activity, then select Display the target.

  2. Right-click the list, then select Configure list.

  3. The query targeting dimension and fields names display in the list.

Testing the population count

Add the code below into the Test activity to check if the targeted population contains at least 1 profile.


Setting up the alert

Now that the population has been added into the instance variable with the desired fields, you can add these information into the Alert activity.

To do this, add into the Source tab the code below:

var items = new XML(instance.vars.items)
for each (var item in items){
<li><%= %> <%= %></li>
} %></ul>

The <%= %> command lets you add one of the fields that have been saved to the instance variable through the JavaScript code activity.
You can add as many fields as desired, as long as they have been inserted into the JavaScript code.

On this page