Creational – Flag Mechanism
When completing a query, Rainbird will typically return a result. Rainbird can also return contextual information about the parameters of the query-we call these bits of contextual information ‘flags’.
Flags can be used to provide an explanation as to why a decision has been made, or just to provide the end-user some information about the parameters they may have selected whilst running a query. Flags can be set phrases, and they can also bring in contextual information entered at runtime to provide even more detail about the query.
Flags are best used in knowledge maps where you would want to notify the user about the parameters of a query but want to provide more detail than the standard Evidence Tree provides.
For example, if Rainbird were to be used to power a sales qualification tool, Rainbird could flag parameters of the deal that might require careful consideration; if Rainbird was being used as a loan application tool, Rainbird could flag reasons why an applicant may have been successful or unsuccessful.
- Typically, Rainbird will display flags in the same order as the flag rules are ordered in the flag relationship. However, sometimes Rainbird will display flags out of order.
- Depending on the certainty factor of the flags, on the result screen, some flags may be shown before the intended result of a query. To combat this, the certainty factor can be set to 1 so that the flags display underneath the results of a query.
- Rainbird will not display metadata text related to flags; because of this, flag text needs to be created as concept instances or expressions.
Flags will typically be created on their own relationship and then brought together with a model’s main relationship into an ‘overall’ relationship. The rule that creates the flags will normally have a condition that when fulfilled will create a flag, as well as the flag text in the form of a string concatenation:
Figure 1: model base structure, double triangle and Flag ConceptTo demonstrate how flags work, we’ve built a small model that will qualify a sales lead as ‘hot’ or ‘cold’ depending on the parameters the user selects at run time. Rainbird will also produce some flags about the parameters of the deal. Let’s take a look at some of the different ways flags can be set up.
Figure 2: Setting up the Flag conceptThe rules which will generate the flags will sit on the relationship between the subject concept and the ‘Flag’ concept. As we don’t want Rainbird to ask the user a question about what flags to display, we turn questions on the relationship to ‘Off’. The relationship is also set to ‘Plural’, to allow Rainbird to generate multiple flags. Now we’re ready to create our flags!
Figure 3: Condition if chosen industry is Blue CollarThen, click ‘Add Expression’, and type in the text you want to display on the results screen if the specified relationship instance is created at runtime:
Figure 4: Adding the flag text in an expressionYou will need to assign the expression to %O so that it displays as an outcome and enclose the flag text in ‘ ‘ (for more information on how to format text in expressions, check out our guide on string concatenation here).
Figure 5: A flag rule applying for all Instances of IndustryThe concept name (e.g. %INDUSTRY) can be added to the expression box and used in string concatenations. The concept should not be enclosed in ‘ ‘ and concept names and new strings of text will need to be separated by + signs:
Figure 6: Adding the flag text in an expressionRainbird will now use the concept instance the user selects at runtime in the flag text:
Figure 7: Expanding the String ConcatinationRainbird will now surface multiple concept instances in the flag text:
Figure 8: Flags showing multiple factsCombining multiple conditions can be used to create summary flags, which can provide context as to why Rainbird has made a decision:
Figure 9: Including flags in overall outcomesNext, open the new relationship you just created. Two rules need to be created: one containing the relationship that Rainbird will query to produce a result, and one containing the relationship Rainbird will query to produce the flags. In each rule, the object of the condition needs to be assigned to %O so that Rainbird will display the object as a result of the query. To do this, underneath the condition, add the object concept name as an expression and assign the value to %O:
Figure 10: Assign overall Lead Status to %OCreate another rule on the overall decision relationship to call any flags that you’ve set :
Figure 11: Add the deal with have flag rules to overall decisionsThe overall relationship should be set to plural, so that Rainbird can display the result of the query as well as the flags: You may want to set the certainty of the flag rule (as well as the minimum certainty of the flag rule) to 1 so that the flags display underneath the result:
Figure 12: Setting Certainty for flags to 1Now Rainbird will display the result of the query, along with any corresponding flags, when running the ‘overall’ relationship:
The RBLang below will generate the example map used in the ‘subject’ section of the article. Click on ‘Export .rbird’ to download the knowledge map, or ‘copy RBLang’ and paste the code directly into Rainbird.
Query & Results
The combined rule is built on the ‘get recommendation combined’ relationship
Version 1.02 – Last Update: 19/02/2021