Transitions
Key Concepts In This Chapter: - Types of Transitions, Transition Attributes, and Transition Scope
In this chapter, we will show how to perform the transition between different states. Here is an example config:
State Transition Process In the Above Example
In the above bot, the user will start from a home page. In home_page_state
, when the user clicks the Start Chat
button, the state machine jumps to intro_message_state
and display the intro message.
At intro_message_state
, user can transit to chat_page_state
by chatting with the bot. We have included several concepts related to transitions in the above example. Let's explain them one by one.
Transition & Its Attributes
A transition is usually defined as:
Where <action_name>
is the name of action, usually which you provide in the on_click
property of button, and <target_state>
is the state to transition when the action is run. This way, you can create a flow where the user gets to choose the path they want the workflow to go by clicking buttons. There are also some reserved action names that allow you to transition when a specific event happens in your bot.
We currently support three reserved action names:
CHAT: triggered when the user sends a message.
ALWAYS: triggered when an AtomicState has finished. Usually used to connect two consecutive states.
DONE: triggered when an Automata is finished. This can be useful in nested automata (to determine the next state of a child automata).
The Scope of Transitions
The transitions
can be defined either in an AtomicState
or in an Automata
. If a transition is defined in an AtomicState
, it will only handle the action triggered in that AtomicState (such as start_chat
in the home_page_state
). However, if a transition is defined in the Automata
, it will handle the actions in all its states. For example, since go_home
is handled in the transitions
of the whole transition_demo
, any button within transition_demo
that can trigger the action go_home
and make the automata jump to home_page_state
.
Conditional Transitioning
Pro Config also supports conditional transition, which means performing validation of some boolean expressions during the transition. The syntax is as follows:
When <action_name>
is triggered, Pro Config will check the conditions sequentially (first check <condition1>
, and then <condition2>
) to decide which state to jump to. If no condition is satisfied, the automata will stay in the original state. We will show how to leverage this advanced syntax in later examples.
Last updated