Prediction

LetsFlow can optionally predict the next states of the process by setting the ?prediction=true query parameter when using the engine API or by calling predict() when using the core library.

During a prediction the predicted states are instantiated, similar to the current state. This means that data functions in the scenario state are evaluated.

Action transitions

For the prediction, the action transitions of the state are tried in order. If the first transition is unavailable or not allowed, the second is tried, etc. If multiple actors are allowed to execute an action, the transition is tried for all actors, before moving to the next transition.

Response

If the action has a response schema, the default value is determined from the schema and used during prediction. If no schema is defined the response will be undefined. You can set the stub property of an action to specify a value used for the prediction instead of the default value.

Timeout transitions

If a state doesn't have action transitions or none of the action transitions are allowed, the prediction will try the timeout transitions. In contrary to action transitions, timeout transitions are evaluated in order based on the after value.

is_prediction flag

During a prediction, the is_prediction flag is added to the process. This flag can be used in if conditions for transitions and actions. It's useful to skip or break out of infinite loops, or to force a transition that would not be allowed.

initial:
  on: start
  goto: main
  if: !ref length(actors) >= 2 || is_prediction
main:
  transitions:
    - on: next
      goto: sign
      if: !ref is_prediction
    - on: next
      goto: prepare

Properties

The predicted states have the following properties

key

string

The key of the current state as defined in the scenario.

title

string

A short title for the state.

description

string

A long description of the state.

instructions

map of actor ⇒ string

Instructions that can be specific per actor. This is an object where the keys correspond with the actor keys.

instructions:
  employee: Fill out this form
  organization: Waiting for the employee to fill out the form

Additional properties

Additional properties that are defined in the scenario state are added to the predicted state when it's instantiated.

Last updated

Was this helpful?