Scenario
A Live Contract scenario is a definition of procedure as a Finite State Machine (FSM). As an FSM, the scenario can be visualized as flowchart and instantiated as a process.
Workflow
A workflow consists of an orchestrated and repeatable pattern of business activity.
A scenario is composed of a set of states and actions. An action can be executed by an actors which may trigger a state change.
The scenario can be instantiated to create a process. A scenario is stateless whereas a process is stateful. Stateful means that the computer or program keeps track of the state of interaction. Stateless means that there is no record of previous interactions.
The scenario may be defined in YAML, which is better readable. The workflow service only accepts JSON, but the LTO client libraries can convert this.
Golden flow
Each state MAY define a default action and each action MUST define a default response. Following these defaults results in the golden flow.
Omit a default action to wait for the timeout by default.
Implicit states
Scenarios have a number of implicit states. Except for :initial
, these don't need to be defined in the scenario. You may define these not the less to set things like descriptions.
Initial state
The state with key :initial
is the initial state of the FSM.
Success state
The :success
state is an end state indicating that the process has been completed successfully.
Cancelled state
The :cancelled
state an end state indicating that the process has been cancelled by one of the actors.
Failed state
The :failed
state is an end state indicating that the process has ended because of an error or other unexpected problem.
Example
In this scenario a supplier provides a quotation for a client to accept. The process can be started either by the client or by the supplier.
If the client starts the process, the golden flow is
Client selects the supplier and describes the service he would like a quotation for
Client invites the supplier to participate in the process
Supplier uploads a quote (due date depends on
urgency
)Client accepts the quote
done
If the supplier starts the process, the golden flow is
Supplier enters the client information
Supplier uploads a quote
Supplier invites the client to participate in the process
Client accepts the quote
done
Scenario schema
https://specs.letsflow.io/v0.3.0/scenario#
schema (or $schema)
The Live Contracts Scenario JSON schema URI that describes the JSON structure of the scenario.
id
A unique identifier. If the scenario is part of a Live Contract, this must be resource id that's valid for the event chain.
The id MUST point to an immutable version of the scenario. Modifying the scenario SHOULD always result in a new id. Previous versions of the scenario SHOULD remain available.
title
The title of the scenario.
description
A description of the procedure shown as scenario details.
actors
Object with JSON Schema, defining the properties for each actor. The keys of the object is used to reference the actor. The actor schema must define an object.
assets
Object with JSON schema, defining the properties for each asset. The keys of the object is used to reference the asset. The asset schema must define an object.
definitions
An object with constant values and predefined objects. This can be used to define things needed in multiple actions and/or states.
Even if it's only used in a single action or state, using definitions helps to keep actions and states small and readable.
actions
Set of the actions of the scenario. The keys of the object are used as reference of the action.
states
Set of all states of the scenario. The keys of the object are used as reference of the state.
Last updated