This content has been archived and is no longer being maintained.

Table of Contents

Article

Tutorial: Building a headless decisioning scenario with data flows in Pega 7.2.1

In this tutorial, you learn how to create and configure data flows that you can use to build a headless decisioning scenario on the Pega 7 Platform. You also get a description of the configuration details of data flows in this scenario, and links to additional resources about data flows and data sets.

The procedure described here is a part of building a model headless decisioning scenario. Before you continue, read the introduction on headless decisioning Headless decisioning on the Pega 7 Platform.
  1. Prerequisites
  2. Creating an instance of the Data Flow rule called DecisionFlow
  3. Creating an instance of the Data Flow rule called ResponseFlow
  4. Configuration details of data flows
  5. Next steps
This tutorial takes 40 minutes to complete.

Prerequisites

  • Create NextBestAction and ResponseStrategy strategies.

    For details on how to create strategies, see the PDN article Tutorial: Creating decision strategies for a headless decisioning scenario.

  • Create a CustomerTable data set of type Database Table in the DMOrg-DMSample-Data-Customer class. This data set contains all of the information associated with the users who log into the website. When the data is merged, it provides a full record about a website user who logged into the website.

    For details on how to create data sets, see the About Data Set rules help topic.

Creating an instance of the Data Flow rule called DecisionFlow

Create an instance of the Data Flow rule that uses the NextBestAction strategy to select banners for a customer who logs in to the website. DH_Decision_Flow1.png

DecisionFlow Data Flow rule

  1. In the Application Explorer, right-click the DMOrg-DMSample-Int- class and select Create > Data Model > Data Flow.
  2. Define the record configuration of the data flow.
    1. In the Label field, enter Decision Flow.
    2. Ensure that the Apply to field contains the class where you want to save the data flow (DMOrg-DMSample-Int-Decision).
    3. Click Create and open.
  3. Navigate to the Source shape, click the add icon on the right, and select Convert.
    1. Open the Convert component.
    2. In the Convert to field, select the DMOrg-DMSample-Data-Customer class.
    3. Click Add mapping.
    4. In the Set field, select .CustomerID.
    5. In the equal to field, select .CustomerID.
    6. Click Submit.
  4. Navigate to the Convert shape, click the add icon on the right, and select Merge. Notice that a secondary source component appeared.
    1. Open the secondary source component.
    2. In the Source field, select Data set.
    3. Select the CustomerTable data set in the DMOrg-DMSample-Data-Customer input class.
    4. Click Submit.
  5. Open the Merge component and specify the merge conditions.
    1. In the when field, select .CustomerID.
    2. In the is equal to field, select .CustomerID.
    3. Click Submit.
  6. Navigate to the Merge shape, click the add icon on the right, and select Strategy.
  7. Configure the Strategy component.
    1. Open the Strategy component.

      Properties panel of the Strategy component in the Data Flow rule form

    2. In the Strategy field, select NextBestAction.
    3. Select the Manage learning cycle or outcome capture option.
    4. Store adaptive inputs and strategy results for 1 day.
    5. In the Output strategy results section, select the Embedded in option.
    6. In the Embedded in field, select the DMOrg-DMSample-Data-DecisionResult class.
    7. Click Add mapping to map the properties between the target class (DMOrg-DMSample-Data-DecisionResult) and the source class (DMOrg-DMSample-SR):
      • .DecisionResults to All results
      • .CustomerID to Subject ID
      • .InteractionID to InteractionID
    8. Click Submit.
  8. Click Save.

Creating an instance of the Data Flow rule called ResponseFlow

Create an instance of the Data Flow rule that writes the outcome of decisions results to Interaction History (the pxnteractionHistory data set) and Adaptive Decision Manager (the pxAdaptiveAnalytics data set). You can use Interaction History records results for reporting and future decisions. The second data set records data that is necessary to update the adaptive data store and refine adaptive models. DH_Response_Flow1.png

ResponseFlow Data Flow rule

  1. In the Application Explorer, right-click the DMOrg-DMSample-Int-Response class and select Create > Data Model > Data Flow.
  2. Define the record configuration of the data flow.
    1. In the Label field, enter Response Flow.
    2. Ensure that the Apply to field contains the class where you want to save the data flow (DMOrg-DMSample-Int-Response).
    3. Click Create and open.
  3. Navigate to the Source shape, click the add icon on the right, and select Strategy.
  4. Open the Strategy component.

    Properties panel of the Strategy component in the Data Flow rule form

    1. In the Strategy field, select ResponseStrategy.
    2. Select the Manage learning cycle or outcome capture option.
    3. Select the Retrieve previous inputs and results using key option and enter .InteractionID in the field.
    4. In the Output strategy results section, select the Individually in option.
    5. Click Submit.
  5. Open the Destination shape.
    1. In the Destination field, select Data set.
    2. In the Data set field, select InteractionHistory data set.
    3. Click Submit.
  6. Navigate to the Destination shape and click the add icon on the bottom.
  7. Open the second destination shape.
    1. In the Destination field, select Data set.
    2. In the Data set field, select AdaptiveAnalytics.
    3. Click Submit.
  8. Click Save.

Once you create all of the rules and configure them, the headless decisioning scenario is ready to use.

Configuration details of the data flows

Types of data flows

There are three types of data flow that you can create on the Pega 7 Platform, depending on the primary input they have:

  • Batch data flows - Data flows of this type use a non-Stream data set type (Database Table, Decision Data Store, HBase Data Set, HDFS data set)or report definition as the primary input of data.

  • Real time data flows - Data flows of this type use a Stream data set type as the primary input of data.

  • Abstract - Data flows of this type use an abstract set of rules instead of primary input. You select Abstract in the Source component of the data flow when you do not know where the data input comes from. The moment the data flow is invoked, for example by an activity, the activity provides the data input.

Data flow components

  • Source and Destination

    The ResponseFlow data flow has an Abstract primary input and output. This means that the mechanism that triggers the data flow needs to provide input data and another mechanism needs to pick up decision results and send them to the channel application. The primary input provides a page of type DMOrg-DMSample-Int-Decisionthat contains the .CustomerID property. The ResponseFlow data flow passes the page to the Convert component.

    The Source and Destination components are the entry and exit points for data that a data flow moves and processes. For more details about data flow components, see Data Flow rule form - Completing Data Flows.

  • Convert

    Convert allows you to take data from one class and put it in another, overwriting identical properties (by name) or explicitly mapping properties that do not have the same name between source and target. In the tutorial, this component converts data from the DMOrg-DMSample-Int-Decision class to DMOrg-DMSample-Data-Customer.

  • Merge

    In this component, the data flow merges the customer record identified by .CustomerID with the record coming from the secondary source (the CustomerTable data set). To merge the data successfully both records must have the same .CustomerID. In this tutorial the secondary source is a Database Table that contains all of the customers' data.

    Make sure that both inputs to the Merge component (output of the Convert and secondary Source component) result in the same class. In this tutorial it is DMOrg-DMSample-Data-Customer.

    The output of the Merge component provides the full customer record for the particular .CustomerID that was sent by the channel application. This full record can be used to execute the NextBestAction strategy.

  • Strategy

    Strategy uses a combination of adaptive models and business rules. When strategy is used in a headless decisioning scenario, data flows can be used to manage the cycle of the decision response. In the tutorial the DecisionFlow is the place where the customer is offered three banners and makes a decision whether or not to click one of them.

    To record customers' decisions, the ServiceActivity activity triggers the ResponseFlow data flow. Execution of this flow saves the users' decisions (information about which banner was clicked) and the data that was used to compute which three banners should be displayed on the website. The flow references two data sets, one of them stores new data used by the adaptive models, the other one stores customers' interaction history (the decisions they made).

    When you reference a strategy in a data flow, it is important to specify the output of the strategy results. You can:

    • Output the results individually on the SR class.
    • Select the input class of the Strategy component as the output class.
    • Create an instance of a completely different class to minimize the amount of data that is sent. For this option, you need to map properties between the classes to retrieve the adaptive payload and decision results.

Data Set types

The data sets referenced in data flows represent data stored in different sources and formats. Once the data flow is invoked, the data from the data source is moved and processed by the data flow's components.

For more information about Data Set types, see Data Set rule form - Completing Data Sets

Next steps

Now that you have prepared all the rule instances that are necessary in the headless decisioning scenario, you can execute the DecisionFlow and ResponseFlow data flows and use the headless decisioning scenario.

Published October 26, 2016 — Updated September 4, 2018

Related Content

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.