Use a Flow link
Some flows may be re-used as parts of other flows. In Teneo, you can link flows between each other to do so. For example, requesting the user's email address can be implemented as an action you take at the end of a conversation to print out a receipt or something similar. In the following, we will build two flows, one for the user asking to subscribe for newsletter, and one flow to finish it off and actually grab the email address.
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:
- Build the email flow.
- Build the main flow.
Build the email flow
Our first flow is 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 flow will look as follows:
This flow can later be reused if the user for some reason provide their email address to the bot. Some examples include asking for an order confirmation, or in our case to subscribe to the newsletters.
Create a global variable
We will start off by creating a global variable that will hold the users email. If its already provided we will avoid to ask for it again.
- Navigate yourself to the Solution Dashboard, and select the Plus button in Globals, 'Variables'.
- Give the variable a fitting name like,
userEmail
. Initialize it to empty string""
.
Create an email flow
First we will create a new to grab the users email.
- Go back to the 'Flows' folder.
- Create a new flow and call it
Get email address
. - Give the intent the same name.
- Click on the 'Edit' button, located at the right corner of the intent. This will allow the user to, enter the following examples:
Can you update my email?
Tell me how to update my email address
Can you register my email
I want my email to be registered
Could you please register my email
Register my email
what's my email?
what is my email?
- Proceed with closing the edit view.
- Finally it is time to add a Match to the intent. This can by done by clicking on the Plus(+) icon that has a yellow 'TODO' label beside it.
- Navigate to 'Match' and click on the 'Generate' button to automatically generate a Match based on the example specification.
Add a prompt for e-mail
- Find the output node and name it
Prompt for email
. - Give it the output
Please enter your email address.
- Add a new output node to follow it by clicking the Plus icon followed by 'Continue with' and 'Transaction'.
- Select the Plus button below the transition and add a Match for 'TLML Syntax'.
- Add the Syntax Condition
%EMAIL_ADDRESS.SCRIPT^{userEmail = _USED_WORDS}
. - Call the new transition
Email entered
. Make sure it has a 'GIVE RESPONSE' banner before.
Set up the email flow to re-prompt
- Locate the Output node. Name it
Confirm email
and give it the answerI have your email as ${userEmail}, is that correct?
. - 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'.
- 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'.
- Now click on the same Plus icon again, this time selecting 'Match' and 'Language object'.
- Paste in the following:
NO.PHR
. This will cover various versions of the word "no".
Set up a positive confirmation of the email
- Click on Plus icon above the Match containing the 'NO.PHR' language object. Select 'Split Path' and 'Transaction'.
- Select the Output node at the end of this path and name it
Email confirmed
. - Add the following answer:
OK, thank you! I'm adding your address ${userEmail}. You will receive a confirmation mail shortly.
- Name the User Intent above this output node
Confirmed
and add the following examples:
yeah
yup
yes
- 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.
- 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 will show you how exactly to do that.
Build the main flow
At this point, we have a flow to capture emails that is not being used anywhere. In this section, we will build a flow that will be triggered if users request to be added to the Longberry Baristas mailing list. Later this flow will make use of the flow 'Get email address' that we created above. But for now, we will just build the question and answer. We'll add the flow link later.
Create the new flow
- Go back to the folder where you store your flows.
- Create a new flow and name it
User wants to subscribe to the mailing list
. - Navigate to the trigger, call it
Subscribe to the mailing list
and add the following positive Intent 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
- Generate a Match using the Plus icon under the trigger, followed by Match and Generate.
- Call the output node
Happy to add you to our mailing list
. - Select the output node and add an answer
I would be happy to add you to our mailing list to receive our free newsletter.
.
Add a call to the email flow
Now we want to pass control to the email flow and let it do all the work of prompting the user for an email address.
- Click on the Plus icon below the output node 'Happy to add you to our mailing list.'. Click 'Continue With' and 'Flow Link'.
- Navigate to the Flow node and call it
Get email address
. - In the 'Get email address' node, make sure to select our flow 'Get email address' inside the 'Flows' folder.
Finish the flow
There might be cases where the email of the user is known, and you don't need to collect it again. Lets build a path for these scenarios.
- Select the Plus icon above the flow link and choose 'Split Path', followed by 'transaction element' and 'Output'.
- Above the new output, add a 'Match' for 'Global Variable', and select 'userEmail' as the condition.
- Call the output node
Confirmation
. - Lastly, give the output an answer
I'm adding your address ${userEmail} to our mailing list. You should receive a confirmation mail shortly.
. - 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 email 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. You will receive a confirmation mail shortly.
If you try to trigger this flow again during the same session, you will discover that Teneo remembers your email and prompts you directly to the 'Confirmation' output node without asking for your email again.