Create a sub-flow that can be re-used in Teneo Studio
By: Artificial Solutions
Tags: Conversational Ai, Chatbots, Chatbot Development, Chatbot Platforms, Chatbots For Business

What if there is a certain flow that you want to be using multiple times for you chatbot? In Teneo Studio it is possible to use sub-flows.

That means that 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 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: 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:

Build the sub-flow. 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:

Create a subflow

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

Create a new flow and call it Get email address . In the ‘Flow’ tab, under ‘Variables’, Add a flow variable called email and initialize it to empty string "" . Click the arrow to return to the ‘Home’ tab. 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

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

Set up the sub-flow to re-prompt

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

Set up a positive confirmation of the email

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

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 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

Create a flow and name it User wants to subscribe to the mailing list . In the ‘Flow’ tab under ‘Variables’, add a flow variable called email and initialize it to empty string "". Click the arrow to return to the home page. 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 Select the output node and add an answer I'm happy to add you to receive our completely free newsletter. . 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.

Select the ‘Happy to add you…’ output node and add a ‘Flow’ node leaving it. Name the transition Call sub-flow and make sure it is 'Unconditional' and set to 'Continues without input'. Call the ‘Flow’ node Get email address . With the ‘Get email address’ node selected, make sure the sidebar area ‘Flow Link’ is visible. Click ‘Browse’ and select our subflow ‘Get email address’. 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

Select the sub-flow node and add a new output node. Call the transition Return from sub-flow and make sure it is 'Unconditional' and set to 'Continues without input'. Give the output an answer I'm adding your address ${email} to our mailing list. You should receive a confirmation mail shortly. . Call the output node Confirmation . 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.