How to create UIs for humans to interact with Robocorp robots
Using the RPA.Assistant library, you can add a user interface to your robots.
The human operator will be able to interact and work together with the robot to complete its tasks. This is especially useful in combination with the Assistant features of Control Room and Robocorp Assistant.
On a technical level, the library will present operating system specific dialogs to the user. See RPA.Assistant library documentation pages for more information.
Example: Configurable Google Images search robot
When run, the robot will:
- present a dialog to the user to input the search query for the Google image search interface
- open a web browser
- search for images according to the search query
- save the first returned image
rpaframework
version22.0.0
or newer is recommended.
rpaframework-assistant
version2.2.2
or newer is recommended.
Run this robot as an assistant in Robocorp Assistant
Follow these instructions to upload the robot to Control Room and set up Robocorp Assistant to execute it on your local machine.
Robot script
Robot script explained
Settings
The *** Settings ***
section provides short Documentation
for the script and imports libraries (Library
) that add new keywords for the robot to use. In this case, we will add the RPA.Browser.Selenium
library to control the web browser and the RPA.Assistant
library to build the UI for the user.
Tasks
Save the first image for a search query collected from the user
is the name of the robot's only task.${search_query}= Collect search query from user
: We are creating a variable to hold the search query that we collect from the user using theCollect search query from user
keyword.Search Google Images ${search_query}
: We pass the value of the variable to theSearch Google Images
keyword.- with the
Collect the first search result image
we take a screenshot of the first returned image. - everything is surrounded in a try-catch clause so the robot will take a screenshot in case one of the above keywords fail
Keywords
- The dialog is created automatically under the hood by the RPA.Assistant library. You can start adding inputs without creating the dialog implicitly.
- We add a new text input field to our dialog (
Add text input
) setting its name and label. - The
Run dialog
keyword allows us to show the dialog to the user, and to assign the values that the user will enter into the dialog into the result object${response}
, which will contain a property with the name that we assigned to our dialog field (search
). The keyword then returns the value.
Here's how our dialog will look like:
- This keyword accepts a search query as an argument, opens Google Images search in a browser, and executes the search by submitting the search form.
- There are also some additional helper keywords defined to bypass cookies, consent and sign in prompts from Google
This keyword will take a screenshot of the first search result image in the Google Images search result page.