# State & Transition

# What

# What is a state?

A State is any point in the conversation where your AI might want to generate a response. At any given moment, the user is in a state. Based upon the conversation, we may transition between states. By default, the user starts at the root state. A state is considered "terminal" if it has been manually marked as such or if it has no outgoing transitions.

From a machine learning perspective, a state is a discrete point in a conversation where a distinct set of machine learning models (svp, slot mapping) and Business Logic is used.

For example, in this food order competency, all the nodes represent different states. Here is a breakdown of all the states and users’ possible interactions in a particular state. states

User State & Response
“Can I order some food?”
food_order:
"Sure, what can I get you?"
“Can I get a cheeseburger?”
“Add a diet coke to my order please.”
food_order_confirm:
"I have your order to be a cheeseburger, is that all?"
"Okay, I've added it, is that all?"
“Yes, that’s correct.”
food_order_confirmed: (After the customer has confirmed the order) “Your order has been processed.”
“No ketchup please.”
“Scratch the fries, I’m on a diet.”
food_order_incorrect:
(If the user says the order is incorrect, the AI can prompt users to make changes.) “What changes would you like to make?”
“Cancel my order.”
“I don’t want it anymore.”
food_order_cancel:
(At any point of the conversation, the users can cancel their order.) "Your order has been cancelled."

# What is a transition?

A transition is the way through which the conversation can move between states. It is visually represented by an arrow in the state graph. There are four types of transitions that you can utilize: classification transition, slot/variable transition, business logic transition, and out of scope transition.

# What different transition types are there?

# Classification Transition

Classification transition is a classification-driven transition. When processing a query, the classifier AI engine begins with classifying the utterance. In the meantime, the AI engine looks at the outgoing classification transitions from the current state. If an outgoing transition includes the resulting class, the transition can be executed successfully otherwise the conversation is taken back to the root state.

In a classification transition, there can be one or multiple intents which are datasets that represent different ways a user gives a query. Any query comes into the platform will always take a classification transition first to get to a certain state. Query like "Can I order some food?" fits in the intent of food_order_start thus take a classification transition and land on the state of food_order.

# Slot/Variable Transition

Slot transition is a slot value-driven transition. This type of transition requires a set of slots to be extracted. When all the slots are filled, a transition will automatically be executed. Until then, the AI prompts the user for the information needed to make the transition.

An example of slot transition can be from food_order state to food_order_confirm state. As shown in the graph above, it requires the presence of a food slot for the conversation to proceed to confirm state. If an end user gives a query "I want to order some food." We need to design the response to prompt the user to give the information about the type of food they want to order. The filling of the food slot then triggers the transition.

# Business Logic Transition

Business Logic transition is a white-listed transition that can be arbitrarily initiated by Business Logic. If Business Logic overrides the destination state, and a matching Business Logic transition exists, then the transition will be taken.

An example of Business Logic transition can be imagine in a financial setting, it makes sense for the virtual assistant to provide the account balance after the end users transfer money. This can be achieved by a Business Logic transition. To see a sample code for this transition, read Transformation 2: Transfer Money in the Advanced Starter Guide.

# Out of Scope Transition

An out of scope transition is a transition used to direct the AI to a particular state when an utterance goes out of scope instead of exiting the competency.

An example use case is when the AI asks for a slot that can include arbitrary vocabulary and the user answers directly. For example, the AI asks Which account do you want to transfer money from? and the user answers XYZ. This would normally go out of scope and exit the user out of the state. With OOS transitions, we can add implement BLS to check if a slot is mapped on OOS transitions. If there is no slot, we can reclassify at root. If there is a slot, we can continue instead of exiting.

In Depth Out of Scope Transition Behavior

By default, custom out of scope transitions utilize the out of scope intent plus the set of intents from root to the destination state. This is to prevent the hidden reclassificy through root transition from overlapping the out of scope transition and leading to unexpected behavior.

If that transition is disabled via the Edit State Dialog, custom OOS Transitions will instead have the out of scope intent plus the set of intents from root minus the set of intents on outgoing classification transitions from that state. This is to ensure the OOS transition is taken intuitively.

Note: Different types of transitions are visually differentiated by solid and dashed lines. See the lower left corner of the state graph.

# What is state graph?

State graph is the visual representation of all the states and transitions in your AI version.

AI workspace

On the AI workspace you can find:

  • Left: Competency Sidebar is where you can not only add/modify competencies in one AI version including viewing all the states, transitions, slots and training data. You can also launch crowdsource jobs, and manage responses gauging to different personalities.
  • Right: State Graph Editor enables you to directly modify conversational states and transitions.

# How

How to add/create a state?

How to delete a state?

How to mark a state as terminal?

How to enable parts of speech tagging?

How to disable reclassification through root?

How to add different types of transitions?

How to edit/delete a trasition?

# How to add a state?

Navigate to the competency sidebar, click add next to the competency name, then click Create State:

  1. You will see an input field that prompts you to name your new state.
  2. Then click Add.

add state

# How to delete a state?

  1. Hover over the state you wish to delete, a add and a clear will appear.
  2. Click clear and confirm that all the transitions and response templates associated with this state will be deleted.

# How to mark a state as terminal?

Competencies are only considered to be completed after the user has reached a terminal state. Completed "Incomplete" competencies will no longer be resumed, and completed "Must-Complete" competencies can be exited. By default, all states without an outgoing transition are considered terminal. States may also be manually set to terminal.

To manually set a state as a terminal state,

  1. Hover over the state you wish to delete and click the hamburger (3-dots) menu.
  2. Select Edit State.
  3. A dialog will pop-up. Mark (or unmark) the checkbox for terminal state and click Save.

# How to enable parts of speech tagging?

Parts of speech tagging is a form of BLS payload enrichment that adds a field titled "pos" to the BLS payload when a state with part of speech tagging enabled is entered. Each word in the utterance is assigned a parts of speech tag. These tags can be used to determine the plurality and tense of words.

To enable parts of speech tagging,

  1. Hover over the state you wish to delete and click the hamburger (3-dots) menu.
  2. Select Edit State.
  3. A dialog will pop-up. Mark (or unmark) the checkbox for parts of speech tagging and click Save.

# How to disable reclassification through root?

By default, all states have an implicit, hidden, classification transition back to root that contains the set of all intents outgoing from root minus the set of all intents outgoing from the state. This transition has reclassify set to true, so instead of going out of scope, the utterance will classify again into the proper competency.

This toggle allows this transition to be disabled for the choosen state. This is advanced behavior, but can be useful to prevent traversal to another competency, or in conjuction with out of scope transitions.

To disable reclassification through root,

  1. Hover over the state you wish to delete and click the hamburger (3-dots) menu.
  2. Select Edit State.
  3. A dialog will pop-up. Unmark the checkbox for parts of reclassification through root and click Save.

# How to add different types of transitions?

  1. Hover over the source state in the competency sidebar.
  2. Click add next to the State name, then click Add Transition.
  3. Then in the Transition Type modal, choose the type of transition you need.
  4. Configure the Source Competency and Source State as well as Destination Competency and Destination State.
  5. Depending on what type of transition is created, there are different actions:

clf_transition

Transition Type Action Instruction Note
clf_transition Classification Transition Specify the intent to be associated with this transition. Choose the intent name in the Add Intents to the Transition menu. If you don't find one that works meet your needs, choose Enter your own. You can either reuse an existing intent or a new intent for which you need to collect training data.
slot_transition Slot/Variable Transition Specify the slots required to be fulfilled in order to trigger this transition. Fill the slot name into the input field below the transition name and then save. The slots used for variable transitions need to be either existing SVP slots or destination slots from slot mapping. It is also possible to have multiple slots associated with a single slot transition, in which case all slots have to be fulfilled to trigger the transition.
BL_transition
Business Logic Transition
No additional action needed N/A This type of transition is triggered by Business Logic.
Out of Scope Transition No additional action needed N/A This type of transition is triggered by the context going out of scope.

# How to edit/delete a transition?

Hover over a transition to reveal the edit options next to the transition name.

  • addallows you to add intents to an existing classification transition. Clicking on the intent allows you to add/remove/curate the dataset associated with the intent.

Note: You can either add a new transition or add an intent to an existing transition (see graph below). Adding an intent is almost like adding the data to the existing except on classification you see intent1&intent2(in response payload). If you add another clf transition they "compete" with each other for classification which could lower either or their respective scores for classification. With individual intent, you can also configure action/response specific to this transition through Business Logic which provides more customizability.

![shared & individual transition](../media/shared_individual_transition .png)

  • clear removes the transition from the state graph.

Note: There are transitions that are essential to the competency. For example, food_order_confirm is indispensable to food_order, so we don't recommend deleting transitions like the transition from food_order to food_order_confirm.



Last updated: 08/6/2022