Defining Context Eligibility Rules

The instructions in this topics explain how to apply context eligibility rules.

Configure anonymous and known-user browsing for the anonymous and known-user browsing use case

Perform the following steps to create the context dimension.

  1. Click App Launcher.
  2. Search for Vlocity Product Console and click the link.
  3. Click Dashboard, then click Rules, then click Context Dimension.
  4. Click New.
  5. Enter the required information for anonymous users or logged-in users. You do not set different context dimensions for anonymous and logged-in users. One contextdimension works for both, for example:
FieldDescription
NameDC_RULE_FIBER
CodeDC_RULE_FIBER
Code must be the same as Name.
Data TypeText
Domain TypeType in
Cacheable ModeEnable this field
Default ValueTRUE
Values for cachingTrue, False
When you run the Populate API Cache job,these values are part of pre-warming the cache. This means the API will return all the products for the defined rule and warm the cache so whenever you get a request that says DC_RULE_FIBER=True, the response is readily available because you ran the Populate API Cache job.
If false, the response will also be readily available.
If values for caching are provided when running the Populate API Cache job, then records are created in the cache response object.
If there are no values in the Values for caching field, there is a cache miss, and when the rule is executed, the response is subsequently created. The values will then be in the cache so there will be a cache hit the next time the API GET request is made.
  1. Click Save.
  2. Click the Context Mapping facet to identify Context Scope.
  3. Click New Context Mapping.
  4. Enter the following required information.

For anonymous users (example):

FieldDescription
Context ScopeAccountScope.
NOTE: Context Mappings with InitializationType as Type In only work with AnyScope or AccountScope ContextScopes.
Initialization PolicyAlways Reinitialize
Always ReinitializeType in
For anonymous browsing, you specify the rule criteria by defining a context dimension name.The dimension name does not need to be a field on the account record. To do this, selectType in, which allows the user to pass any context dimension value as part of the criteria to satisfy the rule condition.
If you want to use that criterion as part of a known-user scenario, for example, the customer's location, then identify the field on the context scope object, in this case, the account object.
TypeIn ValueDC_RULE_FIBER
It is recommended that you give the TypeIn Value the same name as the ContextDimension.
The TypeIn Value must be a constant value that you want the context dimension to hold.
Context Mappings with Initialisation Type as TypeIn only work with AnyScope or AccountScope Context Scopes.
Sequence1

For logged-in users (example):

FieldDescription
Context ScopeAccountScope.
NOTE: Context Mappings with InitializationType as Type In only work with AnyScope or AccountScope Context Scopes.
Initialization PolicyAlways Reinitialize
Initialization TypeSource Expression
Source ExpressionDC_RULE_MEMBER_STATUS__c
This identifies the logged-in user contextcondition.
For known users, the Rule Engine looks for a field named DC_RULE_MEMBER_STATUS__c on the Account Object to request context information about the user. For example, the logged-in user who is browsing products has a Gold-member SLA. "DC_RULE_MEMBER_STATUS" is the ContextDimension and "Gold" is the Context Value that is passed as part of the API Request.
Sequence1
  1. Click Save.

Perform the following steps to create the context rule.

  1. Click App Launcher.
  2. Search for Vlocity Product Console and click the link.
  3. Click + icon next to the Rules item in the menu.
  4. Enter the following required information. For anonymous users (example):
FieldDescription
NameDC_RULE_FIBER_AVAILABLE
CodeDC_RULE_FIBER_AVAILABLE
Expression Modeor

For logged-in users (example):

FieldDescription
NameDC_RULE_MEMBER_STATUS
CodeDC_RULE_MEMBER_STATUS
Expression Modeor
  1. Click Save.
  2. Click Rule Condition.
  3. Click Add Condition.
  4. Enter the following required information. For anonymous users (example):
FieldDescription
CodeDC_RULE_FIBER_AVAILABLE_COND
Context DimensionDC_RULE_FIBER
Operator==
ValueTRUE
Default Expression ValueEnable this setting.

For logged-in users (example):

FieldDescription
CodeDC_RULE_MEMBER_STATUS_COND
Context DimensionDC_RULE_MEMBER_STATUS
Operator==
ValueGold
Default Expression ValueEnable this setting.
  1. Click Save.

Perform the following steps to create rule set.

  1. Click App Launcher.
  2. Search for Vlocity Product Console and click the link.
  3. Click + icon next to the Rules Set item in the menu.
  4. Enter the following required information. For anonymous users (example):
FieldDescription
NameDC_RULE_FIBER_AVAILABLE
Rule TypeQualification
Rule PurposeEligibility
Expression Modeor

For logged-in users (example):

FieldDescription
NameDC_RULE_MEMBER_STATUS
Rule TypeQualification
Rule PurposeEligibility
Expression Modeor

You can create a single rule set by combining rules for Fiber and MemberStatus by applying expression mode or and executing it using a URI to pass two different context parameters separated by a comma. For an anonymous user, an example is: /services/apexrest/vlocity_cmt/v3/catalogs/MOBILE/offers?context={"DC_RULE_MEMBER_STATUS":"Gold","DC_RULE_FIBER_AVAILABLE":"True"}. You can pass two or more dimension parameters as part of the API request. You can also create a rule set that calls two different rules that point to two different context dimensions, in this case, Fiber and Member Status. When you call the URI, you could pass only one dimension name, Fiber, and not Member Status, andthat will satisfy the rule. If you have two or more context dimensions defined with an OR condition but you pass just one of them in the request body, then the defined default value is used for the other context dimension. If you write a URI for Member Status and Fiber Available = True, but there is no value for Member Status, then do not include the parameter value so Digital Commerce does not try to process the null value. Instead, Digital Commerce uses the specified default value for the context dimension value. If you have defined the default value for DC_RULE_FIBER_AVAILABLE as True, then the request URI skips passing the DC_RULE_FIBER parameter.

  1. Click Save.
  2. Click the Children Rules facet.
  3. Click New Child Rule.
  4. Add the rule and the sequence.
  5. Click Save.
  6. Add more child rules as necessary according to the previous steps.

Perform the following steps to apply the rule set to the product.

  1. Click App Launcher.
  2. Search for Vlocity Product Console and click the link.
  3. Click the Search icon next to the Product item in the menu.
  4. Search for Fiber Broadband 100 and open it.
  5. Click Context Rules.
  6. Click Add Rule Set and search for the DC_RULE_FIBER_AVAILABLE rule.
  7. Repeat the above steps for the DC_RULE_MEMBER_STATUS rule.
  8. Click Save.

Before testing the API, you must first run the Populate API Cache job or run theRegenerate Cached API Records job if you are making changes to an existing productcatalog. Perform the following steps to test the API.

  1. Navigate to Postman.
  2. Check to Agree to terms of service.
  3. Click login with Salesforce.
  4. Select Utilities→REST Explorer in the top menu.
  5. Leave GET as HTTP selected method.
  6. Enter the following URL for anonymous users (example).

/services/apexrest/vlocity_cmt/v3/calatogs/FIBER/offers?context={"DC_RULE_FIBER":"true"} Here accountStatus and AccountSLA have an OR condition with each other, so wecan pass either one of these parameters or both. /services/apexrest/vlocity_cmt/v3/calatogs/FIBER/offers?context={"AccountStatus":"Active"} /services/apexrest/vlocity_cmt/v3/calatogs/FIBER/offers?context={"AccountSLA":"Gold"} /services/apexrest/vlocity_cmt/v3/calatogs/FIBER/offers?context={"AccountStatus":"Active","AccountSLA":"Gold"}

The default value is chosen if you create a rule set with two rules pointing to two different dimension names and only one dimension parameter is passed when invoking the API.

For logged-in users (example): /services/apexrest/vlocity_cmt/v3/calatogs/FIBER/offers?context={“AccountID”:“xxxxx”}&isloggedin=true /services/apexrest/vlocity_cmt/v3/calatogs/FIBER/offers?context={“AccountID”:“xxxxx”,"AssetStatus":"Active"}&isloggedin=true You are specifying the context map in the URL.

  1. Click Execute.

If fiber technology is available, the API returns a list of products including the Fiber Broadband 100 product and a special reduction in price that is only available for known users who are Gold members.

Similar to the way in which we have created rules to determine the eligibility of products, you can also determine the eligibility of a promotion or qualify for specific price list entries by applying a context eligibility rule. However, applying acontext eligibility rule for a price list entry is only available for known user browsing specific to the getOfferDetails API and the price list entry is returned as part of the results.