- 10 May 2021
- 2 Minutes to read
- Print
- DarkLight
Using Random Rule and Sampling Rule Steps
- Updated on 10 May 2021
- 2 Minutes to read
- Print
- DarkLight
Overview
The Random Rule and Sampling Rule components provide a way to test for probability within a Flow. Within set boundaries, both components randomly return one of two outcomes "True" or "False." The random outcomes can be weighted by configuring the Percentage of times that the outcome will be True.
To guarantee the ratio of "True" to "False" outcomes, the Sampling Rule offers an additional option for configuring the sample size via the Sample Key Input.
Example
The following example Flow will follow one of three paths. About 50% of the time it will follow the path to send a Customer Satisfaction survey. If the Flow does not follow the path to send a Customer Satisfaction survey, it will choose to either send a thank you email or send an email containing a coupon.
The sample size for this second choice is 10. This means that if the Flow chooses to follow the path to send a thank you email containing a coupon five times, it will not choose that path again until it has chosen both paths a total of 10 times. The same holds true with the options reversed.
- In a Designer Project, select CREATE FLOW, click Default, then click CREATE. Provide a Name for the Flow and click CREATE.
- Attach a Random Rule step by clicking the Done path on the Start step and navigating to All Steps [Catalog] > Data > Rules. Select Random Rule and click ADD.
- On the Properties panel under the INPUTS category, ensure that the value in the Percent True field is set to 50.
- Click the True path and attach a Send Email step.
- On the Properties panel, configure the values for From, To, Subject, and Message. Connect the Sent path to the End step.
- From the RULES step category, attach a Sampling Rule step to the False path of the Random Rule step. Set Sample Key to 10 and leave the Percent True value at 50. Then, connect the Sent path to the End step.This step will be used to determine whether to send a basic Thank You email or one containing a coupon. Sample Key value dictates the sample size and that for every 10 times the Flow crosses this path, the Sampling Rule will send the "Coupon" Email five times. After the Flow reaches these five instances, it will not send the "Coupon" Email again until both paths of the Sampling Rule have been reached 10 times.
- Attach a Send Email step to the True path of the Sampling Rule and configure the required EMAIL values accordingly. Then, connect its Sent path to the End step.
- Attach a Send Email step to the False path and configure its EMAIL values accordingly. Then, attach the Sent path to the End step.
- Click Save to save the Flow.
Debug
- On the top action bar, select Debug and then click FULL.
- After the Flow runs, click CREATE NEW SESSION to repeat the process.