Creating a state machine workflow