Contact Log in

Enforce Rule

The Enforce Rule step creates a branch in the workflow. Rules in a workflow are evaluated from left-to-right, and the first rule that passes will have Thankful continue down that branch.

Adding any Enforce Rule step automatically adds an “else” branch which occurs only when no rule passes.

Note: Since Thankful will mark a ticket as resolved when it completes all steps in a workflow, you must explicitly add “Transfer” steps to all else branches that you don’t want Thankful to handle.

Rules have the form of:

IF x = y

Valid comparison operators include:

=
!=
>
>=
<
<=
CONTAIN (for arrays of strings)
STARTS_WITH (for strings)

Types that can be used in memories include:

Arrays of strings
string
bool
time (RFC3339 format)
number (int, float)

NULL does exist as its own keyword and can be used to check for emptiness with IF x = NULL or IF x != NULL.

You can use memories in rules. A memory is required on at least one side of the comparison operator. Memories must have the same type, so numbers must be compared with numbers, times with times and so on. For example:

Valid:   IF myNumber = 1
Valid:   IF myNumber = otherNumber
Invalid: IF 1 = 1
Invalid: IF myNumber = myString

You can search for values within arrays of strings with the CONTAIN keyword, like so:

Valid:   IF myStrings CONTAIN "hello world"
Invalid: IF string CONTAIN "hello world" -> you should use = instead of CONTAIN

Relative Times

In customer service, you’ll often care about how recent something happened to enforce SLAs and other time-based policies. Thankful’s support for relative times in the rules engine makes this simple.

The following are examples of rules using relative times:

IF order.created_at > 14 DAYS_AGO
IF order.created_at = 0 DAYS_AGO
IF order.preorder_date < 14 DAYS_FROM_NOW

You can compare any dates in RFC3339 format, which looks like this:

2020-01-30T00:00:00Z

You can also compare relative times against the number of US Business Days by prepending each “DAYSAGO" or “DAYS_FROM_NOW” with "US_BIZ”. For instance,

IF order.created_at > 14 US_BIZ_DAYS_AGO

US business days factor in major US holidays as well as weekends which might impact shipping timeframes.

If you need to check on a short timeframe, you can also use the same pattern for HOURS, with HOURS_AGO and HOURS_FROM_NOW.

Counting and Significant Events

Many times you’ll want to engage in a different behavior if something has happened a certain number of times before, like if a customer has written in about the same thing previously.

For this, you can use Track Event steps to record when something happens, then count the number of times that event has occurred using rules like so:

IF COUNT myEventName > 10
IF COUNT myEventName.myValue > 5

Events have both a name and value, so you can specify if you want all events by that name, or just events with a specific value.

You can also count events over just a recent period of time, like this to track the number of times myEventName happened within the past 3 days:

IF COUNT myEventName OVER 3 DAYS_AGO > 10

Sometimes you won’t care about a specific number of times something has happened, but instead want to know when there’s been a statistically significant spike or dip. You can do that in the following way:

IF SPIKE myEventName = TRUE
IF DIP myEventName = TRUE
Ask Support