We're updating help docs to reflect our new product naming. Gladly Sidekick (AI) is now called just Gladly, and Gladly Hero (the Platform) is now Gladly Team. Some articles may display outdated names while we update everything. Thank you for your patience! Learn more

Rules Sort Order Importance

Prev Next

How Rules are sorted on the Rules page has significant importance. Rules execute based on the Trigger from a particular event, and If an event matches a Rule Trigger, then the rest of the Rule (Conditions and Actions) are evaluated and applied. Because you can have multiple Rules in place, you can create an order of priority in which you can decide which Rule takes precedence before the second, third, fourth (and so on) Rule.

How to approach ‘Sort Order’

Think of your Rules list as a pyramid. The most restrictive Rules, those with the most specific Conditions that affect the fewest Conversations, should be at the top. The broadest, most general Rules should be at the bottom.

As Rules evaluate from top to bottom, each layer of the pyramid peels off a specific subset of Conversations. What remains continues down the list until it reaches the broadest catch-all Rules.

Example: Auto-reply Rules

Suppose you have three auto-reply Rules:

Sort Order

Rule

Conditions

1

Auto-reply for Returns

Message body contains "return"

2

Auto-reply for Exchanges

Message body contains "exchange"

3

Generic Auto-reply

No keyword Conditions

In this order, Conversations containing "return" receive the Returns auto-reply, Conversations containing "exchange" receive the Exchanges auto-reply, and everything else receives the generic reply.

If you reversed this order and placed the generic auto-reply at position 1, every Conversation would match the generic Rule first. Because only the first auto-reply Rule fires, the Returns and Exchanges auto-replies would never execute.

Always move new Rules into the correct position after saving. When you save a new Rule, it is automatically assigned the next Sort Order number and placed at the bottom of the list. If you leave it there, a less restrictive Rule above it may already be handling the Conversations you intended the new Rule to catch.

How 'Sort Order' is configured

The Sort Order field only appears after a new Rule is saved. Edit the Rule to see the field. The Sort Order number is automatically added based on the number of Rules you currently have. For example, if you have 30 Rules, a newly added Rule will have "31" in the Sort Order field.

A Rule with a Sort Order of "1" appears at the top of the list and is evaluated first for every event.

Editing rule settings with highlighted sort order and active toggle options.

You can also change the sort order by dragging and dropping a Rule on the Rules page. The Rule on top of the list is "1" in the sort order.

How Rules are evaluated

Events are evaluated against the entire list of Rules, starting with the first Rule on top of the list, all the way to the end but excluding any Rules that have been deactivated. Keep in mind that all Rule Conditions are evaluated at once. Only then will Actions be executed for the Rules that have matched. This means it evaluates all Rules + executes all Rules, not evaluate Rule 1 + execute Rule 1, evaluate Rule 2 + execute Rule 2, etc.

When multiple Rules match the same Trigger, the Rule with the highest sort order (closest to 1) takes precedence for exclusive Actions. This applies to Inbox assignment, Agent assignment, and auto-reply — only the first matching Rule for each of these Action types will execute. However, non-exclusive Actions like Add Topics are cumulative: if multiple matching Rules each add a different Topic, all of those Topics will be applied.

In the sample below, there are seven Rules for this organization. Let's say an applicable event (like receiving a new email) happens; then the following Rules will be evaluated and vetted in this exact order all at once:

List of rules for task evaluation and assignment in a communication system.

  • Rule 1 (New Conversation) - Evaluate

  • Rule 2 (Conversations older than five days) - Evaluate

  • Rule 3 (Mail Reassignment | No DH | Overdue) – Skip (the Rule and any related Actions ignored)

  • Rule 4 (Task Assignment | Away) – Evaluate

  • Rule 5 (Messaging Assignment | No DH | Agent logout) – Evaluate

  • Rule 6 (Communication with auto-reply) – Skip (the Rule and any related Actions ignored)

  • Rule 7 (Task Reassignment | No DH | Overdue) – Skip (the Rule and any related Actions ignored)

Actions (within the Rule) are completed when a Rule is evaluated, and a match is made. Even though Rule 3, 6, and 7 are sorted with priority, they won't be included in the evaluation process because they are deactivated.

Closing Conversations with Rules

Once a Conversation is closed by a Rule, no further actions are applied to that Conversation. This means Rules sorted after the 'Close Conversation' Rule will no longer apply. For example, if Rule 1 closes a Conversation and Rule 3 adds a Topic to a Conversation then Rule 3 would not be evaluated because Rule 1 executed. However, if the Rule sort order is reversed such that the Rule to add the Topic is in the first position, the Rule to add a Topic would be evaluated.

Duplicate Rules

Duplicate Rules are ignored. So if you have duplicate Rules that perform the same action, where those Rules are in the sort order, it dictates which one fires and which is ignored. For example, if you have two Rules that assign an Inbox to an email Conversation, the Rule with the higher sort order (closer to 1) fires.