Use a sub-flow

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 adress can be realised 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: franks@gmail.com
Bot: I have your email as franks@gmail.com. Is that correct?

User: no
Bot: Please enter your email address.

User: frank@gmail.com
Bot: Is your email address frank@gmail.com correct? Please confirm.

User: yes
Bot: OK, thank you! I'm adding your address frank@gmail.com to our mailing list. 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 mail. 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: Subflow to query and return email

Create a subflow

First we will create a new flow and turn it into a subflow.

  1. Create a new flow and call it Get email address.
  2. In the 'Flow' tab, under 'Variables', Add a flow variable called email and initialize it to empty string "".
  3. Click the arrow to return to the 'Home' tab.
  4. In the ribbon bar of the 'Home' tab, click the 'Sub-Flow' button, in the section 'Flow Entry'. This will replace the default trigger with a blue dot.

Add a prompt for email

  1. Select the output node and give it the output Please enter your email address.
  2. Name the output node Prompt for email.
  3. With the output still selected, add a new output node to follow it.
  4. Select the new transition and call it Email entered.
  5. Make sure it is set to 'Conditional' and 'Gets input before continuing'.
  6. Add the condition %EMAIL_ADDRESS.SCRIPT^{email=_USED_WORDS}.

Set up the sub-flow to re-prompt

  1. Select the second output and give it an answer I have your email as ${email} is that correct?.
  2. Name the output node Confirm email.
  3. Select the 'Confirm email' output node and using the mousekey, drag and drop a transition back to the output 'Prompt for email'.
  4. Make sure the transition is set to 'Conditional' and 'Gets input before continuing'.
  5. Call the transition Re-try and give it the condition %NO.PHR.

Set up a positive confirmation of the email

  1. Select the output node 'Confirm email'.
  2. Add a new output node to follow it.
  3. Select the transition and make sure it is set to 'Conditional' and 'Gets input before continuing'.
  4. Paste %YES.PHR into the condition field and name the transition Confirmed.
  5. Give the new output node a response OK, thank you! and rename the node Thank user.
  6. Click save.

That's it! We can now use this sub-flow that requests the user's email adress in as many other flows as we want. In the next section we 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. In the 'Flow' tab under 'Variables', add a flow variable called email and initialize it to empty string "".
  3. Click the arrow to return to the home page.
  4. Select the trigger, call it Subscribe to the mailing list and add positive learning examples:
    Can i get your newsletter?
    How can i subscribe to the newsletter?
    How to get on your mailing list?
    I want to subscribe to your mailing list
    I'd like to subscribe to the newsletter
    Please add me to your mailing list
    Please put me on the mailing list
  5. Select the output node and add an answer I'm happy to add you to receive our completely free newsletter..
  6. Call the output node Happy to add you to our mailing list.

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. Select the 'Happy to add you...' output node and add a 'Flow' node leaving it.
  2. Name the transition Call sub-flow and make sure it is 'Unconditional' and set to 'Continues without input'.
  3. Call the 'Flow' node Get email address.
  4. With the 'Get email address' node selected, make sure the sidebar area 'Flow Link' is visible.
  5. Click 'Browse' and select our subflow 'Get email address'.
  6. Retrieve the email address from the subflow: in the section 'From' where you see 'Get the value back' select email from the dropdown list as illustrated here:

Finish the flow

  1. Select the sub-flow node and add a new output node.
  2. Call the transition Return from sub-flow and make sure it is 'Unconditional' and set to 'Continues without input'.
  3. Give the output an answer I'm adding your address ${email} to our mailing list. You should receive a confirmation mail shortly..
  4. Call the output node Confirmation.
  5. Hit 'Save'.

That's it! You may now give it a go in try out and replicate the conversation below. Note that the answer parts from the sub-flow are underlined 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: frank@gmail.com
Bot: I have your email as frank@gmail.com, is that correct?
User: Yes.
Bot: OK, thank you! I'm adding your address frank@gmail.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.

Was this page helpful?