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
.
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.
Introduced in CSML v1.2
If you want to reach a specific step in a specific flow, you can use the @ notation:
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
.
Introduced in CSML v1.5
As you can see above, steps and flows use strings as identifiers, but they are expressed without double quotes "..."
. In order to navigate to dynamically set steps or flows, CSML adds a special syntax, similar to the dereference pointer concept in other languages.
To go to a variable step or flow, you can reference the variable name prefixed with a $
sign:
Any of the syntaxes presented above are supported. For instance:
Please note that dot notation (accessing child properties in an object or array, i.e a.b
) is not supported in variable flow and step names.