Putting the user on hold in chatbot
Learn how to put the user on hold during an interaction with a chatbot.
About this task
In this tutorial, you will:
- Set the bot language
- Start the bot execution context
- Send text messages
- Put the user on hold
- Navigate to a website
Before you begin
To develop the script, you need:
- One of the supported browsers below:
- Google Chrome
- Mozilla Firefox
- Internet Explorer
- Microsoft Edge
- Stable internet connection
- Use the Designer tab in IBM RPA Studio
Get the complete script for this tutorial in Resources for the "Putting the user on hold in chatbot" tutorial.
Procedure
Defining the bot language
Start the digital assistant script development with the definition of the bot's language, also referred to as culture:
- Open a new blank script.
- Insert the Create a Language command in the script.
- Fill in the following parameters:
- In the Culture input parameter, select the
en-US
option. - In the Culture output parameter, insert the value
cultureEnUS
.
- In the Culture input parameter, select the
Starting the bot execution context
The Connect to Chatbot and Disconnect Chatbot commands start and end, respectively, the context of the execution of the digital assistant:
- Insert the Connect to Chatbot command in the script.
- Fill in the following parameters:
- In the Communication type input parameter, select the option
Chat
. - In the Language input parameter, insert the
${cultureEnUS}
output variable returned by the Create a Language) command. - In the Timeout input parameter, insert the value
00:05:00
.
- In the Communication type input parameter, select the option
The Disconnect Chatbot command is automatically inserted after defining and saving the Connect to Chatbot command.
- Save the Disconnect Chatbot command as soon as its window is shown on the screen.
Starting the interaction
Start the bot interaction by asking for the user's name:
- Insert the Bot Ask Name command inside the instruction block of the Connect to Chatbot and Disconnect Chatbot command.
- In the Text input parameter, insert the value
Hello, my name is Sofia, and I will be your virtual assistant. First, what is your name?
. - In the Timeout input parameter, insert the value
00:02:00
. - In the First output parameter, insert the value
userName
.
- In the Text input parameter, insert the value
- Insert the Bot Ask command in the script.
- In the Text input parameter, insert the value
${userName}, please insert a valid URL for the site you want to browse in.
. - In the Timeout input parameter, insert the value
00:02:00
. - In the Value output parameter, insert the value
userResponse
.
- In the Text input parameter, insert the value
Getting the website address
You need to develop an instruction block to get the website address from the user:
- On the Home page tab, click the New variable button to define a new variable.
- In the Name input parameter, insert the value
${urlFound}
. - In the Variable type input parameter, select the option
Boolean
.
- In the Name input parameter, insert the value
- Insert the While command in the script.
- In the Left operator input parameter, insert the variable
${urlFound}
. - In the Operator input parameter, select the option
Is true
. - Enable the Negate input parameter.
- In the Left operator input parameter, insert the variable
The End While command closes that block of instructions. It is automatically inserted into the script when saving the While command.
- Insert the Find by Regular Expression command inside the instruction block of the While command.
- In the Text input parameter, insert the variable
${userResponse}
returned in the Bot Ask command. - In the Regular expression input parameter, insert the value
^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
. - In the Options input parameter, select the option
Ignore Case
. - In the Occurrence output parameter, insert the variable
${urlFound}
created earlier.
In the While command the URL is validated. If the URL is not valid, the bot asks again for a valid URL.
- Insert the If command still within the loop initiated by the While command.
- In the Left operator input parameter, insert the variable
${urlFound}
. - In the Operator input parameter, select the option
Is true
. - Enable the Negate input parameter.
The End If command ends this block of instructions. It is automatically inserted into the script when saving the If command.
- Insert the Bot Ask command inside the instruction block of the If command.
- In the Text input parameter, insert the value
${userName}, we did not find the URL inserted. Could you re-insert a valid URL, please?
. - In the Timeout input parameter, insert the value
00:02:00
. - In the Value output parameter, insert the value
userResponse
.
- In the Text input parameter, insert the value
The End While command finishes the first part of the construction of this script.
Putting the user on hold
You need to put the user on hold to him wait for a return of the query:
- Insert the Bot Start On Hold command in the script and, in the input parameter Messages, insert the value
Wait until navigation is complete.
.
The End Wait command closes that instruction block and the waiting state. It is automatically inserted into the script when saving the Bot Start On Hold command.
Ending the interaction
To finish the interaction, you need to develop an instruction to send the last text message to the user:
- Insert the Bot Says command after the End Wait command.
- In the Text input parameter, insert the value
${userName}, the site name is '${titleSite}.' Thank you for contacting us, see you soon!
.
- In the Text input parameter, insert the value
The Delay command is inserted in the script so that the web chat is open for a few seconds, during the execution of the script in debug mode, after the last interaction of the bot using the Bot Says command.
- Insert the Delay command in the script.
- In the Timeout input parameter, insert the value
00:00:05
.
- In the Timeout input parameter, insert the value
After performing all the steps in this tutorial, run the developed script.