Contact Log in


What if you want:

Thankful’s rules engine enables you to customize Thankful’s behavior for these use-cases and more by defining custom rules. We’ve designed rules to be easy for any non-programmer to write, yet powerful enough to give managers the fine-grained control they need.

By the end of this guide, you should feel comfortable enough to customize Thankful’s behavior by writing your own rules.

Important Note: Thankful’s rules engine is case-sensitive, meaning Thankful sees, for example, IF and if as two, completely different things. Ensure that your rules are in the case as described in this documentation.


Rules always take this form:

IF condition

Conditions are parts of rules which determine whether the action should be performed. When the condition evaluates as true, the steps below that rule will be performed.

The following are examples of valid conditions:

IF size = "large"
IF name != ""
IF RAND < .5 AND order.created_at < 14 DAYS_AGO

Conditions may consist of the following parts:


Left and right operands may be one of the following:

Comparison Operators

Comparison operators define when a comparison is to be considered true and the rules, therefore, active. The following are all the comparison operators which may be used:

Joining Conditions

Rules may have several conditions to meet before being acted upon. For example, the following is a valid rules:

IF order.created_at < 14 DAYS_AGO AND order.shipments.length >= 1

The following keywords may be used to join conditions:

Testing for existence

NULL indicates whether a memory has been set. To test if a memory exists, you’d write:

IF order != NULL

Whereas to test if it’s empty, you’d write IF order = NULL


Thankful provides several ways to interact with arrays.

To get a specific item out of an array, use the notation yourArray[i] where yourArray is an array in Thankful’s memory and i is the index.

Arrays are zero-indexed. To get the first item out of an orders array, you’d write: orders[0]

You can also access the last item in an array:


To get the second-to-last item, you’d write orders[-2].

JSON data

You can interact with JSON data directly in rules using dot notation. For example, given this data stored in the order memory:

	"id": 1,
	"number": "#123",
	"shipments": [{
		"id": 99,
		"shipped": true

You can access the id using Similarly you can access shipped (which is inside an array) using order.shipments[0].shipped.

Times and relative dates

Thankful lets you compare relative dates in RFC3339 format. For instance, given the memory order containing:

	"id": 1,
	"created_at": "2018-10-01T12:30:00Z",
	"shipping_at": "2018-10-14T00:00:00Z"

You can write rules like any of the following:

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

Need Help?

Rules are one of Thankful’s more advanced capabilities. If you need any help, contact our support team at and describe the rules you’d like to write–we’ll help you through it!