Sub-workflows

Sub-workflows

Overview

Sub-workflows are steps that let you call other workflows. Some common use cases:

  • A joint application workflow calls a KYC workflow for both applicants.
  • A ruleset is reused by multiple workflows as a sub-workflow.
  • The fraud and credit teams each own a workflow, and their team members only have access to their team’s workflow. A main workflow calls the fraud workflow and credit workflow as sub-workflows.
icon
Each execution of a sub-workflow is also billed as a workflow execution.

Call a sub-workflow

To call a sub-workflow, create a sub-workflow step. The step references a version of the sub-workflow, and the following restrictions apply:

  • You can’t call a sub-workflow that contains a sub-workflow itself. This is to avoid circular dependencies.
  • You can’t call a sub-workflow that contains case nodes. Instead, create cases in the parent workflow.

Sperta will automatically assign input features from the parent workflow to the sub-workflow if the feature ID and type match exactly. You can use any expression to assign values to the sub-workflow input features, such as passing a data source feature to the sub-workflow.

A joint application workflow calls the credit workflow for the primary holder
A joint application workflow calls the credit workflow for the primary holder

Use sub-workflow results

To access sub-workflow results, use the workflows namespace in expressions, and you have access to two fields:

  • decision is the decision from the sub-workflow.
  • output is a JSON that contains the output features of the sub-workflow.
    • If the feature ID contains ., you can access it like this: workflows.step_id.output["approve_outputs.loan_amount"]

Depending on the workflow graph of the sub-workflow, not every feature in the output will always be available. In this case, you must check if the feature exists before comparing it with other values. You can add ? before the feature ID and use the hasValue() function to check if it exists:

workflows.step_id.output[?"approve_outputs.loan_amount"].hasValue()
and workflows.step_id.output["approve_outputs.loan_amount"] > 1000.0