Prediction
Last updated
Was this helpful?
Last updated
Was this helpful?
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 . This means that in the scenario state are evaluated.
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.
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 of an action to specify a value used for the prediction instead of the default value.
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
flagDuring 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.
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.
Additional properties that are defined in the scenario state are added to the predicted state when it's instantiated.