Shape the routing with the DOMS Toolkit
The DOMS Toolkit allows you to create customized routing rules by providing you with tools to evaluate the content of the orders and the network of affiliates, and make decisions accordingly.
This page is outdated. Please go to our new documentation under https://docs.fulfillmenttools.com/documentation.
How to define a toolkit fence
In the following we will explain in detail what each field does and how to use it. Almost all of these steps will apply to building a toolkit rating so if you're interested in how a toolkit rating works, please don't skip this section!
ToolkitFence fields in detail
Defining the actual rule
To define a rule you have to pick exactly one of the following.
rule
The setup for a conditional rule. Incompatible with using the comparisonRule field. Use this if you want to compare each side against a fixed value (e.g. order line item quantity > 3)
comparisonRule
The setup for a comparison rule. Incompatible with using the rule field. Use this if you want to compare the left side directly with the right side. (e.g. order brand == facility brand)
How to define a conditional rule
Conditional rules test a certain property of an entity (Order
, Facility
) against a pre-defined static value.
How to define a comparison rule
Comparison rules are very different to conditional rules in that a certain property of the left-hand side (Order
) can be compared to a certain property of the right-hand side (Facility
).
An example of this could be an order with articles of a certain brand demanding a facility tagged with the same brand.
How to define a toolkit rating
This setup works largely the same as the setup of a toolkit fence with a few key differences.
Differences to toolkit fences
order
-> since all ratings get evaluated either way the order field does not exist for ratingsmaxPenalty
-> the penalty which determines the weight of the rating in comparison to other ratingsThat aside toolkit ratings follow the exact same syntax as toolkit fences
Intro to JSONPath
It always begins with $
referring to the entity, followed by a path to the nested property. (e.g. $.orderLineItems[*].quantity
) Used in:
Intro to transformers
Transformers allow to modify the input of a ToolkitPredicate
before it gets evaluated. This can serve multiple purposes, maybe you only want to look at the number of elements, get the total price of all OrderLineItem
s or just want to consider the beginning of the tenantOrderId
.
These are the transformations currently available in the platform.
SUM
: sums the number values of each element - requires an array of elementsCOUNT
: counts the number of elements - requires an array of elementsSUBSTRING
: gets a substring of a value, requiresstart
andend
parametersLAST
: gets the lastn
chars of a string - requiredlength
parameter
Count Transformation
Applies to orders with 10 OrderLineItems
or more.
Sum Transformation
Applies to orders where all OrderLineItems
in sum have a total quantity of 100.
Substring Transformation
Applies to orders where any OrderLineItem
has a tenantArticleId
that begins with "Coca".
Last Chars Transformation
Applies to orders where any OrderLineItem
has a tenantArticleId
that ends with "Christmas Special"
Examples:
Scenario 1, routing orders to a facility located in the same area as the customer.
In this scenario we received the task of routing orders based on the user's location. Our customer has a very specific use case, where the order from customers located in the zip codes 50xxx and 51xxx should be routed to facilities located in the same areas (both areas are valid regardless of which zip is used).
The first step would be to create a Fence in our system by using the API. We use the API endpoint /api/configurations/routing/toolkit/fences
like in the following example:
The interpretation of this Fence would be:
Orders from zip code areas beginning with 50 or 51 must be routed to facilities in zip code areas 50 or 51.
Some details in the example:
The Fence rule consists of two parts, the left part processes the information contained in the order (entity1), and the right part processes the information contained in the facility (entity2). Left part and right part are connected with the operator EQUALS, which means that if the result of evaluating the left part is true then the result of evaluating the right part has to evaluate to true, and analogously when the left side evaluates to false
The left part consists of two predicates connected with the OR predicate evaluator. The predicates are similar, as they take the value of the postalCode property of the consumer's address.
Both predicates have a transformation, which means that after getting the value of the postalCode, and before evaluating the predicate, this postal code is transformed by using the SUBSTRING transformation. In this case, the first two digits are extracted.
Then, for this extracted values, they are compared by using the entity operator, in this case VALUE_EQUALS. This would be interpreted as, "if the extracted value equals the expected value, then this predicate is evalued to true".
After evaluating the two left-side predicates individually, they are evaluated as a whole using the predicate operator OR.
Analogously, the right-hand side of the rule is evaluated. The result of evaluating the right side and the left side are evaluated again by using the rule operator EQUALS.
Suppose we have an incoming order for an user that is located in an area with postal code 51379, and the fence is evaluating a Facility located in an area with postal code 51355. When evaluating this combination from order and facility with the fence specified above would be:
LEFT PART PREDICATE 1 EXTRACTION
51379
51355
RIGHT PART PREDICATE 1 EXTRACTION
LEFT PART PREDICATE 1 TRANSFORMATION
51
51
RIGHT PART PREDICATE 1 TRANSFORMATION
LEFT PART PREDICATE 1 EXPECTED VALUE
50
50
RIGHT PART PREDICATE 1 EXPECTED VALUE
LEFT PART PREDICATE 1 EVALUATE EQUALS
FALSE
FALSE
RIGHT PART PREDICATE 1 EVALUATE EQUALS
LEFT PART PREDICATE 2 EXTRACTION
51379
51355
RIGHT PART PREDICATE 2 EXTRACTION
LEFT PART PREDICATE 2 TRANSFORMATION
51
51
RIGHT PART PREDICATE 2 TRANSFORMATION
LEFT PART PREDICATE 2 EXPECTED VALUE
51
51
RIGHT PART PREDICATE 2 EXPECTED VALUE
LEFT PART PREDICATE 2 EVALUATE EQUALS
TRUE
TRUE
RIGHT PART PREDICATE 2 EVALUATE EQUALS
EVALUATE BOTH PREDICATES WITH OR
TRUE OR FALSE -> TRUE
TRUE OR FALSE -> TRUE
EVALUATE BOTH PREDICATES WITH OR
TRUE or TRUE -> TRUE
Result of the Rule evaluation
TRUE
Result of the Rule evaluation
and the facility will be retained as candidate for the routing, because the fence evaluated to true.
Scenario 2, directly compare values of the entity on the left with the entity on the right.
In this scenario we will ignore the evaluation of the left side and the right side of the rule, to perform a direct comparison of values of the entity on the left with the right entity, to handle the following scenario:
Orders with order line items containing a tag with id "CATEGORY" should be routed to facilities that have the same category. Available categories are "DANGEROUS_GOODS" and "SAFE_GOODS".
We create the fence in our system by using the following request:
Suppose we have an incoming order with an order line item that has the tag {id:"CATEGORY",value:"DANGEROUS_GOODS"}, and we have to facilities, (1) the first which has the tag SAFE_GOODS and (2) the second which has the tag DANGEROUS_GOODS
When evaluating the Fence for the (1) first facility, the following will happen:
the fence will consider the order and take the value of the orderLineItems.tags[*].value, in this case, the value "[DANGEROUS_GOODS]".
the fence will consider the facility take the value of the tag "tags[*].value", in this case for facility (1) it is "[SAFE_GOODS]".
then it will apply the entity operator "RIGHT_CONTAINS_LEFT". Because the value "[SAFE_GOODS]" does not contains "[DANGEROUS GOODS]", the fence will evaluate to false, and this facility will be discarded.
When evaluating the Fence for the (2) second facility, the following will happen:
the fence will consider the order and take the value of the orderLineItems.tags[*].value, in this case, the value "[DANGEROUS_GOODS]".
the fence will consider the facility take the value of the tag "tags[*].value", in this case for facility (1) it is "[DANGEROUS_GOODS]".
then it will apply the entity operator "RIGHT_CONTAINS_LEFT". Because the value "[DANGEROUS_GOODS]" is contained in "[DANGEROUS GOODS]", the fence will evaluate to true, and this facility will be retained as candidate.
Note: In case the order has many order line items containing many different tags, then all of them will be evaluated and compared with the values from the right part.
Reference
Find the full specification of the toolkit configuration endpoints in our fulfillmenttools API
You can find the JSONPath documentation here
A helpful tool for testing JSONPath expressions can be found here
Last updated