Sub-Zap by Zapier Quick-Start Guide

Do you often find yourself repeating the same actions across different zaps in Zapier? Well, then the Sub-Zap by Zapier action was made just for you! You can take all those grouped actions you repeatedly use across your zaps and put them in a single sub-zap that you can then request from any other zap in Zapier.

For anyone with programming experience, a sub-zap functions similar to a function in programming where you pass input parameters to the function from your main program, the function does some work with these parameters and then returns output values that you can use in your main program.

This feature will save you oodles of time. On top of the time saved from not having to put the same actions into zaps, again and again, you will also save time when maintaining and updating the actions in the sub-zap. Previously, if there were an update needed to a group of actions used across multiple zaps then you would have to make the update multiple times. Now you can make the update in one single place, the sub-zap!

Sub-Zap by Zapier Walkthrough Video

Sub-Zap For Sales Member Tagging

Now that you know a little about sub-zaps and how they can save you from repetitive strain injury let’s take a look at how to use a sub-zap within Zapier. We’ll use the example of tagging sales members if their names appear on a lead notification in Slack.

Sales notification sent to Slack from Marketo
Sales notification sent to Slack from Marketo
Slack thread of the sales notification showing tagging of the sales owner
Slack thread of the sales notification showing tagging of the sales owner

Sub-Zap Setup

Start a Sub-Zap Trigger Event

Once you choose the “Sub-Zap by Zapier” app and the “Start a Sub-Zap” trigger event, you will need at list one input parameter for this sub-zap to be functional. Under the “Input/Argument List” we are going to include an input parameter called text and make this a required input by putting the “(Required)” keyword after the input name.

"Start a Sub-Zap" action in Zapier
“Start a Sub-Zap” action in Zapier

This text input variable is the message from Slack, which will be passed from the requesting Zap outlined below. This sub-zap will parse this message in order to determine if there are any sales member names present and if so prepare a message that will tag these sales members in the thread of the original message (as shown in the images in the introduction of this post).

Get First Names and Slack Tag Names

The Slack Tag Names Google sheet stores a list of all sales members along with their tag name, which is used to mention them on Slack, in the “Front End” tab. Since Zapier’s Google Sheets integration can only read in a maximum of 20 rows at once some finagling must be done in order to get all these names into Zapier in one action.

This is where the “Back End” sheet comes into play. The join formula below is used in both the “First Name” and “Slack Tag” columns to join every row value from the corresponding columns in the “Front End” tab with the asterisk character.

=JOIN("*", 'Front End'!C2:C)

Then in Zapier the “Lookup Spreadsheet Row” is used to search the “Lookup” column for the ***lookup*** value from the “Back End” tab. Since this lookup value will never change this action will always bring in the “First Name” and “Slack Tag” strings.

Google sheet action to pull in salesperson names and Slack tags
Google sheet action to pull in salesperson names and Slack tags

Parse Owners and Prepare Slack Message

Once the “First Name” and “Slack Tag” strings have been imported into Zapier the Python code in Step 3 splits these strings using the asterisk as a delimiter so that parallel lists are created where the Slack tag at index i in the t_names list corresponds to the first name at index i in the f_names list. The mapping dictionary is then created from these 2 lists so that using a first name as a key in the mapping dictionary i.e. mapping[first_name], will return the Slack tag for that first name.

The input Slack message is then searched using Regex patterns to extract the Account Owner, Account SDR, Lead Owner, and Lead SDR names, which are then stored in the l_names list. A for loop is then used to iterate through the l_names list and add the owner or SDR name to a string if the name is populated and is not present in the string already. The owner or SDR name is prepended with an “@” character so that when this string is sent to Slack the salesperson will be tagged.

You can copy this Python code from Github here.

Python code used to parse out sales owners and prepare the tagging message
Python code used to parse out sales owners and prepare the tagging message

Return From a Sub-Zap

Once again the “Sub-Zap by Zapier” app is used but this time the “Return From a Sub-Zap” event is selected. In the “Set up action” section, the new message created in Step 3 containing the sales member tag names is put into the “Output/Return Values” field so that this new message will be returned to the requesting Zap outlined below.

"Return From a Sub-Zap" action in Zapier
“Return From a Sub-Zap” action in Zapier

Requesting Zap Setup

Overview of the zap that will call the sub-zap
Requesting zap overview

New Message #inbound-formfills Channel

Select the “New Message Posted to Channel” trigger event under the Slack app and then once you have chosen the channel you would like to monitor e.g. #inbound-formfills, ensure that “Trigger for Bot Messages” is set to “Yes” so that sales notifications from a marketing automation tool such as Marketo will trigger the zap.

New message to Slack channel trigger in Zapier
New message to Slack channel trigger in Zapier

Marketo Bot Filter

In this case we are only interested in Slack messages sent from Marketo. Therefore, a filter is used in Step 2 to check that the ‘User Name” obtained from Step 1 does not exist, since only human Slack members will have a “User Name”.

Zapier filter to only allow progression for bot messages
Zapier filter to only allow progression for bot messages

Call a Sub-Zap

The “Call a Sub-Zap” action is used from the “Sub-Zap by Zapier” app to request the sub-zap we created above. In the “Set up action” section you can see that the required text field we specified as an input argument in the sub-zap setup now appears under the “Input Argument” section and is ready to be populated with the incoming Slack message from Step 1.

Calling a Sub-Zap in Zapier and passing input arguments
Calling a Sub-Zap in Zapier and passing input arguments

At this point, the sub-zap will take the input Slack message, run through its steps, then return the message containing the salespeople who will be tagged in the thread of the original Slack message.

Empty Message Filter

Step 4. then takes the message returned from the sub-zap and ensures that the message does not equal “NA” since this is the value used to initialize the message variable and if it has not changed then that means there are no salespeople to tag.

Zapier filter to only allow progression if the message returned from the sub-zap is populated
Zapier filter to only allow progression if the sales tagging message is populated

Tag Owner(s) in Thread of Original Message

Finally, the “Send Channel Message” action is used from the Slack app to post the salesperson tagging message returned from the sub-zap in the thread of the original incoming message. After selecting the channel and populating the “Message Text” field with the message returned from the sub-zap in Step 3, make sure to populate the “Thread” field with the “Ts” parameter of the incoming message from Step 1.

Posting the message returned from the sub-zap to Slack
Post message to Slack action in Zapier
Specifying the thread to post a Slack message to in Zapier
Specifying the thread to post a Slack message to in Zapier

Sub-Zap Things to Note

Place Filters AFTER Return from Sub-Zap Step

One thing to be cautious about when it comes to sub-zaps is the use of filters. For example, for the sub-zap we created above you might have wondered why don’t we take the “Empty Message Filter” step and “Tag Owner(s) in Thread of Original Message” step from the requesting zap and put these in the sub-zap too.

I have moved these 2 steps into the sub-zap in the YouTube video shown at the top of the post. This allows different requesting zaps that listen to different Slack channels to all use these 2 last steps via the sub-zap by passing the channel and thread ids as input arguments to the sub-zap.

The placement of the filter is important. It must be AFTER the return from sub-zap step.

Take the scenario where the message returned from the “Parse Owners and Prepare Slack Message” is empty. If the “Empty Message Filter” step were before the “Return From a Sub-Zap” step then the sub-zap would never reach the “Return From a Sub-Zap” step meaning that the sub-zap would never return to the requesting zap and then the requesting zap will never complete.

I have not tested what will happen in this scenario but I am guessing the sub-zap would time out causing all subsequent steps in the requesting zap that depend on the sub-zap action to fail.

This is why in the YouTube video I placed the “Empty Message Filter” AFTER the “Return From a Sub-Zap” step so that even if the message is empty and the sub-zap ends, the sub-zap has already completed the “Return From a Sub-Zap” step and the requesting zap can complete without issue.

What’s After Sub-Zaps?

If you are a Marketo user and you are interested in setting up sales tagging like this in your Slack instance but have not set up sales notifications from Marketo then check out the Marketo Slack Integration post.

In the meantime, if you are curious about merging leads in Zapier, optimizing zaps, or integrating with the Dropbox, Airtable, and Rebrandly APIs then take a look at the Zapier section on my site, and while you’re there see what else takes your fancy!

Leave a Reply

Your email address will not be published. Required fields are marked *