Non linear workflow approach

We have a workflow of multiple stages but the flow is not linear. The Front end application has multiple user roles involved during the overall process. Based on the user action, flow can go back to any of previous stages. So its dynamic in nature to some extent.

We are planning to have an orchestration service with the temporal workflow. Workflow will have multiple activities. It has a

‘While(Condition) {
Switch(activityCase): {
case Activity1:
case Activity2:
… }’

in the workflow, this allows us to call the required activity dynamically. Once the final stage is completed, it will come out of this while loop and end the workflow.

Is this approach correct? if not how we can approach this problem to dynamically execute the activities?

There are many ways to implement dynamic flow. One common way is to use OO techniques to model the sequence of activities according to your requirements.