This is a tutorial series that's cumulative in nature. To start from the beginning, start here.
A dialog is a group or flow of interactions that are triggered based on consumer intent. In this lesson, you create a Voicebot and a few dialogs therein.
Step 10: Create the bot
-
Open the menu on the left side of the page, and select Automate > Conversation Builder.
- Click New Bot in the upper-right corner.
-
In the Choose a Bot Template window, click the orange arrow that appears when you move the mouse over the Custom Bot template in the Custom category.
-
Specify the following:
- Name: Pharmacy Bot
- Channel Type: Voice
-
Click Create Bot.
This takes you to the new bot in Conversation Builder. And it opens the Welcome dialog. A dialog is a group or flow of interactions that are triggered based upon consumer intent. Since you selected the Custom Bot template when you created the bot, by default this creates a bot with 2 dialogs:
-
Welcome: This dialog is triggered after the call is set up and ready for the conversation. Once the call is ready, the system automatically sends the pattern
initialize_conversation_voice
to the bot, and the bot starts the conversation. In the Voice channel, the bot always starts the conversation because it’s the consumer who called in the first place. So, the bot speaks first, saying, “Hi there! Thanks for calling!” Learn more about how Voice conversations begin. -
Fallback: This dialog is triggered when the bot doesn’t recognize the consumer’s message.
Let’s use the Preview tool to test the conversational flow so far. Keep in mind that, while Preview is helpful as you build out the bot flow, the primary way to test your bot is by phone. You’ll do that in a later step.
-
-
Click Preview in the upper-right corner.
This starts the conversation, so it triggers the Welcome dialog.
The Preview tool lets you preview the conversational flow when the speech is played and when it isn’t.
-
Click If speech is played.
This doesn’t move the flow along because we haven’t built out the bot yet.
-
Still in the Preview window, enter, “I want to refill my prescription.” Then click If speech is played.
This consumer query regarding a prescription refill triggers the Fallback dialog to begin its flow because the bot can’t handle this intent. So, you see the following:
-
Over in the Dialogs panel on the left, select the Fallback dialog to examine the interaction therein.
-
Change the fallback response, so it uses more expressive, more informal language. Replace it with, “I’m sorry! I don’t understand.” Click Save in the interaction.
-
In the Preview window, click Reset & start, so a new session is started, which ensures your changes are picked up.
-
Enter the following again: “I want to refill my prescription.”
You should see the updated fallback response:
-
Back in the Welcome dialog, change the bot’s welcome response: In the speech statement interaction, enter, “Hi there! I'm Anna, your automated voice assistant. Thanks for calling! How can I help you today?” (Remember to save the changes.)
Being transparent about the use of an “automated assistant” is a Conversational Design best practice.
-
Return to the Preview tool and test the changes. (Remember to click Reset & start to pick up your changes.)
(Learn about the different parts of the workspace in Conversation Builder.)
Step 11: Add the Refill Prescription dialog
- Click Add Dialog in the lower-left corner.
-
Specify the following:
- Dialog Name: Refill prescription
- Dialog Type: Dialog (This is the default value.)
-
Click Save.
The dialog is created and includes an empty Dialog Starter interaction. As you might surmise by the name, a dialog starter is the way that a dialog is started. That is, if the consumer’s response matches an intent or pattern that’s set in the dialog starter, that dialog’s flow begins.
Let’s set that up now.
-
In the dialog starter, click + Intent.
This opens the Assist tool.
-
In Assist, select the “Pharmacy” domain.
-
Select the “Refill prescription” intent.
This associates the intent with the dialog starter.
Now, whenever the consumer says something that matches the “Refill prescription” intent, the Refill Prescription dialog is triggered. And its flow begins.
Let’s flesh out the dialog flow.
-
Beneath the dialog starter, click New Interaction, and select the Speech statement interaction.
-
Name the interaction, “Acknowledge refill” in the upper-left corner. And enter the statement: “Got it. I can help with that.”
-
Beneath the statement, click New Interaction again, and select the Speech question interaction.
- In the upper-left corner of the question, name the question “Get prescription number.”
-
For the question enter: “What’s your seven digit prescription number?”
The bot will always listen for a spoken response from the consumer, but you can turn on Accept touch-tone input if you also want to allow the consumer to respond using the keypad on their phone. If you enable this setting, the bot will listen for touch tones (DTMF input) in addition to speech.
- Click Accept touch-tone input. Then click Settings beside it.
-
In the settings, specify the following:
- Minimum Digits: 1
- Maximum Digits: 7
- Inter-digit Timeout: 2500
- Still in the settings, click the Advanced tab.
-
For Elapsed time before prompt, enter “7000”.
This should give the caller sufficient time to answer before being prompted again.
-
Click Save.
Now let’s add a custom rule that 1) verifies that the number entered by the consumer is seven digits, and 2) saves the consumer’s prescription number to a variable if it is seven digits, so we can use the number later.
-
In the speech question, under Next Action, click Go To: Next Interaction, and then click + Custom Rule.
- In the pop-up window, name the rule “7 digits.”
-
Click + Add Condition, and specify the following:
-
When the user matches any of the following conditions: Select “Regular Expression” and enter
^\d{7}$
as the RegEx value. -
Then perform the following: Click + Add Variable. Enter “prescriptionNumber” for the variable name. Enter
{$userMessage}
for the variable’s value. Keep the duration as “Session.” - And go to: Leave this as “Go To: Next Interaction”
-
When the user matches any of the following conditions: Select “Regular Expression” and enter
- Click Save.
- Add the interaction to play when the consumer enters a valid 7-digit prescription number: Click New Interaction, and select the Speech statement.
-
In the interaction, enter, “Great! Thanks! We’ve got your info. We’re working on prescription number
{$botContext.prescriptionNumber}
now. Your prescription will be ready in 2 hours.”Ordinarily, before playing this message, you’d use an Integration interaction to tie into your pharmacy’s prescription fulfillment system and process the refill. But for the purpose of this tutorial, we’ll just assume this happened, and display the confirmation message straight away.
-
Set the interaction’s next action to “End Interaction.”
“End Interaction” stops the flow within the dialog.
-
Save the interaction.
Let’s preview the flow so far using the Preview tool.
-
Open Preview if needed. Or, click Reset & start if it’s already opened.
- Enter, “I want to refill my prescription.”
-
Enter any 7-digit number.
Now let’s build out the flow for when the consumer enters an invalid prescription number.
-
At the bottom of the dialog, click New Interaction, and add a Speech statement.
-
In the interaction:
- Name the interaction “Not seven digits”
- For the statement, enter: “I’m sorry. That’s not a seven digit number. Please try again.”
- For the next action, select the “Get prescription number” interaction in the same dialog.
You need to add another rule that directs the conversation flow to this new interaction when the consumer doesn’t enter a 7-digit number.
- Return to the “Get prescription number” question, and click + Custom Rule.
- In the pop-up window, name the rule “Anything else.”
-
Click + Add Condition, and specify the following:
- When user matches any of the following conditions: Select “No Match”
- And go to: Select the “Not seven digits” statement in the same dialog
-
Click Save.
-
Use the Preview tool to test out the new flow.
In this lesson, you worked with Speech statements and Speech questions because the bot only uses TTS. But keep in mind that Voicebots also support Audio statements and Audio questions; these are for pre-recorded audio. While a text-to-speech (TTS) solution can be easier to build and maintain in the long run, use of pre-recorded audio is sometimes useful.
Step 12: Add the Schedule Vaccine dialog
- Click Add Dialog in the lower-left corner, and create a new dialog named “Schedule flu vaccine” of type “Dialog.”
-
Link the dialog starter to the “Pharmacy” domain, and then to the “Schedule flu vaccine” intent.
-
Add a statement interaction that simply says, “To schedule a flu vaccine, visit our website at www.acmemedical.com/vaccines.” Name the interaction “Acknowledge flu vaccine” in the upper-left corner.
-
Save the interaction, and test it in the Preview tool.
Step 13: Add an IVR menu
- Return to the Welcome dialog: Select it in the dialogs panel to open it in the dialog editor.
-
In the speech statement, remove the question at the end, which is, “How can I help you today?” Then save the changes.
- Beneath the speech statement, add a speech question.
- In the question, enter the question: “To refill a prescription, press or say 1. To schedule a vaccine, press or say 2.”
-
Turn on Accept touch-tone input.
-
Go into the Advanced tab in the interaction settings, and set the Elapsed time before prompt to “7000”.
Next, we add a custom rule that checks whether the consumer pressed 1 or said “one” to refill a prescription. So we can direct the conversation flow accordingly.
-
Still in the question, add a custom rule named “Refill prescription.” In the rule, add two conditions that check for exact values of “1” and “1.” (with a period). If either condition is true, the flow should go to “Acknowledge refill” interaction in the Refill Prescription dialog.
You must add both conditions because, if the question supports touch-tone input, and the consumer enters “1”, the bot receives “1”. And if the consumer says “one”, the bot might receive either “1” or “1.” You must account for both possibilities.
-
Add a second rule named “Schedule flu vaccine.” In the rule, add two conditions that check for exact values of “2” and “2.” (with a period). If the conditions are true, the flow should go to “Acknowledge flu vaccine” interaction in the Schedule vaccine dialog.
-
Test the flow of the IVR menu using the Preview tool.
Step 14: Add the Anything Else dialog
In this step, you create a dialog named “Anything else” to support the flow when the bot asks, “Is there anything else I can help you with today?”
- Create a regular dialog named “Anything else.”
-
Delete its Dialog Starter interaction.
-
Add a speech question:
- Name it “Ask if anything else.”
- Enter the following question: “Is there anything else I can help you with today?”
- Go into the Advanced tab in the interaction settings, and set the Elapsed time before prompt to “7000”.
-
Follow the speech question with another question to play if the consumer says Yes, and a statement to play if the consumer says No, as shown below. The No statement should specify “Close Conversation” as its Next Action.
- Scroll up to the top of the dialog.
-
In the dialog-level context menu, select Dialog Settings.
-
For Domain, select the “LP_Cross-vertical” domain that you extended to include intents for yes and no responses. Click Save.
Associating the domain to the dialog makes available the intents in the domain, so you can take advantage of them in the dialog.
-
Move to the first interaction in the dialog, which is a question. In the interaction, create a rule named “Yes” that directs the flow to the next interaction (“What’s your question or query?) if the consumer’s response matches the “Yes response” intent.
-
Create another rule named “No” that directs the flow to the “goodbye” statement if the consumer’s response matches the “No response” intent.
The consumer might just ask their next query straight away, instead of simply answering “yes” or “no.” But this will trigger one of the other core business dialogs. And if it doesn’t, it will trigger the fallback dialog.
-
Return to the Refill Prescription dialog, and locate the interaction that thanks the consumer. Change its next action to redirect the flow to the first question in the “Anything else” dialog.
-
Do likewise at the end of the flow in the Schedule Vaccine dialog.
-
Test the experience in the Preview tool, for example:
What's next?
Continue on to the next tutorial in the series.