Create an interactive flow

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.

We'll use the following example, where the bot needs a confirmation from the user before it proceeds to reset the password:

User: I forgot my password.
Bot: Would you like me to reset your password?

User: Yes.
Bot: I've reset your password. You'll receive a confirmation email shortly.


User: I've forgot my password.
Bot: Would you like me to reset your password?

User: No.
Bot: Ok, I won't reset your password.

This is what your flow will look like:

final flow

This page will only cover the communication with the user. To actually reset the password you 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 mostly the same as when you created Your first flow.

  1. Select the 'Flows' folder and create a new flow with a class trigger via the Flow button.
  2. Once the flow has been created a new window will open, enter the flow name User wants to reset the password into the name field.
  3. After you have named the flow, hit the back button in the top left to get out to the actual flow.
  4. Let's go ahead and populate the trigger, select the class trigger and make sure that the 'Learning Examples' panel to the right is active.
  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):
    Can you reset my password?
    I need some help with reseting my password
    I forgot my password
    Would you be able to help me reset my password
    I have forgotten my password
    I need a new password!
    I want to reset my password
    Password reset
    Please can you reset my password
    I've lost my password
    I don't remember my password.
    I have lost my password.
    Reset my password please
    Could you reset my password?
    I have lost my pass word
  6. Give the class trigger a descriptive name, for example I forgot my password (you will find the name field along the bottom of the window).

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 ask a question to the user, rather than give a final answer.

  1. Select the output and add the following answers to the output node (use the Add button to add the individual answers):
    • Would you like me to reset your password?
    • Shall I reset the password for you?
    • Do you want me to reset your password?
  2. Give the output node a name: Ask user for confirmation.

Add a branch for user saying 'yes'

At this point in your flow, we expect the user to say either 'yes' or 'no'. Depending on what is said, the bot should react differently.

First you'll design what should happen when the user says 'yes'.

  1. Select the output node 'Ask user for confirmation'.
  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.

Now the branch is in place. Teneo will automatically select the transition (the line that connects both output nodes) and open the 'Examples' panel for you.

Add a condition

Next we need to make sure that Teneo only goes down this transition when the user says ‘yes’. To achieve this, we need to make the transition conditional and add 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. First we need to make the transition conditional by clicking the switch next to the label that says the transition is currently Unconditional. As you can see this will allow us add example inputs and it will also open an second panel, called 'Condition'.
  2. In the examples panel, click the 'Positive' tab and paste the following examples:
  3. Now we should generate a language condition based on the examples. Click the 'Now' button in the 'Condition' panel to tell Teneo to generate a condition using the example inputs.

After a few seconds the condition field will get the value (%YES.PHR). This is the language condition 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 'yessir'. 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 in later.

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

Before we proceed, let's give the transition the name yes. This makes the flow look nicer, and makes debugging easier.

Add an answer text

To complete the 'yes' branch we need to specify how your bot should respond when the user says 'yes'. Select the output node after the transition and add the answer text: I've reset your password. You'll receive a confirmation email shortly.

And finally, give the output a descriptive name like: I've reset your password.

Add a branch and condition for user saying 'no'

Now, we'll 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 user for confirmation'.
  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. Make sure the transition is conditional.
  4. Add a few example inputs in the examples panel:
  5. Generate the condition in the condition panel
  6. Give the transition the name no.

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.

Add an answer text and save the flow

Almost there! Next we will add an answer to the final output and give it a descriptive name. For example:

  • Ok, I won't reset your password.

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

Try it out!

That's it! If you'd like to test the flow from within Studio, minimize or close the flow, open the 'Try out' panel in the 'Solutions' window and have a go.

Note: if you have just saved your flow the 'Try out' panel will show model training started followed by model training completed. This means Teneo is learning the new training examples you just created. After training has completed you will be able to test the new content.

Where to go next?

In these first tutorials you have familiarised yourself with some of the core concept of Flows in Teneo, like triggers, outputs, transitions and language conditions. There are many more possibilities for designing your dialogs, so this might be a good time to explore the Flows section. It is divided into two parts:

  • Concepts: here you will find more detailed information about the core elements that make up your flows.
  • How to's: here you will find practical step by step guides to create different types of flows that allow you to achieve things like using entities or slot filling.

Let's continue to Flows.

Was this page helpful?