Teneo Developers

Introduction to 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 Baristas 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 Baristas coffee mug for you.

or

User: I want to buy a coffee mug.
Bot: The official Longberry Baristas 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
  • Add an output response in the form of a question.
  • Create a 'yes' transition if the user replies with 'yes'.
  • Add output response for the 'yes' scenario.
  • Create a 'no' transition if the user replies with 'no', 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 flow layout

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. Start by doing the following:

  1. Navigate to the 'Flows' folder and create a new flow.
  2. Enter the flow name User wants to buy a coffee mug into the name field.
  3. Click on 'Create' to create the flow.
  4. Navigate to the trigger and name it I want to buy a mug.
  5. Add the positive learning intents below by clicking on the 'edit' button.
  • 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!
  1. Now we need to add a Match. Click on the Plus icon below the Intent trigger, followed up with 'Match' and 'Generate'. This will automatically generate the best Match requirement based on the User Intents.

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. Navigate to the output and enter a name like Ask the user if they want to reserve a mug for in-store purchase.
  2. Add the following answers to the output node (each line represents an output):
  • The official Longberry Baristas 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 allows you to either randomly choose an answer and return it to the user, or to set order for the outputs to be returned.

Add two transitions

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 adding these transition.

  1. Located under the output node 'Ask the user if they want to reserve a mug for in-store purchase', click on the Plus icon, followed up with 'Fork To' and 'Multiple complete transactions'. You will now have the option to select the number of times the output should be forked.
  2. Enter '2' and click on confirm. Notice that two new paths are shown for the user to take. These will now be edited to cover the 'yes' and 'no' options.

So far, you have created two flows in your solution, each containing one trigger with a Class Match. But in the next section, you will get to add a Language Object-based Match to a transition.

Add a Language Object Match

Now we need to make sure that one of the paths only matches (the line that connects two 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. Navigate to the the transition located to the left.
  2. Give the transition the name User says 'Yes'. This increases the readability of the flow and makes debugging easier.
  3. Paste the following Intent examples:
  • Yes
  • Indeed
  • Yep
  1. Finally, click on the Plus icon, followed up with 'Match' and 'Generate', 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' 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.

The condition used as a Match in this example is based on the User Intents, 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 per trigger and transition. We have only explored two different types of Matches, 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 an answer text

The last step to complete the 'yes' branch is to specify how your bot should respond when the user says 'yes'. The output node below the 'User says Yes' 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.

Create the path 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. Navigate to the transition located to the right.
  2. Give the transition the name User says 'No'.
  3. Paste the following Intent examples:
  • No
  • Never
  • Nope
  1. Finally, click on the Plus icon, followed up with 'Match' and 'Generate', this will automatically generate the best Match requirement based on the example specification.

Add an answer text for 'no'

Almost there! Now we need to make sure that the reply is recognized and taken care by the flow.

  1. Navigate to the Output node below the transition.
  2. Give it the name: Ok, I will not reserve a coffee mug for you.
  3. We can reuse the name of the output node as our answer text.
  4. Finally, save your flow by clicking 'Save'.

Try it out!

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

Summary

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

  • Match, which are 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, which determine the path your dialogue should take.

Test yourself

Try to add one more branch, but this time for if the user answers with an answer that does not meet the match requirements of the Yes or No transitions. Make sure to test your flow in Try Out!