Overview
In this article we'll go over the ways you can reference action event data as it flows through your story. Specifically, we'll take a look at how you can map this output data from one action into subsequent actions. You'll hear this commonly referred to as "upstream events" or "upstream event data."
Tines references
Before getting started, we recommend familiarizing yourself with the surrounding functionality this article covers:
Make it happen
We'll use the following sample of a "Get User Info" action's event data that kicks off a story:
{
"user": "Jane Tino",
"email": "jtino@tines.io",
"usernames": [
{
"value": "jtino",
"is_active": true
},
{
"value": "jane_tino",
"is_active": false
}
]
}
Basic
Throughout these options, let's grab the user's email from the"Get User Info" action's event data. When referencing upstream event data, the JSON path will always start with the referenced action's name in snake case format (i.e. Get User Info → get_user_info
).
⚙️ Option One: Type it out
Within your subsequent action, navigate to where you want to reference the upstream data. In our example, this will be within the Payload.
Click + → Value (shortcut:
cmd + space
|ctrl + space
)Write out the JSON path with your keyboard:
get_user_info.body.email
As you type out each segment, Tines will try to suggest the next part of the JSON path.
Reference the "Results" on the bottom-right to confirm the data element you are targeting. In our example, this will be:
"jtino@tines.io"
.
⚙️ Option Two: Click through the path
Within your subsequent action, navigate to where you want to reference the upstream data. In our example, this will be within the Payload.
Click + → Value (shortcut:
cmd + space
|ctrl + space
)Click on the action name you want to get the data path for in the formula widget. For this example, this would be:
get_user_info
Each time you click on the element it will auto-fill. This is similar to option one via typing, however, this method tends to be quicker:
get_user_info.body.email
Note: You will need to ensure that a
.
is between each value. You can do so by clicking twice between each.
Reference the "Results" on the bottom-right to confirm the data element you are targeting. In our example, this will be:
"jtino@tines.io"
.
Tines Tip: Instead of clicking, you can also go through the JSON path by pressing enter
/return
!
⚙️ Option Three: From the Events panel
Locate the upstream event data that you want to map the data from.
Go upstream to the desired action.
Open the Events panel of that action.
Navigate to the part of the data you want by clicking the "..."
While hovering over the object, click on the copy icon that appears on the left-hand side. This will copy the specific JSON path.
Navigate to your subsequent action + where you want to reference the upstream data. In our example, this will be within the Payload.
Execute a paste (
cmd + v
|ctrl +v
).See your Value pill with the copied JSON path configured.
Tines Tip: When referencing JSON paths from upstream actions, you will need event data to be able to review the output preview in the "Results" on the bottom right of the formula widget. Without it, the "Results" view will show as empty, or sometimes null
.
Advanced
⚡️ Arrays - Static referencing
Take a look at the usernames
array in our "Get User Info" action. Let's say we want to capture the jane_tino
username. We can see that jane_tino
is part of the 2nd object in the array. So, to reference this in our subsequent action, we'll capture the following JSON path via one of the basic options above: get_user_info.body.usernames[1].value
.
Tines Tip: The reason why the 2nd object in the array is referenced as index 1 in the path is because array indexes start at 0.
However, what happens if that order is swapped, or, we only want to pull active usernames?
🌊 Arrays - Dynamic referencing
If we want to be able to capture a specific set of data, we can integrate Tines functions into our setup. Functions let us use programmatic logic to capture data in a more dynamic way. Let's see how we could filter the array and keep usernames where is_active
is true
, using our WHERE
function.
Within your subsequent action, navigate to where you want to reference the upstream data. In our example, this will be within the Payload.
Click + → Value (shortcut:
cmd + space
|ctrl + space
)Begin typing out
WHERE
in the formula widget.As you start typing this out, Tines will suggest functions that match the letters provided.
Select
WHERE
.Our
WHERE
function accepts the following syntax:WHERE(array, path, [value])
. Essentially,WHERE
looks at an array and targets a key path using a comparable value.
Since we want to only to see active usernames, format the
WHERE
function as follows:WHERE(get_user_info.body.usernames, "is_active", TRUE)
. (Note:TRUE
is highlighted + formatted in all-caps due to it being a boolean.)Make sure to change the data type to Formula mode so
WHERE
formats the array correctly!
Reference the "Results" on the bottom-right to confirm that the final output will only include usernames where
is_active
is set totrue
.