I’ve come across the Explode action a few times and I have a rough sense that it’s used for splitting up arrays, but I haven’t used it properly yet. I’m curious about when it’s the right tool to reach for, what to watch out for, and any tips for getting the most out of it. Would love to hear how others use it in practice.
Think of explode as a kind of “for each loop” (if you come from a programming background this will make a lot of sense) or a Run the rest of the story once for eace element.
You give the explode an array, and it emit an new separate even for each element in that array,
and that event then run through the rest of the story as it own chain of events.
Like: I have a list of user and i want to send each a slack message Explode user list → Send slack message
The hard part about explode it when you want want to bring all the explode evens back together to one event that can then continue on in the story.
This is where implode comes in (and this is actually the hard part, exploding things is easy the hard part it putting it back together take a little more precision)
Now we move into the area of imploding and I will happily talk about that somewhere else
but sticking to best practices for exploding:
-
Only explode when you really need to! (general good rule for life as well)
If you want to do something like explode an array, reformat the data and bring it back together consider something like LOOP mode instead on an Event Transform Action -
Only explode what you need to! (again also good life advice)
If your story looks like Explode → Condition consider filtering the data before exploding it! (it can save you a lot of events!)
I made some examples on the story library here the show how you can use FILER and REJECT to reduce the number of events you need to explode before exploding them! -
When you explode something, have a plan for putting it back together!
If the explode is toward the end of the story and you dont have anything else to do in your story or branch you done need to think too much about this, and you. can just end the story!
But if you want to explode a user list, look up the users, and then filter some of them so you only message say admin users before your story continue.For this I always recommend the approch of “Make sure the same number of events explode hits the Implode”
The core here is that if you use a Condition action between the Explode and the Implode, Make sure the no-match for that condition reaches the implode!
That little dotted line for the No-Match path is the magic answer!
The implode looks for the Build results in its Path setting,
The build results only exit if the event matched the trigger, so if the event did not match the trigger, build results does not exist and it will be a null in the imploded array (and you can remove that later with a COMPACT() functions
But you implode can still use theexplode.sizefor its size setting becasue you know every event that was exploded will always reach the imploade as well!
I hope my ramblings has been useful! And I highly recommend looking into Implode some more as that is where this stuff gets really fun!
