State machine as a service