Transitions

Sometimes your bot will need some additional information from the user before it can provide a final answer. On this page, you will learn how to branch after an output prompt and take different paths depending on the user response. These paths in Teneo are known as transitions and are used to tie flow nodes together.

We'll use the following example, where the bot provides information about the coffee mug to the user, and then the bot needs a confirmation from the user before it proceeds to reserve a coffee mug:

User: I want to buy a coffee mug.
Bot: The official Longberry barista coffee mug is only available for purchase in our store. Would you like me to reserve a mug for you?

User: Yes.
Bot: I have reserved a Longberry barista coffee mug for you.

or

User: I want to buy a coffee mug.
Bot: The official Longberry barista coffee mug is only available for purchase in our store. Would you like me to reserve a mug for you?

User: No.
Bot: Ok, I will not reserve a coffee mug for you.

To achieve this we will do the following:

  • Create a new flow.
  • Populate a trigger with example inputs and generate a match requirement
  • Add an output response in the form of a question.
  • Create a 'yes' transition so that the user can answer the question.
  • Add output response for the 'yes' scenario.
  • Create a 'no' transition so that the user can answer the question, and then add answer text for the no scenario.
  • Save and test the flow.

This is what our flow will look like when it is completed:
Final Version of the flow

This page will only cover the communication with the user. To actually reserve a coffee mug, we would have to integrate with a service; we will leave that part out for now.

Create the basic flow and populate the trigger

The first steps are to create a new flow and populate the trigger with relevant training examples.

  1. Select the 'Flows' folder and create a new flow by pressing the 'Flow' button.
  2. Once the flow has been created a new window will open, enter the flow name User wants to buy a coffee mug into the name field.
  3. Press the back button in the top left corner and select the trigger to open the trigger configuration panel.
  4. Give the trigger the name I want to buy a mug
  5. Add the positive learning examples below either one by one, or paste them all at once by clicking where it says, 'No Positive Examples' and use the shortcut Ctrl+V (alternatively, you can also right-click and choose Paste).

    Do you have branded mugs for sale?
    Can I buy a mug please?
    Do you sell mugs?
    Can I purchase a mug?
    Purchase coffee mug
    I want to buy a mug
    Do you have coffee mugs for sale?
    I would like to purchase a coffee mug
    I want to buy your coffee mug
    Do you sell longberry barista mugs? 
    I want to have a longberry barista branded mug
    I want to buy a mug!
  6. Now we need to add a match requirement. Click on the 'Generate' button under 'Match Requirements' section, this will automatically generate the best match requirement based on the example specification.

Add answer texts to the output

Now we will populate the output node with answer texts. In this case, the output node will be used to give the user information about the Longberry barista coffee mug and then ask a question, rather than just give a definitive answer.

  1. Select the output node, this will open the output configuration panel.
  2. Add an output name by and name it something like: Ask the user if they want to reserve a mug for in-store purchase.
  3. Add the following answers to the output node (use the Add button to add the individual answers):
    • The official Longberry barista coffee mug is only available for purchase in our store. Would you like me to reserve a mug for you?
    • Right now you can only buy our coffee mug physically in our store. Do you want me to reserve one for you?
    • Our coffee mug is only available for purchase in our store. Shall I reserve one for you?

Output nodes can contain multiple answer variations to make the conversation more dynamic. Teneo will choose any of these answers randomly and return it to the user.

A brief explanation of transitions

Before we start extending our flow with transitions, it might be a good idea to quickly go over the concept of transitions. Transitions link different flow nodes together and determine the paths a dialogue can follow within a flow.

By default, all transitions are set to 'Match Conditionally'. Simply put, if a transition is set to match conditionally it requires one or more match requirements. Transitions that have 'Match Conditionally' enabled but no assigned match requirements will get a yellow 'TODO' label as a reminder. When 'Match Conditionally' is enabled the most recent user input must match the set match requirements to continue down the transition. You can disable the match conditionally option for transitions. This means that the transition will allow any user input to continue down the transition as it has no match requirements. Transitions are also ordered, which tells Teneo in which order to test the match requirements on conditional transitions.

Transitions are by default set to ‘Wait for user input before continuing'. This means that the flow processing will stop and wait for the user to provide new input. If the user input fits the transition's match requirement the flow processing will resume along with the transition. If the transition is not set to wait for user input before continuing, the flow processing will not stop and wait for new user input. If this is the case, the most recent user input will be tested against the match requirement.

Transitions explanation

Add a transition for a user saying 'yes'

We have now reached the point in the flow where we expect the user is going to say either 'yes' or 'no'. Depending on what is said, the bot should react differently. Let us start with designing what should happen when the user says 'yes'.

  1. Select the output node 'Ask the user if they want to reserve a mug for in-store purchase'.
  2. Click on 'Output' in the ribbon bar at the top. This will add an output node, linked to the first output node via a transition (the line that connects both output nodes).

Now the branch is in place. Teneo will automatically select the newly created output node for you.

Add an answer text

The first step to complete the 'yes' branch is to specify how your bot should respond when the user says 'yes'. The output node after the transition should be selected:

  1. Give the output a descriptive name like: I have reserved a coffee mug for you.
  2. Finally, add the answer text: I have reserved a Longberry barista coffee mug for you.

So far, you have created two flows in your solution, each containing one trigger with a class match requirement. But in the next section, you will get to add a language object-based match requirement to a transition.

Add a Language Object Match Requirement

Now we need to make sure that Teneo only goes down this transition (the line that connects both output nodes) when the user says ‘yes’. To achieve this, we need to add a new type of match requirement, namely a language condition. Simply put, language conditions check if a user input matches a certain pattern. They can be generated from a set of examples or you can specify them directly. Let's generate one from a set of example inputs.

  1. Open the transition configuration panel by selecting the transition that goes from the output node 'I have reserved a coffee mug for you'.
  2. Give the transition the name User says 'Yes'. This increases the readability of the flow and makes debugging easier.
  3. In the examples panel, paste the following examples:
    Yes
    Indeed
    Yep
  4. Finally, click on the 'Generate' button under 'Match Requirements' section, this will automatically generate the best match requirement based on the example specification.

After a few seconds, the match requirement field will get the value (%YES.PHR). This is the 'Match Requirement' for 'Language Objects' that was generated. The language condition uses a 'language object' called YES.PHR, which recognizes various phrases (hence the suffix .PHR) that mean 'yes', like 'by all means', 'absolutely' and 'yup'. This perfectly covers our need for this transition. Note that there is a lot more you can do with language conditions, but that will be covered later.

If the language condition that was generated is not (%YES.PHR), make sure you have assigned the lexical resources in your solution.

The condition used as a match requirement in this example is based on the provided examples, and unlike class, there is no ‘condition manager’. This means that all conditions are managed on the node or transition itself.

So far, we have only added one match requirement per trigger and transition and only explored two different types of match requirements, class, and language objects. However, triggers and transitions can contain one or more match requirements. It is also possible to mix the match requirement types depending on what the use-case requires, this is however not going to be covered on this page. You can read more about it here.

Add a branch and an answer for the user saying 'no'

Now, we will specify what should happen when the user says 'no'. We'll follow the same steps as when adding the first branch:

  1. Select the output node 'Ask the user if they want to reserve a mug for in-store purchase'.
  2. Click on 'Output' in the ribbon bar at the top. This will add an output node, linked to the first output node with a transition.
  3. The new output node will be selected by default.
  4. Give it the name: Ok, I will not reserve a coffee mug for you.
  5. We can reuse the name of the output node as our answer text.

Add a condition for the user saying 'no' and save the flow

Almost there! We need to make sure that Teneo only goes down this transition when the user says ‘no’.

  1. Open the transition configuration panel by selecting the transition that goes from the output node 'Ok, I will not reserve a coffee mug for you'.
  2. Give the transition the name User says 'No'.
  3. Add a few example inputs in the examples panel:
    No
    Never
    Nope
  4. Select the 'Generate' button under 'Match Requirements' section, this will automatically generate the best match requirement based on the example specification. Note that this time the 'Match Requirement' generated NO.PHR.

Finally, save your flow by clicking 'Save' in the top left or use the shortcut Ctrl+S.

Do you see that there are numbers on the transitions (1 and 2 respectively)? These numbers represent the order in which Teneo will test the conditions. You can adjust this order by having the transition selected, then use the arrows found under the two checkboxes 'Get input before continuing' and 'Match conditionally' to increase or decrease the order of the selected transition.

Try it out!

That's it! If you would like to test the flow from within Studio, minimize or close the flow, if the 'Try Out' window is not open, you can reopen it panel in the 'Solutions' window and have a go.

Notice the Flow Updated message? The Try Out panel is also used for the bot to communicate with you. When something is updated or wrong the Try Out will print a message for you.

Summary

You've just created your first interactive flow and used the following components:

  • Match requirement: used to set criteria that the user's input must match.
  • Multiple answer variation: used to make the bot's responses more dynamic.
  • Language condition: which you can use to ensure that the user input matches a certain pattern.
  • Transitions: determine the path your dialog should take.

Test yourself

Try to add one more branch but this time if the user doesn't answer with a Yes or No. Make sure to test your flow in Try Out.

What's next?

Now that you know how transitions work. Let's continue with the Class Manager and how to add training examples.

Was this page helpful?