cs-icon.svg

Using Repeat Paths to Automate Repetitive Tasks

This use case covers a scenario where you can dynamically create multiple entries in Contentstack using the Repeat Path feature.

In this use case, we send bulk data via Postman and fetch the data in the HTTP trigger. Once the data is fetched, you need to configure the Repeat Path. Select the HTTP trigger data via the Data source field in the Repeat Path configuration.

Note: You can use any trigger or action to fetch the data from any source.

Configure the Contentstack action and select the Create an Entry action inside the repeat path. In the Create an Entry action, fetch the current-item value from the Repeat Path step. The current_item will iterate through each item in the data array and create the entries in Contentstack.

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 “HTTP'' Trigger Event: This trigger event is activated whenever a user makes a HTTP GET/POST request to the configured URL. In this case, the data is collected from Postman to the HTTP trigger.
  • Set up the Contentstack “Repeat Path”: Once the above event triggers the automation, it checks for the configuration provided within the repeat path.
  • Set up the Contentstack “Create an Entry” action: When the Repeat Path configurations are set, the create an entry action will create different entries in Contentstack.

    Note: Once you configure any action inside the Repeat Path, it will execute the action step repeatedly until the condition is met.

The steps to set up the Automation are as follows:

  1. Configure HTTP Trigger
  2. Configure Repeat Path
  3. Configure Contentstack Connector within the Repeat Path Step

Let’s look at the setup in detail.

  1. Configure HTTP Trigger

    1. Log in to your Contentstack account and click the “Automation Hub” 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.
      Configure_Trigger.png
    7. Within the Configure Trigger step, click the HTTP trigger connector.
      Click_HTTP_Connector.png
    8. Select HTTP Request Trigger. This trigger will be activated whenever you make an HTTP GET/POST request to a specific webhook URL.
      Select_HTTP_Trigger.png
    9. Select a Method, i.e., GET/POST.
      Select_HTTP_Method.png
    10. Click the Proceed button.
    11. You will find the applicable input “URL.” This URL will be the webhook URL to see the rule working. To send the data, hit the URL with a POST call in Postman.

      Note: Let’s consider the following dummy data from Postman.

      {
      "Students":
      [                   {"studentName":"test1","studentClass":"6","studentSection":"A"},
                          {"studentName":"test2","studentClass":"7","studentSection":"B"},
                          {"studentName":"test3","studentClass":"8","studentSection":"C"},
                          {"studentName":"test4","studentClass":"9","studentSection":"D"}
      ]}
      
    12. Click the Test Trigger button to test the configured trigger.
      Test_Trigge.png
    13. On successful configuration, you can see the below output. Click the Save and Exit button.
      Save_Exit_Trigge.png
  2. Configure Repeat Path

    1. Click Configure Action Step from the left navigation panel.
      Click_Configure_Action_Step.png
    2. Click Repeat Path to configure and select the Repeat type.

      Select_Repeat_Path.png
    3. In the Repeat Path Configurations, select the Data source to iterate the array received in the trigger.
      Repeat_Path_Configuration.png
    4. Click Save Configuration.
      Save_Configuration.png
    5. You can click the Reload icon to access the most recent data fetched from the Data Source field for the Repeat Path output without affecting the configuration.
      Reload.png
  3. Configure Contentstack Connector within the Repeat Path Step

    Configuring an action step inside the Repeat Path will iterate and run the action until the end of the data source is reached.

    1. Click + Add Step under the Repeat Path from the left navigation panel.
      Add_Step.png
    2. Within the Configure Action Step, click the Contentstack connector.
      Contentstack_Action.png
    3. Select the Contentstack Management connector to perform CMS tasks.
      Select_Connector_Category.png
    4. Under Choose an Action tab, select the Create an Entry action.
      Create_an_Entry_Action.png
    5. In the Configure Action tab, click + Add New Account to add your Contentstack account.
      Add_New_Account.png
    6. Select a way to add a new account. You can authenticate your account in two ways: Contentstack OAuth or Management Token.
      Authorize_Account.png
      1. If you select Contentstack OAuth and click Proceed, the Manage Permissions modal will open, as shown below. Provide the OAuth permissions for all the values by checking the boxes and click Authorize
        Authorize_Contentstack.png
      2. In the pop-up that appears, select your organization to complete the authorization.
        Select_Organization.png
      3. In the pop-up that appears, view the module-specific access rights provided to the app. Click Authorize to complete authorization.
        Authorize_Organization.png
      4. Provide an Account Name and click the Save button.
        Set-Account-Name
    7. Select a Stack, Branch, and a Content Type from the Lookup list.
      Select_Different_Fields.png
    8. Provide your entry data in the Entry Data field. Fetch the data from the Repeat Path step.

      Note: Provide your entry data as per your content type schema in JSON format only.

      Entry_Data.png
    9. Click the Proceed button.
    10. Click the Test Action button to test the configured action.
      Test_Action.png
    11. Click the Save and Exit button.
      Save_Exit_Action.png

    You can also add another action step using the Quick Select screen after you have configured the Contentstack connector.

    Create_Action_Step.png


    In the output, you will see one entry. To view all the entries created, you must activate the automation.

    Activate_Automation.png


    After activating the automation, you must send the data via Postman to the HTTP trigger URL. Navigate to Contentstack to view the entries in the selected content type.

    Entry_Ouput_1.png


    You can view the details of the entry as shown below:

    Entry_Output_2.png
Was this article helpful?
^