A flow is made of at least one step (called start
), but can also contain as many steps as necessary. You should think of steps as individual, simple bits of logic, linked inside the same conversation topic (which is the flow).
To go from one step to the next, you can simply use the keyword goto
(or goto step
) followed by the name of the step.
To finish a flow (and close the conversation), add goto end
.
start:say "hi"goto step otherstep // note: in the following examples, we will use the shorthand notation `goto otherstep`otherstep:say "I'm in otherstep"goto end
If, at the end of a step, the goto end
instruction is omitted, the conversation will be closed anyway.
In other words,goto end
can be used to exit of a conversation early at any point, but it is implicitly added at the end of all steps if no other goto
instruction is present.
Similarly to navigating between steps of the same flow, you can go to the beginning of any other flow by using the goto flow
keyword. This will trigger the start
step of the target flow and close the current flow, so coming back to the first flow will actually go back to the beginning of that flow.
somestep:goto flow anotherflow
If you want to reach a specific step in a specific flow, you can (since CSML v1.6) use the new @ notation:
goto step_name@flow_name
This is the universal way of navigating between steps and flow. The above two methods are actually special cases of this notation:
When the @flow_name
part is not specified, CSML interprets it as "in the current flow". So goto stepname
actually is shorthand notation for goto stepname@current_flow
, where current_flow
is dynamically matched from the name of the current flow, and works accordingly.
When the step_name
part is not specified, CSML interprets it as start
. So as @
means "flow", goto @flow_name
is the same as goto start@flow_name
which is also the same as goto flow flow_name
.
goto stepname // navigate to the step named stepname in the current flowgoto flow flowname // navigate to the start step in flow flownamegoto @flowname // navigate to the start step in flow flownamegoto stepname@flowname // navigate to step stepname in flow flowname