Data Chain
In order for a flow's operations to track and access the same data, each flow creates its own data chain. Every operation has access to this data chain and each operation appends some value onto this object after it runs. This means you can dynamically access data from a previous operation or trigger in the current operation with data chain variables.
Each flow creates its own JSON object to store any data generated. When the flow begins, four keys are appended to the data chain: $trigger
, $accountability
, $env
, and $last
.
Then, as each operation runs, it has access to this data chain. Once an operation finishes, its data is appended under
its <operationKey>
. When the operation doesn't generate data, null
is appended under its key.
The following is an example of a data chain.
{
"$trigger": {},
"$accountability": {},
"$env": {},
"$last": {},
"operationKey1": "A value",
"operationKey2": {
"nestedKey": ["nested val", "nested val 2"]
},
"operationKey3": null
}
The keys contain the following information.
$trigger
— Contains data generated by the flow's trigger. This could include headers, access tokens, payloads, etc. Every data chain has a$trigger key
.$accountability
— Provides details on who/what started the flow. This could include user's id, role, ip address, etc. Every data chain has an $accountability key.$env
— Environment variables allowed inFLOWS_ENV_ALLOW_LIST
. This could include PUBLIC_URL, PORT, etc. Every data chain has an$env
key.$last
— The value appended under $last changes after each operation. It stores data of the last operation that executed in the Flow. Every data chain has a$last
key.
Operation keys will contain the data (if any) generated by the first operation. If none, null
will be appeneded. It will also be common to have nested JSON data.
Real-life examples of data chains and their data structures will vary, based on your Flow's unique configuration.
Data Chain Variables
While configuring your operations, you can use keys from the data chain as variables to access data. The syntax to do so is as follows:
"{{ $accountability }}"
This will get the data nested under the $accountability
key, producing something like this, for example:
{
"user": "4b11492d-631d-4b8a-bca7-2beasdfadf58b",
"role": "12c79228-5361-4905-929b-d69d3w46trs6b",
"admin": true,
"app": true,
"ip": "127.0.0.1",
"userAgent": "Amazon CloudFront"
}
You can mix your own hardcoded JSON alongside variables. You can also use dot notation and array indexing to retrieve nested values:
{
"key0": "a hard-coded value",
"key1": "{{ $trigger.payload }}",
"key2": "{{ operationKey.payload.friend_list[0] }}"
}
Certain operations use dropdowns, toggles, checkboxes, and other input options. However, you can bypass this entirely to input raw values directly with Toggle to Raw Editor.