Beginning with Pega 7.2.2, you can capture responses in a headless decisioning scenario by using a real-time data flow.
The enhancements described in this article simplify the previous process of building headless decisioning scenarios (see Headless decisioning in Pega 7.1.8 to Pega 7.2.1
). You can choose whether to configure a response service and an activity to trigger a response flow, or to create and activate a real-time data flow to capture responses.
Decisioning process in a headless decisioning scenario
This scenario is built in the DMSample application, but you can use this scenario in any other application.
A customer who logs in to a website enters a user name (ID) and password. The Pega REST service calls the ServiceActivity activity in the DMOrg-DMSample-Int-Decision class and passes the customer's ID. The ServiceActivity activity then invokes the DecisionFlow data flow for this customer. The NextBestAction strategy that is referenced from the DecisionFlow data flow selects the banners to display on the website. When the customer clicks one of the banners, the ResponseStream data set that is the source for the StreamResponseFlow data flow picks up this event. The ResponseStrategyWithoutInteractionID strategy that is referenced from the StreamResponseFlow data flow gets a list of the customer's decision results from decision time as well as the customer properties that rank the banners by using adaptive models. This data is used to update the previous results (the pxInteractionHistory data set) and refine the adaptive models (in the pxAdaptiveAnalytics data set).
Headless decisioning process with a real-time data flow as the response flow
Rules used by this headless decisioning scenario
The headless decisioning scenario uses several business rules, such as Service REST, Activity, Strategy, and Data Flow. The DMSample application has the following rule instances:
The DecisionService service in the DMOrg-DMSample-Int-Decision class
To invoke this service on any system, use the following URL: http://<IPaddress>/prweb/PRRestService/DMSampleServices/DMSample/DecisionService/decision?CustomerID=<CustomerID>.
For example, http://192.168.12.56/prweb/PRRestService/DMSampleServices/DMSample/DecisionService/decision?CustomerID=CE-1.
The service call returns offers in XML format, like this example:
- The ServiceActivity activity in the DMOrg-DMSample-Int-Decision class
- The DecisionFlow data flow in the DMOrg-DMSample-Int-Decision class
- The NextBestAction strategy in the DMOrg-DMSample-Data-Customer class
- The StreamResponseFlow data flow in the DMOrg-DMSample-Int-Response class
- The ResponseStrategyWithoutInteractionID strategy in the DMOrg-DMSample-Int-Response class
StreamResponseFlow data flow
The StreamResponseFlow data flow is a new way of sending the response data. When you run and activate this data flow, the ResponseStream data set can receive responses in JSON format.
StreamResponseFlow data flow with the ResponseStream data set as the source
The responses that the data set receives can contain an InteractionID, but it is no longer required. When the channel application does not keep track of the InteractionID in a headless decisioning scenario, use a response strategy that fetches all the interactions for a particular customer in a specific date range. In the DMSample application, the ResponseStrategyWithoutInteractionID strategy is a simple example of such a strategy.
Properties of the Decision strategy shape in the StreamResponseFlow data flow
The ResponseStrategyWithoutInteractionID strategy fetches the last interaction and assumes that the response is for that interaction. Then, the strategy uses properties from the Issue/Group/Name hierarchy to match one particular decision from that last interaction. The strategy assumes that the click is for the decision, marks the click as a positive outcome, and marks the other decisions from that interaction as negative.
The decision results from the strategy return to the StreamResponseFlow data flow and are written into the Interaction History data set (pxInteractionHistory) and the Adaptive Analytics data set (pxAdaptiveAnalytics). The results stored in these data sets improve the adaptive model outputs and can be accounted for by the subsequent decisions.