Teneo Developers

Use a Flow link

Some flows may be re-used as parts of other flows. In Teneo, you can use Sub-Flows to do so. For example, requesting the user's email address can be implemented as a Sub-Flow that can then be used in larger flows. In the following, we will build both the Sub-Flow and a flow that makes use of it.

This is how a conversation should look:

User: I'd like to subscribe to your newsletter
Bot: I'm happy to add you as a recipient of our free newsletter. Please enter your email address.

User: teneo@example.com
Bot: I have your email as teneo@example.com. Is that correct?

User: no
Bot: Please enter your email address.

User: teneo@example.com
Bot: Is your email address teneo@example.com correct? Please confirm.

User: yes
Bot: OK, thank you! I'm adding your address teneo@example.com. You will receive a confirmation mail shortly.

We will implement the conversation in two steps:

  1. Build the Sub-Flow.
  2. Build the main flow.

Build the Sub-Flow

Our Sub-Flow to retrieve the user's email will ask the user to enter an email address, confirm with the user that the email was correct, and if correct, return the email. If not correct, the user will be re-prompted. This continues until a correct email was entered. The final Sub-Flow will look as follows:

final sub flow

Create a Sub-Flow

First we will create a new Sub-Flow.

  1. You can create a new Sub-Flow by clicking on the Create button and selecting 'Sub Flow' from the dropdown menu.
  2. Name the Sub-Flow Get email address.
  3. Add a variable and name it email. Initialize it to empty string "" and click on 'Add'.
  4. Click on 'Create' to create your flow.

Add a prompt for e-mail

  1. Select the output node and name it Prompt for email.
  2. Give it the output Please enter your email address.
  3. Add a new output node to follow it by clicking the Plus icon followed by 'Continue with' and 'Transaction'.
  4. Name the new transition Email entered.
  5. Click the Plus icon underneath the transition, followed by 'Match' and 'TLML Syntax'.
  6. Add the Syntax Condition %EMAIL_ADDRESS.SCRIPT^{email=_USED_WORDS}.

Set up the Sub-Flow to re-prompt

  1. Locate the Output node. Name it Confirm email and give it the answer I have your email as ${userEmail}, is that correct?.
  2. Navigate to the bottom of the 'Confirm email' output node and using the mousekey, drag and drop a transition back to the output 'Prompt for email'.
  3. Click on the Plus icon on the newly created transition between 'Confirm email' and 'Prompt for email'. Select 'Continue with' and 'transaction element' followed by 'Response'.
  4. Now click on the same Plus icon again, this time selecting 'Match' and 'Language object'.
  5. Paste in the following: NO.PHR. This will cover various versions of the word "no".

Set up a positive confirmation of the email

  1. Click on the Plus icon above the Match containing the 'NO.PHR' language object. Select 'Split Path' and 'Transaction'.
  2. Select the Output node at the end of this path and name it Email confirmed.
  3. Add the following answer: OK, thank you! I'm adding your address ${userEmail}. You will receive a confirmation mail shortly.
  4. Name the User Intent above this output node Confirmed and add the following examples:
  • yeah
  • yup
  • yes
  1. Finally, generate a Match. Click on the Plus icon above the output node (the Plus icon will have a yellow 'TODO' message next to it) and select 'Match' and 'Generate' to automatically generate a Match requirement based on the Intent example specification. In this case we will generate language object YES.PHR. This will let you proceed if the email stored is correct.
  2. Save the flow.

That's it! We can now use this Sub-Flow that requests the user's email address in as many other flows as we want. In the next section, we will show you how exactly to do that.

Build the main flow

At this point, we have a Sub-Flow that is not being used anywhere. Since it doesn't have a trigger, Teneo will never select it. In this section, we will build a flow to trigger if users request to be added to the Longberry Baristas mailing list. Later this flow will make use of the Sub-Flow 'Get email address' that we created above. But for now, we will just build the question and answer. We'll add the Sub-Flow link later.

Create the new flow

  1. Create a flow and name it User wants to subscribe to the mailing list.
  2. Add a flow variable called email and initialize it to empty string "". Click 'Add' to add the variable.
  3. Click on 'Create' to create the flow.
  4. Name the trigger Subscribe to the mailing list and add the following positive Intent examples:

    example-inputs

    1Can i get your newsletter?
    2How can i subscribe to the newsletter?
    3How to get on your mailing list?
    4I want to subscribe to your mailing list
    5I'd like to subscribe to the newsletter
    6Please add me to your mailing list
    7Please put me on the mailing list
    8
  5. Click on Plus icon below the trigger, followed by 'Match' and 'Generate' to automatically generate the best Match based on the example specification.
  6. Call the output node Happy to add you to our mailing list.
  7. In the output node, add the answer I would be happy to add you to our mailing list to receive our free newsletter..

Add a call to the Sub-Flow

Now we want to pass control to the Sub-Flow and let it do all the work of prompting the user for an email address.

  1. Click on the Plus icon below the output followed by 'Continue With' and 'Flow Link'.
  2. Using the dropdown menu, locate our 'Get email address' Sub-Flow.
  3. Retrieve the email address from the Sub-Flow: in the section 'From', where you see 'Get the value back', select email from the dropdown lists.

Finish the flow

  1. Select the Plus icon below the 'Flow' node and add a new output node by selecting 'Continue With', followed by 'Transaction Element Output'.
  2. Call the output node Confirmation.
  3. Lastly, give the output an answer I'm adding your address ${email} to our mailing list. You should receive a confirmation mail shortly..
  4. Hit 'Save'.

That's it! You may now give it a go in Tryout and replicate the conversation below. Note that the answer parts from the sub-flow are italic for illustrative purposes. In practice, they will not be distinguishable from the answers of the main flow:

User: I want to subscribe to your newsletter!
Bot: I'm happy to add you to receive our completely free newsletter. Please enter your email address.

User: teneo@example.com
Bot: I have your email as teneo@example.com, is that correct?

User: Yes.
Bot: OK, thank you! I'm adding your address teneo@example.com to our mailing list. You should receive a confirmation mail shortly.

Note that if the name of the Sub-flow should change at some point, all existing connections between main flows and this Sub-flow will automatically be updated by Teneo.