LetsFlow
  • Introduction
  • Tutorial
    • The basics
    • A handshake
    • A conversation
    • A proper introduction
    • Group meeting
    • Quote
  • Cookbook
  • ENGINE
    • Installation
    • Authentication
    • API
    • Services
      • Configuration
      • Messaging
        • ZeroMQ
        • AMQP 0-9-1
        • Webhook
      • Engine service
  • Integration
    • Frontend
      • React
      • Angular
      • Vue
      • Svelte
    • Backend
  • Reference
    • Scenario
      • Actor
      • Action
        • Update instruction
      • State
        • Transition
          • Log
        • Notify
      • Data function
    • Schema
    • Process
      • Current state
      • Previous log
      • Prediction
      • Events
        • Instantiate event
        • Action event
        • Timeout event
  • Libraries
    • Core library
    • JMESPath
    • Test suite
      • Given
      • When
      • Then
        • Assert state
        • Assert actor
        • Assert variable
        • Assert service
        • Assert event
      • Customize
  • Advanced topics
    • Deep integration
    • Decentralized workflows
    • Custom JMESPath functions
    • Custom YAML tags
Powered by GitBook
On this page
  • Action transitions
  • Response
  • Timeout transitions
  • is_prediction flag
  • Properties
  • key
  • title
  • description
  • instructions
  • Additional properties

Was this helpful?

  1. Reference
  2. Process

Prediction

PreviousPrevious logNextEvents

Last updated 2 months ago

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.

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 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
{
  "initial": {
    "transitions": [
      {
        "on": "join",
        "by": "participant",
        "goto": null
      },
      {
        "on": "join",
        "by": "organizer",
        "goto": "start"
      },
      {
        "on": "cancel",
        "by": "organizer",
        "goto": "(canceled)"
      }
    ]
  }
}

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
{
  "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.

current state
data functions
stub property