Send personalized alerts to operators sending-personalized-alerts-to-operators

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.

Workflow with a query, JavaScript code and Test activity; the True branch leads to an Alert activity, False to End 2.

Saving the population to the instance variable 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">
      <select>
       <node expr="[target/recipient.@firstName]"/>
       <node expr="[target/recipient.@lastName]"/>
      </select>
     </queryDef>
  );
  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.

JavaScript code script with the queryDef schema temp and the target firstName and lastName nodes highlighted.

To retrieve these information, follow the steps below:

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

    Right-click menu on the outbound transition of the Query activity with Display the target selected.

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

    Records of the target list with the right-click menu open and Configure list selected.

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

    Configure list Columns tab showing the query temp root element highlighted and its targeting dimension fields.

Testing the population count testing-the-population-count

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

var.recCount>0

Test activity with a True conditional fork using the condition vars.recCount>0 and a default False branch.

Setting up the alert 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:

<ul>
<%
var items = new XML(instance.vars.items)
for each (var item in items){
%>
<li><%= item.target.@firstName %> <%= item.target.@lastName %></li>
<%
} %></ul>
NOTE
The <%= item.target.recipient.@fieldName %> 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.

Alert activity assigned to an operator, with a message that loops over saved items to list first and last names.

recommendation-more-help
campaign-help-automation