Creational – Flag Mechanism

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.


  • Expressions – flag text is normally created as a string concatenation inside an expression
  • String concatenation – flag text can be formatted using string concatenation formatting
  • Object Specific – A flag can be created as an Instance including Meta Data

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 Concept

To 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.
One way to setup a model to produce flags is to create a new concept tied with a relationship to the subject concept of your main query:

Figure 2: Setting up the Flag concept

The 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!
An object specific flag will be shown if a specified object-specific relationship instance is created at runtime by Rainbird. To create an object-specific flag, open up the relationship where all the rules for the flags will sit, and click ‘Add Rule’. Next, add the relationship instance that contains the specific object you want to flag as a condition of the rule:

Figure 3: Condition if chosen industry is Blue Collar

Then, 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 expression

You 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).
Flags can surface concept instances users select/enter at runtime and use these in flag text. Follow the steps to make the object-specific flag, but do not specify the object of the relationship you want to flag:

Figure 5: A flag rule applying for all Instances of Industry

The 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 expression

Rainbird will now use the concept instance the user selects at runtime in the flag text:
Rainbird can surface multiple concept instances in a flag. You can even add the subject of the query to the flag text. All you need to do is add the relationships that contain the concepts you want to surface in flag text to the rule which will create the flag:

Figure 7: Expanding the String Concatination

Rainbird will now surface multiple concept instances in the flag text:

Figure 8: Flags showing multiple facts

Combining multiple conditions can be used to create summary flags, which can provide context as to why Rainbird has made a decision:
Flags will typically be displayed alongside the results of a query to provide context as to why Rainbird has made a decision. The relationship that produces the flags needs to be combined into one relationship with the relationship that Rainbird will query to produce a result. First, create a new concept to act as an ‘Overall outcome’ concept. The subject of the main query should be linked with a relationship to the ‘Overall outcome’ concept:

Figure 9: Including flags in overall outcomes

Next, 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 %O

Create 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 decisions

The 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 1

Now 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

Article Feedback form
Did you find this article useful?

Version 1.02 – Last Update: 19/02/2021