Intro
When we are within Tines, we don't need to run everything in a linear story. There are different ways to configure how our Stories flow that make it convenient and easy, both from a processing perspective and a visual perspective. In some cases, we'll have Triggers that create multiple Story lanes.
In this design pattern, we will have multiple streams of actions that stem from one "kickoff" action. Then, we will pull them back together to continue the story as one singular item, combining the efforts of the story fork.
How do you map an HTTP request?
In this step, we prepare our HTTP requests by carefully mapping out the URL, selecting the appropriate method (GET, POST, etc.), and specifying any necessary parameters. This ensures that our requests are well-structured and targeted.
Let's look at an example of a service that doesn't require authentication (also known as an open API). Here, we have a Dungeons & Dragons service that lets us request information about spells, classes, and monsters. You can ask for the entire list of spells or retrieve a specific one like "acid-arrow." Not all APIs work this way, but on the website below, you can actually test it out: https://www.dnd5eapi.co/
If you enter that URL into your browser and press enter, you'll receive the same information as you would by using an HTTP request action. I'm going to use "https://www.dnd5eapi.co/api/spells."
To use that URL in an HTTP request action, simply copy the URL and paste it into the URL section.
Press Play/Pause to follow along with the GIF below
Example Steps:
Add an HTTP request action.
Set the name.
Set the URL.
Retrieve the URL from the API documentation.
Set the content type to JSON.
Set the method to GET.
Most services that don't require authentication with a password or API token typically use GET by default.
Run the action to review the results in the event data.
This method applies to any API service you want to configure as an HTTP request.
How do you capture data in an event transform?
When we fork a story, we often need to capture and organize data as it flows through various paths. This is where the event transform comes into play, allowing us to catch the incoming data and normalize it for consistent use downstream.
Press Play/Pause to follow along with the GIF below
We continue the naming convention of "format" to ensure that subsequent actions reference the "format.message" field. This approach allows us to rely on the event transform to normalize the data, avoiding concerns about variations in the JSON paths across different HTTP request actions that occur beforehand.
Example Steps:
Go to the action you want to capture data from.
Go to the HTTP Request action (in this example).
Open the event data by clicking the number in the top right corner (e.g., 1).
Click the
[ ][ ]
icon to the left of the value you want to map or copy.Add an event transform action.
Connect the previous action to the newly added event transform.
Set the name to "Format."
Click the purple text next to "message" in the builder.
Delete the purple text.
Press
CMD+V
to paste the data you copied earlier.Repeat this process for any other actions you want to map data for.
Hot Tip: You can copy an action with CMD+C
and then paste it with CMD+V
. This reduces the need to recreate the event transform entirely.
How do you pull results together from different actions?
Once our data has been processed, we’ll need to aggregate the results. This involves specifying the size (number of items), determining the item path (which data elements to group), and using an identifier path to correctly pull the items together, ensuring that everything is neatly bundled for the next stage.
Press Play/Pause to follow along with the GIF below
Example Steps:
Pull in an event transform action
Set the name
Set the mode to implode
Set the item path
These are the objects you want to pull together. So if you have an action named "Format" and inside of it an object named "message", then we would set the item path to "format.message".
Set the item size
This is how many items you want to pull together in your list/array. Since this example has 2 items, we'll set the size to 2.
Set the identifier path
This is when we want to pull the story together. STORY_RUN_GUID() is great to leverage because it is a unique code generated every time you run a story.
An alternative way is by going to the options on the bottom of the action and adding "seconds". If we do this we'll want to click the "-" to the right of identifier path and just use the seconds instead. Selecting how long to wait to pull together results.
Now you can run the story from the top and see how the implode works.