# State Machine

Builds the workflow from states and the transitions between them. The flow starts from the initial state, moves from state to state through transitions and completes when it reaches a **Final State**.


---

### Usage

On the State Machine canvas:

* **State** and **Final State** are dragged from the toolbox and dropped. These two can only be added inside a State Machine.
* The initial state is set by drawing a connection from the start node on the canvas to a state, or with the **Set as Initial State** command in the state's right-click menu. A State Machine without an initial state causes a validation error; a **Final State** cannot be the initial state.
* A transition is drawn by dragging from the edge of a state to another state. The **Trigger**, **Condition** and **Action** fields of a transition are described on the **State** page.
* A state is opened by double-clicking it; **Entry**, **Exit** and the transition list are edited there.

At run time:

* The flow enters the initial state. In each state, **Entry** runs first, then the triggers of the transitions are awaited.
* With the first transition whose condition is met, the state's **Exit** activity, the transition's **Action** activity and the target state's **Entry** activity run in order.
* When a **Final State** is entered, its **Entry** activity runs and the State Machine completes.