Skip to main content

Using explode and implode

Learn how to use explode and implode in the event transform action

Written by Fergal Collins
Updated today

This article and video explains how to use the explode and implode modes within the event transform action in Tines to process, clean, and reassemble array data. This is useful for manipulating data elements, such as removing unwanted characters, that would otherwise be difficult to do individually.

Tines Tip: For more background information on Implode and Explode actions, read here:

Steps

Initial setup (the kickoff action)

The process begins with an action (referred to here as the kickoff action) that contains an array of data. In this example, the data includes email, name, and id fields for several people. Each field contains an unwanted extra character, a dollar sign ($), which needs to be removed.

Here is the data if you want to follow along:

[
{
"email": "john$$doe@example.com",
"name": "John$$ Doe",
"id": "133445"
},
{
"email": "jane$$doe@example.com",
"name": "Jane$$ Doe",
"id": "198876"
},
{
"email": "jessie$$doe@example.com",
"name": "Jessie$$ Doe",
"id": "192837"
}
]

Step 1: Explode the data

To process the data points individually, pull in an event transform action and connect it from the kickoff action. This is the explode step.

  1. Name the action (e.g., Explode).

  2. Set the mode to "Explode".

  3. Set the path to reference the source data array (e.g., kickoff).

    • By default, the exploded items are named individual_item, but you can rename this if desired.

Running the workflow will cause the Explode action to generate multiple events, one for each item in the original array. The unwanted characters are still present at this stage.

Step 2: Format and clean the data

Next, pull in a second event transform action and connect it from the explode action to clean and format the data.

  1. Name the action (e.g., Format Data).

  2. In the message field, set up the desired key-value pairs (email, name, and id) to maintain the original data structure.

  3. For the value of each key, use a formula to reference the exploded item's data and remove the extra character. The REMOVE formula is often the simplest method for this.

    • Example formula for email: REMOVE(explode.item.email, '$')

    • Apply this same formula logic to the name field, adjusting the data pill reference (e.g., REMOVE(explode.item.name, '$').

Running the workflow now shows that the Format Data action has cleaned the email, name, and ip fields by removing the extra dollar signs, modifying the data to the desired format.

Step 3: Implode the data

Finally, use a third event transform action in implode mode to combine the individual, cleaned events back into a single list.

  1. Name the action (e.g., Implode).

  2. Set the mode to Implode.

  3. Set the item path to the action containing the cleaned data (e.g., Format Data).

  4. Set the guide path to explode.guid. This is the unique identifier created when the initial explode action happens.

  5. Set the size path to explode.size. This tells Tines how many items were exploded.

When the workflow is run, the Implode action will output a single item containing the complete list of cleaned data, pulling everything back together. This showcases how you can quickly use a couple of different event transforms to achieve cool results.

Event processing flow of explode actions

When a story is started, a story run GUID is created. This is a unique identifier for that story run. For each action that is executed, they have an event ID, which is unique to the singular execution of that action.

An explode action treats however many events were emitted from it almost as different story runs. So, they're emitted and they can flow through the rest of the story in parallel to each other, but they maintain the same story run GUID.

We do not respect the order of the events from an explode. For example, when these events are submitted, if you run the same transformation against 50 events and then use an implode action, the implode can and will receive them out of order. This is because, on our back-end, some processors will do the same job slightly faster than others, and while we process as first in/first out, we can't guarantee that an implode will be in the same order as it was sent out.

Example: Exploding an array

This video explains how to explode an array in Tines using a get cat picture example.

👉 For a more detailed description of event transformation see here

Did this answer your question?