cs-icon.svg

Using Conditional Paths to Customize Automations

This use case covers a scenario where you can execute an Automation based on a conditional path. The conditional path configurations are checked, and if the condition is true, the If step actions are executed, otherwise the Else step actions are executed.

Creating a new entry triggers the automation, and the conditional path configurations are checked. If the condition is true, the If step will execute the Slack connector that will send a message to the configured channel.

If the condition is false, the Else step will execute the Transform connector that will fetch the entry details from the trigger and pass these details as an object in Algolia.

Let's break this scenario to see what must be the trigger event and the consequent action required to execute the Automation:

  • Set up the Contentstack “Entry Created'' Trigger Event: This trigger event is activated whenever a user creates a new entry in Contentstack and in turn it executes the automation.
  • Set up the Contentstack “Conditional Path”: Once the above event triggers the automation, it checks for the configuration provided within the conditional path.
  • Set up the Slack “Send Message” action for the If step: When the conditional path configurations are met, the If step action will send a message to the configured channel using the Slack action connector.
  • Set up the “Transform” action for the Else step: When the conditional path configurations are not met, the Else step will execute the Transform action which will fetch the entry UID from the entry trigger as a JSON object and entry data will be merged in the final result.
  • Set up the Algolia “Index Entries” action for the Else step: Once the transformation is complete, an object will be created in the Algolia index with the same entry UID.

The steps to set up the Automation are as follows:

  1. Configure Entry Trigger
  2. Configure Conditional Path
  3. Configure Slack Connector within the If Step
  4. Configure Transform Connector within the Else Step
  5. Configure Algolia Connector within the Else Step

Let’s look at the setup in detail.

  1. Configure Entry Trigger

    1. Log in to your Contentstack account and click the “Automate” icon.
    2. Click + New Project to add a new project.
    3. Click + New Automation.
    4. Enter the Automation Name and Description.
    5. Click Create.
    6. Select Configure Trigger from the left navigation panel.
      Basic-Information-Screen.png
    7. Within the Configure Trigger step, click the Contentstack connector.
      Select_Contentstack_Trigger
    8. Click Entry Trigger from the list of trigger events.
      Select-Entry-Trigger.png
    9. Add your Contentstack account. For more information, refer to the Contentstack Trigger documentation.
    10. Select Entry Created event from the list of events. Select a Stack, and a Branch from the Lookup dropdown. 
      Select_Different_Fields
    11. Once done, click Proceed.
    12. Click Test Trigger to test the configured trigger.
      Test-Trigger.png
    13. On successful configuration, you can see the below output. Click Save and Exit.
      Save-Exit.png

      Note: You can specify trigger conditions that will determine whether the complete automation should run or not. The automation and conditional path will not be carried out if the trigger conditions are not satisfied. You can see the updated list of executions in the Execution Log section

  2. Configure Conditional Path

    1. Click Configure Action Step from the left navigation panel. 
      Click-Configure-Action-Step.png
    2. Click Conditional Path to configure and set conditions.
      Click_Conditional_Path
    3. Click + Add Condition. In the Select Input box, enter the content type UID from the previous step. Select Matches (Text), and provide the UID of the content type in the input box.
      Configuration-Page.png
    4. Click Save Configuration.
  3. Configure Slack Connector within the If Step

    When the conditional path configurations are met, the If step action of sending a Slack message is executed.

    1. Click + Add Step under the If step from the left navigation panel.
      If-Add-Step.png
    2. Within the Configure Action Step, click the Slack connector.

      Note: You can sort and search the connector(s) based on the filter.

      Select_the_Connector.png
    3. Under Choose an Action, select the Send Message action.
      Select-Slack-Action.png
    4. In the Configure Action tab, add your Slack account. For instructions on adding your account, refer to the Slack connector documentation.
    5. Select a Channel from the Lookup list where you want to send the message. Enter the message in the Message field.
      Select-message-channel.png
    6. Click Proceed.
    7. Click Test Action to test the configured action.
      Test-Slack-Action.png
    8. On successful configuration, you can see the below output. Click Save and Exit.
      Save-Exit-Slack.png
    9. Once you configure the Slack action, you can add other actions inside the If step using the quick select screen. Similarly, you can also configure Else steps.

      Note: The quick select next step screen appears only when you have configured an action inside the If-Else step.

      Next_Step_If_Action

    This sets the Slack action connector

  4. Configure Transform Connector within the Else Step

    When the conditional path configurations are not met, the Else step actions of transformation and indexing entries in Algolia are executed.

    1. Click + Add Step under the Else step from the left navigation panel.
      Click-Else-Step.png
    2. Within the Configure Action Step, click the Transform connector.
      Select_the_Transform_Connector.png
    3. Under Choose an Action, select the Transform action.
      Select-Transform-Action.png
    4. Click Add Input, and enter a variable name for the Input Name (say, “ObjectID”) and an Input Value configured in the previous step (entry UID) (see the screenshot in next step).
    5. Click + Add Objects to Merge and fetch the complete entry details configured in the previous step as shown below.
      Select-Input-Objecttomerge.png
    6. In the Transformation field, enter the JSON code to fetch the UID value from the Input Value field in a variable. You can use the following code format: {“objectID” : “{ObjectID}”} 

      Transformation-Box.png
    7. Click Proceed.
    8. Click Test Action to test the configured action.
      Test-Transform-Action.png
    9. On successful configuration, you can see the below output. Click Save and Exit
      Save-Exit-Transform.png

    This sets the Transform action connector.

  5. Configure Algolia Connector within the Else Step

    1. Click + Add Step under the Else step from the left navigation panel.
      Add-Algolia-Step.png
    2. Within the Configure Action Step, click the Algolia connector.
      Select_the_Algolia_Connector.png
    3. Under Choose an Action tab, select the Index Entries action.
      Select-Index-Entries-Action.png
    4. In the Configure Action tab, add your Algolia account. For instructions on adding your account, refer to the Algolia connector documentation.
    5. Select the Index Name where you want to send the data in the form of a list of objects.
    6. In the Entries field, select the entry data fetched from the transform step.
      Select-Algolia-Index-Entry.png

      Note: Provide your index data as per your object schema and in JSON format only.

    7. Click Proceed.
    8. Click Test Action to test the configured action.
      Test-Algolia-Action.png
    9. On successful configuration, you can see the below output. Click Save and Exit.
      Save-Exit-Algolia.png
    10. Go to the Algolia Index section and check the latest index entry with the data.
      Algolia-Output.png

    Note: You can view the status of your executions in the Execution Log section.

Was this article helpful?
^