Output Attributes in Alloy are essential components used to store and manipulate data within Workflows and generate custom values.
Output Attributes are derived from a calculation within the Workflow; it can be any combination of outputs of upstream nodes (Input Attributes, other Output Attributes, Matrix Models, Tags, third party Service nodes), and integers using basic mathematical operators and nested grouping. They can be either regular Output Attributes, which are specific to a single workflow, or Published Output Attributes, which are stored on the Entity profile to be used in future scenarios without having to re-calculate the same Output Attribute.
Output Attributes have a wide variety of use cases. For example, an Underwriting Workflow may use Output Attributes to calculate a debt_to_income_ratio
, or a final_credit_line_assignment
for a client’s credit policy. This document provides a detailed overview of Output Attributes and their usage.
This article will cover the following sections:
- Identifying an Output Attribute node in a Workflow
- How do Output Attributes work
- Output Attribute Raw Response Schema
- Adding an Output Attribute
- Building Output Attributes Expressions
- Using jq with Output Attributes
Identifying an Output Attribute node in a Workflow
Output Attributes in a workflow are denoted by a blue node with an icon of arrow pointing to the right, exiting out of a bracket.
How do Output Attributes work
An Output Attribute expression is made up of one or more Workflow nodes, string, or number elements combined combined to produce an output value.
String Output Attributes tend to be used as a simple data storage. For example, storing the result of a data vendor’s response to be used in a follow-up Workflow.
Numeric Output Attribute expressions are generally combined with arithmetic operators to perform calculations. These calculations can involve hardcoded numbers, or integer and decimal values stored in other tags or Workflow nodes.
A simple expression may look like Sample Tag * 1
. In the Output Attribute expression editor, this would look like:
Output Attributes support running calculations on a given tag from the Workflow. When a tag is used within an Output Attribute calculation, its presence represents a value of 1
(indicating it has been set within the evaluation), and its absence represents a value of 0
(indicating it has not been set within the evaluation). In the previous example, if Sample Tag
was set, the expression would be simplified as 1 * 1
; if it were not set, the expression would be simplified as 0 * 1
. This allows use cases where a combination of tags should result in a certain action or outcome in the Workflow, or a weight assigned to certain tags to calculate risk factors.
Supported Data Types
When creating a new Output Attribute, there are three options for Data Types your Output Attribute can be saved as.
Data Type | Example | Use Case |
String Strings always represent text-based information, which include any form of letters, numbers, or other characters. Since string-types are considered text, they cannot have mathematical computation performed on them. In an JSON body, string-types are always wrapped in quotes. |
"this is an example" , "1"
|
Since string-types do not support mathematical computations, the most common use case is storing the result returned from another node or value returned from a data service response. |
Integers
Integers are always a whole number without a decimal. In a JSON body, integer-types are never wrapped in quotes. If they are wrapped in quotes, they are considered a string-type. |
1 , -1
|
(7 * monthly_grace_period) + (7 * seven_day_grace_period) |
Decimal
Decimals are always a floating number representing fractional part. In a JSON body, decimal-types are never wrapped in quotes. If they are wrapped in quotes, they are considered a string-type. |
1.2 , -1.2
|
0.8 * meta.reported_annual_income
|
Supported Expression Elements
The following list below covers the different types of elements that are supported when building an Output Attribute. The supported elements you can add into your expression will be dictated by the data type you’ve configured the Output Attribute to be. For example, if the data type of your Output Attribute is an Integer, you won’t be able to add in a string constant or a string attribute from a data service node.
- Input Attributes: Input Attributes are data imported into the workflow from the supplied data. The result of an input attribute can be stored as an output attribute for data passing, or included within the calculation if it’s an integer or decimal.
- Output Attributes: Output Attributes, which are results of calculated expressions, can be used within follow-up Output Attribute expressions as well.
- Data Service Attributes: The result returned for a given data service attribute can be used in a mathematical expression or can be stored in an Output Expression for data passing between workflows.
- Matrix Models: Matrix Models are a type of data structure used to organize and evaluate data in a tabular format, often involving multiple dimensions.
- Custom Model Nodes: Custom Models point to a Python model that can be hosted at Alloy or by the client. These are typically used for highly complex underwriting policies; rather that creating all of the logic in the Alloy Workflow, clients have the option to write part of this logic in Python and have the Alloy Workflow call out to it, receive the response, and continue the Workflow accordingly.
- Integers: Integers or numbers can be input directly into the expression editor.
- Strings: Any text can be inputted as a string directly into the expression editor.
Supported Arithmetic Operators
Output Attributes support some arithmetic operators — symbols that connect two or more expressions to generate an output based on a calculation. While Output Attributes support storing strings, mathematical operations should only be used if the expression contains numbers (integers or decimals) and the final output for the Output Attribute is an integer or decimal data type.
Output Attribute expressions are read from left to right, and follow the order of operations in math equations. For an expression, parenthesis are simplified first, followed by multiplication and division from left to right, followed by addition and subtraction from left to right.
The same order of operations are applied within parenthesis as well.
The following operators are supported to build an expression and control the order of operations.
Operator | Functionality | Example |
Group ( | Group specific parts of an expression together to control the order of operations. When a Group is opened with an open parenthesis
|
(1 + 3) * 2 |
* |
Multiplication
|
1.234 * 0 |
/ |
Division
|
2 / 1 |
+ |
Addition
|
1 + 1 |
- |
Subtraction
|
1 - 1 |
Output Attribute Raw Response Schema
Without Journeys
The output of all Output Attributes expressions will be stored in their own object in the Entity Application raw response within the models
object.
Sample models
object showing sample output attributes with varying data types:
{
"models": {
"risk_level": "LOW",
"risk_level_number": 1,
"final_score": 249,
"years_in_business": 2.199
}
}
Journeys without Final Reconciliation Workflow
For clients utilizing Journeys that do not have a final reconciliation Workflow configured, any Output Attributes that are defined in standard (non-reconciliation) Workflows uaws in the Journey are going to be surfaced in two places:
- Within
_embedded.entity_applications[].output.output_attributes
. Think of this as the “per Entity top-level” section. - Within the nested
_embedded.events[]...evaluation_result.models
section when you pass the?fullData=true
query parameter into your API call.
Journeys with Final Reconciliation Workflow
For clients utilizing Journeys, Output Attributes can also be imported into downstream Workflows in the Journey to be used in later logic.
Any Output Attributes that should be lifted up to the top level of a Journey Application raw response can be put there by using a Final Reconciliation Workflow and making an Input Attribute for the upstream Output Attributes. These will then instead appear in the terminal_reconciliation_output.output_attributes
object of the Journey Application response.
Sample terminal_reconciliation_output.output_attributes
object showing sample output attributes with varying data types:
{
"terminal_reconciliation_output": {
"output_attributes": {
"risk_level": "LOW",
"risk_level_number": 1,
"final_score": 249,
"years_in_business": 2.199
}
}
}
Adding an Output Attribute
To start adding an Output Attribute:
- Click the Add menu at the top right hand side of the Workflow builder.
- Select Output Attribute from the menu.
- Within the Add Output Attribute modal, fill out the fields.
- You can select New Attribute or Published Attribute. At this point, keep New Attribute selected to add a regular Output Attribute. Output Attributes are used in the context of the Workflow you are configuring it to whereas Published Output Attributes are stored on the entity profile to be used in future Workflows. Click to learn more about working with Published Attributes if you’d like to use a Published Attribute instead.
- Attribute Name: Fill out a custom name for the Output Attribute,
- Data Type: Select one of the data types from the drop-down.
- Publish this attribute: Check this box if you’d like this input attribute on the entity profile to be stored for decisioning in future Workflows. Additional options become available when enabling this setting. Click to learn more about Published Output Attribute settings if you’d like to use a Published Attribute instead.
- Once the attribute is configured, click Add Attribute.
Once an Output Attribute has been added, it will appear to the left-most column of the Workflow (this means that this node will always run). From here, the Expression drawer will slide out to start building the output expression.
Building Output Attribute Expressions
To provide the most flexibility and efficiency, the Output Attribute expression editor supports both mouse clicks and keyboard shortcuts.
When first adding an Output Attribute or clicking the node for an existing Output Attribute, the Expression drawer will open up. From here, you can begin building or editing an expression wherever there is a yellow box. A yellow box can appear on hover from your mouse as well.
Once the yellow box is clicked, the available options will display in the dropdown in the format of: node type
: node name
. You can scroll the drop down for your available node options, then click on your selection to add it to the expression; or you can type which node you’re looking for to narrow down the options.
The start of an expression must always one of the supported expression elements or a Group operator. Once added, the next part of the expression is an arithmetic operator. You can build as may layers as you’d like into the expression, but the following rules must always apply to ensure valid expression syntax:
- When a Group is opened with an open parenthesis
(
, it must be closed with a closed parenthesis)
- There can never be two nodes or numbers right after each other. A node or number must be followed by an arithmetic operator.
If an incorrect expression syntax arises, your Output Attribute may not function properly or store data properly.
Examples:
Example - Invalid | Example - Valid |
Group(1 * 4 |
Group(1 * 4) |
4 10
|
4 * 10 |
Using jq with Output Attributes
Output Attributes may allow calculations, but some times the result of those calculations need more complex data manipulation. For example, a credit policy may need the credit line assignment rounded to the nearest $100 or rounding a number to the nearest hundredth decimal point. Enabling jq for Output Attributes allows even more robust calculations.
Sample view of an Output Attribute configured with jq for rounding
To enable jq on an Output Attribute:
- After adding an Output Attribute, the Expression drawer should slide out. Or click on the blue Output Attribute node for an existing attribute you’re editing.
- Click on the Options menu in the drawer.
- Check the Parse with JQ? box.
- The JQ Formula editor will become active and can be used to write your jq formula.
- Click Save on the bottom-right of the drawer once your changes are complete.
- Don’t forget to click Save **in the Workflow to save the changes to a new version, otherwise the changes will be lost.
For more information on jq, the following resources are recommended:
Comments
0 comments
Article is closed for comments.