[Video: Short explainer on how to create rule groups. Once you've watched the video, jump here for a quick recap]
What are rule groups?
Like standalone rules, rule groups can be built in the Edit connection sidebar in either Flowchart or List view.
However, unlike standalone rules, rule groups enable builders to isolate sets of rules much like how brackets group equations in algebra. This allows builders to apply multiple sets of rules that work either separately or in combination with one another.
Example: Intake bot
As an example of when you might build rule groups, let's take an intake bot that determines whether an end-user can receive legal help from a Legal Aid Organization.
The Legal Aid Organization may not be able to help people if they are under 18 years old. However, if an end-user is severely disadvantaged, there may be an exception in the Organization’s mandate that states they must assist.
Once the bot has collected the user's age and eligibility, a message connection may feature the following rule groups:
- Group 1: If the person is over 18, we can help.
- Group 2: If the person is under 18 and severely disadvantaged, we can help.
The rule groups would look something like this.
[Image: Two rule groups applied to a single message connection with the Any/All toggle switched to Any]
[Image: Group 1 containing a single rule where "2. Age" [is] "Over 18"]
[Image: Group 2 containing two rules where "2. Age" [is] Over 18 AND "3 Social advantage" [is] "Severely disadvantaged"]
Here, the rule groups enable the bot to manage the conflict surrounding the end-user's age. They take both circumstances into consideration, whereas if the builder had just used standalone rules, this would not have been possible since the two eligibility criteria would have
- Caused the bot to break, or
- Led to all under 18s receiving unmandated help.
Create a rule group
Here's how to create a rule group.
- In List view or Flowchart, select the relevant message connection and open the Edit connection sidebar.
- Next to Add rule, click Add group.
- By default, a rule group cell will be entitled Group 1. Click it.
- The rule group tab will open.
- Hint: To rename the group, click Group 1 at the top of the sidebar and input a new title.
- Next, click Add rule and insert the relevant rules.
- Watch the walkthrough video to learn how.
- Once applied, be sure to toggle the Any/All toggle correctly. This will determine how the rules within a group relate to one another.
- To exit Group 1, click the left arrow in the top-left of the sidebar. This will take you back to the entirety of the connection's rules.
- Like before, check the Any/All toggle applied to the overall rule equation is toggled correctly.
- Like #6, this will determine how all the individual rules and groups relate to one another. Learn more.
Example: Sorting apples
In the video at the top of the article, we have a bot that utilises rule groups. Here's a quick recap of how the rule groups were implemented.
Responding to messages featuring single-choice text response types, the user can choose from either "Red" or "Green" and "Large" or "Small" apples.
The end goal of this bot is to:
- Discard "Small", "Green" apples because they’re unripe, and
- Keep all "Large" and "Small" "Red" apples, as well as "Large" "Green" apples.
To achieve this, we apply the following rules to each connection.
Message connection 1: "Size" to "Keep"
Aim: keep ripe apples
Any/All toggle = Any
- Color [is] Red
- Group 1 (Any/All toggle = All)
- Color [is] Green
- Size [is] Large
Note: In Group 1, all rules need to be met but by switching the Any/All toggle to Any in the overall rules page, either Red or Group 1 can be true.
Message connection 2: "Size" to "Discard"
Aim: discard unripe apples.
Any/All toggle = All
- Color [is] Green
- Size [is] Small
Note: Here both standalone rules need to be met, so we've switched the Any/All toggle to All.
Together, these two message connections (containing rule groups) ensure only the right apples are kept and discarded.
Got a question? Contact us at email@example.com.