[Zapier] How to replace Path action with Code action?
Issue
I want to send notification emails to different product teams using Zapier. The team to send the email to is determined based on a multiple picklist value on a Salesforce Account, which may contain multiple different products.
The intuitive solution is to use a "path" with an IF-ELSE function. However, there are a few problems:
- The path must be placed at the end of the entire Zap. This means that you cannot first check the first product and then sequentially check the second and third products.
- If you want to use Zapier's path function to implement a conditional action, you need to upgrade to a Professional version or higher, which requires additional cost.
In short, path cost money, and I don't have money.
Solution
Fortunately, Zapier offers a powerful tool called "Code," where you can use JavaScript or Python to do a lot of things you want.
(Code Tool: https://zapier.com/apps/code/integrations)
Assuming that I have five possible products, my original intuitive design was to create five different send email actions, each with its own subject, body, and recipients. Then, I would add conditional checks to each action to determine whether to execute it.
When it comes to conditional checks, you must use a path if you don't write code. Fortunately, we can write code!
I merged the five send email actions into one, where the subject, body, and recipients are all set as variables.
Where do these variables come from?
They are generated by Python in the previous step!
As long as all the parameters that need to be used are prepared using Python code in advance, you can use a for loop to execute the send email action for each product.
This saves several dollars each month.
The concept is simple, and here is a simple sample:


留言
張貼留言