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:

  1. Open a new blank script.
  2. Insert the Create a Language command in the script.
  3. Fill in the following parameters:
    1. In the Culture input parameter, select the en-US option.
    2. In the Culture output parameter, insert the value cultureEnUS.

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:

  1. Insert the Connect to Chatbot command in the script.
  2. Fill in the following parameters:
    1. In the Communication type input parameter, select the option Chat.
    2. In the Language input parameter, insert the ${cultureEnUS} output variable returned by the Create a Language) command.
    3. In the Timeout input parameter, insert the value 00:05:00.

The Disconnect Chatbot command is automatically inserted after defining and saving the Connect to Chatbot command.

  1. 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:

  1. Insert the Bot Ask Name command inside the instruction block of the Connect to Chatbot and Disconnect Chatbot command.
    1. 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?.
    2. In the Timeout input parameter, insert the value 00:02:00.
    3. In the First output parameter, insert the value userName.
  2. Insert the Bot Ask command in the script.
    1. In the Text input parameter, insert the value ${userName}, please insert a valid URL for the site you want to browse in..
    2. In the Timeout input parameter, insert the value 00:02:00.
    3. In the Value output parameter, insert the value userResponse.

Getting the website address

You need to develop an instruction block to get the website address from the user:

  1. On the Home page tab, click the New variable button to define a new variable.
    1. In the Name input parameter, insert the value ${urlFound}.
    2. In the Variable type input parameter, select the option Boolean.
  2. Insert the While command in the script.
    1. In the Left operator input parameter, insert the variable ${urlFound}.
    2. In the Operator input parameter, select the option Is true.
    3. Enable the Negate input parameter.

The End While command closes that block of instructions. It is automatically inserted into the script when saving the While command.

  1. Insert the Find by Regular Expression command inside the instruction block of the While command.
    1. In the Text input parameter, insert the variable ${userResponse} returned in the Bot Ask command.
    2. 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})?(\/.*)?$.
    3. In the Options input parameter, select the option Ignore Case.
    4. 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.

  1. Insert the If command still within the loop initiated by the While command.
    1. In the Left operator input parameter, insert the variable ${urlFound}.
    2. In the Operator input parameter, select the option Is true.
    3. 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.

  1. Insert the Bot Ask command inside the instruction block of the If command.
    1. In the Text input parameter, insert the value ${userName}, we did not find the URL inserted. Could you re-insert a valid URL, please?.
    2. In the Timeout input parameter, insert the value 00:02:00.
    3. In the Value output parameter, insert the value userResponse.

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:

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

Creating the navigation process

Develop the navigation process using the URL sent by the user:

  1. On the Home page tab, click the New variable button to define a new variable.
    1. In the Name input parameter, insert the value nameInstance.
    2. In the Variable type input parameter, select the option Text.
    3. In the Value input parameter, insert the value browser-instance.
  2. Insert the Start Browser command inside the instruction block of the Bot Start On Hold and End Wait command.
    1. In the Instance name input parameter, insert the variable ${nameInstance}.
    2. In the Browser type input parameter, select a browser available on your machine.

The Close Browser command closes the navigation context. It is automatically inserted into the script when saving the Start Browser command.

  1. In the Close Browser command, insert the variable ${nameInstance} in the Instance name input parameter.
  2. Insert the Navigate command inside the instructions block of the Start Browser and Close Browser commands.
    1. In the URL input parameter, insert the variable ${userResponse}.
  3. Insert the Get Element Value command in the script.
    1. In the Selector type input parameter, select the option Css.
    2. In the CSS of the element input parameter, insert the value head > title.
    3. In the Value output parameter, insert the value titleSite.

The Close Browser and End Wait commands end the navigation process on the web page and standby status, respectively.

Ending the interaction

To finish the interaction, you need to develop an instruction to send the last text message to the user:

  1. Insert the Bot Says command after the End Wait command.
    1. In the Text input parameter, insert the value ${userName}, the site name is '${titleSite}.' Thank you for contacting us, see you soon!.

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.

  1. Insert the Delay command in the script.
    1. In the Timeout input parameter, insert the value 00:00:05.

After performing all the steps in this tutorial, run the developed script.