Skip to content

Phase 5 — Automate Workflow Execution

Time to complete: ~5 minutes

Overview: In this phase, you’ll automate the execution of the workflow created in Phase 4 and clean up its labels. The result will be a workflow that executes automatically every 60 seconds and where each node in the workflow is explained in plain English.

Completed Phase 5 Workflow A view of the completed Phase 5 workflow.

Steps

  1. In this step, you will configure a scheduler trigger. Triggers automate the execution of a workflow based on certain events. A Scheduler Trigger enables you to execute a workflow based on a specified time schedule. To enable a Scheduler Trigger:

    • Click the + icon in the workflow editor toolbar for the MyFirstWorkflow workflow.
    • Scroll down and drag the Scheduler Trigger node onto the workflow editor canvas and drop it on the left-hand side of the Invoke GetAllEcommerceSku node. Then click the x icon to close the modal.
    • If placed correctly, it should draw a line connecting the two nodes automatically. If not then simply connect the two nodes by dragging the output arrow of the Scheduler Trigger to the input arrow of the Invoke GetAllEcommerceSku node.
    • Click the expand icon on the Scheduler Trigger node to set the interval on which the workflow should automatically be run. Enter the following parameters then close the dialog window:
      • Polling Interval (seconds): 60
    • Click Save in the main toolbar.
  2. In this step you will verify that your workflow is running automatically every 60 seconds. To verify your workflow is running every 60 seconds:

    • Login to the UI of the Demo Inventory API using your Lonti account.
    • Click the Stock Out menu and then click the Remove Stock button.
    • Enter any value for the Reference. Enter a value in Quantity, and click Manage to select a SKU to apply the stock adjustment to, then click Save. The Stock On Hand value will be reduced by the Quantity you enter.
    • Wait one minute for your workflow to be run, then verify that the change reflected in your local database by running the query SelectAllSkus that you created in Step 4 of Phase 3.

      Bonus Tip: In practice it is often useful to add Logger Functions to your workflow so that you can see the output of any node in your workflow in the Console. If you would like to try this, locate the Logger Function Info (string) and connect it to the output of the Scheduler Trigger node. In the Input mapper for the node set the message property to Workflow execution started (Language=Plain Text). Save, then watch that message appear in the Console every 60 seconds when the Scheduler Trigger executes the workflow. Logger function connected to scheduler trigger

  3. In this step, you will improve the labels on each node to make them easier to understand. Read your workflow like a project manager would view it and create labels that explain the process being run. To edit a node's label:

    • Double click on the label of each node and enter a new label. Here are some suggested labels:
      • Scheduler Trigger → Run workflow every 60 seconds
      • Invoke GetAllEcommerceSku → Get all product SKUs from the eCommerce API
      • Repeat → Iterate over each Ecommerce SKU
      • Map → Map Ecommerce SKUs to Inventory SKUs
      • Execute File.writeToPackage → Save Ecommerce SKUs as XML in resources folder
      • Invoke GetInventorySkuByProductCode → Enrich SKUs with stock on hand from Inventory API
      • Query database → Upsert results to local database Phase 5 Workflow with improved labels

What’s next: In Phase 6 you’ll learn how to publish an API.