Examples of programmable decisions
The following are examples of programmable decisions to help get you started writing JavaScript in a a decision model variant.
Example 1: Retrieve custom attributes in a programmable decision
You can leverage custom guest attributes that are specific to your organisation, as inputs in decisioning. For example, use the guest's loyalty membership tier as an input in a decision model variant. This can ensure that you only display offers and content relevant to the guest's current membership tier.
Ensure you set the Return Type as Map for the programmable decision.
Example 2: Retrieve currency of closed session in a programmable decision
To ensure your organization is consistent in personalizing to the guest in the same currency that they chose in their closed session, you can create a programmable decision that retrieves the currency of the closed session. This is particularly useful in experiments that are designed for retargeting.
Ensure you set the Return Type as String for the programmable decision.
Using programmable outputs in decision tables
After creating a programmable decision, you can use its output as input for decision tables. This allows you to combine custom JavaScript logic with rule-based decision-making.
We'll show an example on how to use the output from Example 2 in a decision table to create currency-specific offers and pricing.
Step 1: Output from the programmable in Example 2
For a sample guest input with values for currency is USD, the programmable named Programmable 1 returns a an output like the following from a closed session:
Step 2: Set up the Input column to use the programmable
To use the sessionCurrency output from the programmable in a decision table:
- Add an input column and select the programmable decision as input. In our example, you are using the programmable named Programmable 1.
- Specify the following for the Input Column:
- Name of Column - name to use for the input. (example: Guest currency)
- Choose Type - select the correct data type based on the indicated programmable output's type. (example: String)
- Once the Input column is added, continue configuring the decision table as normal, by setting up the output column and adding rules.