Search code examples
zapierzapier-cli

Zapier Zaps with branching Logic


I want to create a zap with branching logic. I want to do this since the gateway/REST API am using supports addition of only one web hook. I require a Zap that can perform Action 'A' when suppose trigger returns an event with 'event_type' = 'alpha' and Action 'B' will be performed when the same trigger returns an event with 'event_type' = 'beta'

example:

if trigger_A.output.event_type = 'alpha'
       then 'Send mail' to '[email protected]'
else if trigger_A.output.event_type = 'beta'
       then 'Send message' to 'Slack'
else
       post in 'Facebook' trigger_A.output.message

Is this possible with a single Zap?

NOTE that I cannot add multiple webhooks to my REST API, and hence I cannot have multiple Triggers, and I can use use maximum 1 Zap.

Any help from the forum would be appreciated.


Solution

  • edit: This answer is outdated. See the other answer about Zapier's first-party support for Paths.


    David here, from the Zapier Platform team.

    I've got good news and bad news! The bad: this is not currently possible out of the box. It's being discussed internally and we have nothing further to say about it at this time.

    The good news is that the workflow you describe is possible, but it'll take a few zaps:

    Zap A: Webhooks (catch) -> Code -> Webhooks (post)
    Zap B: Webhooks (catch) -> Gmail (send mail)
    Zap C: Webhooks (catch) -> Slack (send message)
    Zap D: Webhooks (catch) -> Facebook (create new post)

    The steps are as follows:

    1. Your service sends a webhook to Zap A with a key+value describing event_type
    2. You have a code step that runs the real version of the pseudocode you posted above, setting a url variable based on the event type. Zaps B,C,D each have a unique url for their trigger, all of which are known to Zap A.
    3. Zap A posts to the url returned in step 2, sending along whatever data you'd like.
    4. One of the child zaps (B,C,D) gets triggered, doing the desired action.

    So there you have it! Not pretty, but certainly doable.

    ​Let me know if you've got any other questions!