Building Resilient Bots - Step List

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Building Resilient Bots: Step List

Introduction to the Course

This course provides the steps to build a resilient bot using the principles and best practices that
automates a process. This is done using Automation Anywhere Enterprise A2019, a premium Robotic
Process Automation (RPA) platform from Automation Anywhere, which allows enterprises to deploy
a digital workforce comprised of software bots that will automate business processes end to end.

Building Resilient Bots to Handle Unpredictable Issues Using the Try/Catch/Finally/Throw


Actions

Introduction
This demo will help you to create a resilient bot that is designed to handle unpredictable adverse
situations that occur during run time.

Objective
In this use case, you will learn how to handle errors arising out of unpredictable issues using the
Try/Catch/Finally/Throw actions, and thereby build resilience.

Prerequisites
You need access to the following:
• Access to the Automation Anywhere Community Edition:
https://community.cloud.automationanywhere.digital/
• Access to http://rpademo.automationanywhere.com/newuserlist.php

Note: After editing actions, make sure you click the Apply button to apply the changes and Save button
to save the task bot.
1. Open the file and mitigate any potential issues using the Try action
a. Open the file and mitigate any potential issues.
I. From the Actions panel, drag and drop the Try action to the bot editor.
II. From the Actions panel, drag and drop the Excel advanced: Open action within the Try
action.
III. In the Action details panel, click Desktop file and enter the excel file path with name,
that contains the extracted data.
Note: At all such instances, you will have the option to either enter the file path
manually or browse and select the required file. You can choose either of the two.
IV. Open the file in a read-write mode and select the Sheet contains a header checkbox.
V. Click Apply.

2. Handle any potential errors using the Catch action.


a. Catch potential errors
i. From the Actions panel, drag and drop the Catch action to the bot editor and place it
parallel to the Try action.

b. Create a new folder


i. From the Actions panel, drag and drop the Folder: Create action within the Catch
action.
ii. In the Folder field, enter a directory path for the new folder to be created.
iii. Check the Overwrite an existing folder checkbox.
iv. Click Apply.

c. Create a new workbook


i. From the Actions panel, drag and drop the Excel advanced: Create workbook action
within the Catch action.
ii. In the File path field, enter a file path for the new workbook to be created.
iii. Click Apply.

d. Open the created workbook.


i. From the Actions panel, drag and drop the Excel advanced: Open action at the end of
the Catch action.
ii. In the Action details panel, click Desktop file and enter the file path with name.
iii. Open the file in a read-write mode and select the Sheet contains a header checkbox.
iv. Click Apply.

3. Log the status into a log file using the Finally action.
a. Log the status into a log file
i. From the Actions panel, drag and drop the Finally action to the bot editor and place it
parallel to the Catch action.
ii. From the Actions panel, drag and drop the Log to file action at the end of the Finally
action.
iii. In the File path field, enter the file path with name to place the log text file.
iv. In the Enter text to log field, enter the text to be logged in the log text file.
v. Under the When logging section, select the Append to existing log file option.
vi. Click Apply.

1
4. Capture the exact error using the Throw action.
a. Create a child bot to find the error
i. In the Child bot, drag and drop the If condition from Actions panel.
ii. In the Condition field, select the File exists condition from the list.
iii. In the File path field, enter the file path that needs to be searched.
iv. From the Actions panel, drag and drop the CSV/TXT: Open action within the If action.
iv.1) In the File path field, enter the same file path name that was searched.
iv.2) Choose the Comma delimiter.
iv.3) Click Apply.
v. From the Actions panel, drag and drop the Excel advanced: Open action within the If
action.
v.1) In the File path field, enter the file path.
v.2) Open the file in a Read-write mode and select the Sheet contains a header
checkbox.
v.3) Click Apply.
vi. From the Actions panel, drag and drop the Loop action at the end.
vi.1) In the Iterator field, select For each row in CSV/TXT iteration type from the list.
vi.2) In Assign the current row to this variable field, create and select the variable.
Note: Make sure that the variable is created with the variable type as Record.
vi.3) Click Apply.
vii. From the Actions panel, drag and drop the Excel advanced: Set cell action within the
Loop action.
vii.1) Select Active cell option.
vii.2) In the Cell value field, select the existing record variable.
vii.3) Click Apply.
viii. From the Actions panel, drag and drop the Excel advanced: Go to cell action within
the Loop action.
viii.1) Select the Active cell option and choose the One cell below from the drop-down
list.
viii.2) Click Apply.
ix. From the Actions panel, drag and drop the Else condition parallel to the If condition.
x. From the Actions panel, drag and drop the Throw action within the Else condition.
x.1) In the Please enter exception message (optional) field, enter the error message
to be displayed.
x.2) In the Exceptions field, select AllErrors exception from the drop-down list.
x.3) Click Apply.

b. Call the child bot inside the Try action


i. From the Actions panel, drag and drop the Try action to the bot editor.
ii. From the Actions panel, drag and drop the Task Bot Run action to the end of Try
action.
iii. In the Task Bot to run field, select the child bot.
iv. Click Apply.

c. Handle the errors thrown from the child bot inside the Catch action
i. From the Actions panel, drag and drop the Catch action to the bot editor and place it
parallel to the Try action.
i.1) In the Action details panel, select AllErrors exception from the drop-down list.

2
i.2) In the Assign exception message to (optional) field, create and select a variable.
Note: Make sure that the variable is created with the variable type as String.
i.3) Click Apply.
ii. From the Actions panel, drag and drop the Delay action within the Catch action.
ii.1) In the Delay field, enter the delay time in seconds.
ii.2) Select the Seconds radio button under Time unit section.
ii.3) Click Apply.
iii. From the Actions panel, drag and drop String: Assign action to the end.
iii.1) In the Select the source string variable(s)/value field, enter the required value.
iii.2) In the Select the destination string variable field, assign the existing variable to
the output.
Note: Make sure that the variable is already created with the variable type as String.
iii.3) Click Apply.
iv. From the Actions panel, drag and drop Screen: Capture desktop action to the end.
iv.1) In the File path to save image field, enter the file path to save the images.
iv.2) Click Apply.

d. Log the file status inside the Finally action


i. From the Actions panel, drag and drop the Finally action to the bot editor and place it
parallel to the Try and Catch action.
ii. From the Actions panel, drag and drop the If condition within the Finally action.
ii.1) In the Condition field, select the String variable conditions from the list.
ii.2) In the String variable field, select the existing string variable from the drop-down
list.
ii.3) Select the Equals to(=) operator from the drop down list.
ii.4) Enter the value to be checked.
ii.5) Click Apply.
iii. From the Actions panel, drag and drop the Log to file action at the end of the previous
step.
iii.1) In the File path field, enter the file path to save the log text in a file.
iii.2) In the Enter text to log field, enter the text to be logged in the file.
iii.3) Select the Append to existing log file radio button.
iii.4) Select ANSI from the Encoding drop-down list.
iii.5) Click Apply.
iv. From the Actions panel, drag and drop the Comment action to the end of the Log to
file action.
iv.1) In the Comment field, enter the comments to be displayed at the end of the
whole process.
iv.2) Click Apply.

Now, you have successfully created a task bot to capture a table data with built-in resilience using the
Try/Catch/Finally/Throw actions.

3
Building Resilient Bots to Handle Known Exceptions Using the If/Else Conditions

Introduction
This demo will help you to create a resilient bot designed to handle known exceptions that occur
during run time.

Objectives
In this use case, you will learn how to use the If/Else conditions to build resilience into the bots to
handle known errors.

Prerequisites
You need access to the following:
• Access to the Automation Anywhere Community Edition:
https://community.cloud.automationanywhere.digital/
• Access to http://rpademo.automationanywhere.com/newuserlist.php

Note: After editing actions, make sure you click the Apply button to apply the changes and Save button
to save the task bot.

4
1. Setup the condition to check if the window exists using the If block.
a. Launch the website
i. From the action panel, drag and drop the Launch website to the bot editor.
ii. In URL field, enter the URL.
iii. In Browser field, select the browser from drop down list.
Note: For the purpose of this activity, we will use Internet Explorer.
iv. Click Apply.

b. Maximise the window


i. From the Actions panel, drag and drop the Maximize action at the end of the Launch
website action.
ii. In the Select an existing window variable field, click Window and from the drop-down
list, select the appropriate window.
Note: You must click the Refresh windows icon first to populate the drop-down list.
iii. Click Apply.

c. Specify the condition inside the If action


i. From the action panel, drag and drop If condition at the end.
ii. In the Condition field, select the Window does not exist condition from the drop-down
list.
iii. In the Select an existing window variable field, click Window and from the drop-down
list, select the appropriate window.
Note: You must click the Refresh windows icon first to populate the drop-down list.
iv. In How long you would like to wait for this condition to be true? (seconds) field,
enter the wait time in seconds format.
v. Click Apply.

d. Log the text into a file


i. From the Actions panel, drag and drop the Log to file action at the end of the If
condition.
ii. In the File path field, enter the file path to save the log text in a file.
iii. In the Enter text to log field, enter the text to be logged in the file.
iv. Check the Append timestamp checkbox.
v. Select the Append to existing log file radio button.
vi. Select ANSI from the Encoding drop-down list.
vii. Click Apply.

e. Capture the desktop action


i. From the Actions panel, drag and drop the Screen: Capture desktop action at the end
of Log to file action.
ii. In the File path to save image field, enter the file path to save the captured images.
iii. Check the Overwrite File checkbox.
iv. Click Apply.

2. Setup the screen capture for the failed condition using the Else block.
a. Log the else text into a file inside the Else action
i. From the Actions panel, drag and drop Else condition Parallel to If condition.

5
ii. From the Actions panel, drag and drop the Log to file action within the Else condition.
iii. In the File path field, enter the same file path to log the text.
iv. In the Enter text to log field, enter the text to be logged in the file.
v. Check the Append timestamp checkbox.
vi. Click Apply.

b. Capture the table using the Recorder: Capture action


i. From the Actions panel, drag and drop the Recorder: Capture action outside the
If/Else action.
ii. In the action details panel, select the Select an existing window variable field and
assign the existing window variable.
iii. In Action field, select Get table action from the list.
iv. In the Assign the output to variable (optional) field, create a variable and assign it to
the output.
Note: Make sure that the variable is created with the variable type as Table.
v. Click Apply.

c. Open the workbook.


i. From the Actions panel, drag and drop the Excel advanced: Open action at the end.
ii. In the Action details panel, click Desktop file and enter the file path with name.
iii. Open the file in a read-write mode and select the Sheet contains a header checkbox.
iv. Click Apply.

d. Navigate to the first cell in the spreadsheet


i. From the Actions panel, drag and drop the Excel advanced: Go to cell action at the
end.
ii. In the Specific cell field, enter the cell address.
iii. Click Apply.

e. Loop each row in the table


i. From the Actions panel, drag and drop the Loop action at the end.
ii. In Iterator field, select For each row in table iteration type from the list.
iii. In Table variable field, select the existing table variable from the list.
iv. In Assign the current row to this variable field, create and assign the variable to the
output.
Note: Make sure that the variable is created with the variable type as Record.
v. Click Apply.

f. Loop each value in the record iteration


i. From the Actions panel, drag and drop the Loop action at the end.
ii. In Iterator field, select the For each value in record iteration type from the list.
iii. In Record variable field, select the existing record variable from the list.
iv. In Assign the current value to this variable field, create and assign the variable to the
output.
Note: Make sure that the variable is created with the variable type as any.
v. Click Apply.

6
g. Set the current read value
i. From the Actions panel, drag and drop the Excel advanced: Set cell action within the
Loop action.
ii. Select the Active cell radio button.
iii. In the Cell value field, create and assign the variable to the output.
Note: Make sure that the variable is already created with the variable type as Any.
iv. Click Apply.

h. Move one cell to the right


i. From the Actions panel, drag and drop the Excel advanced: Go to cell action within
the Loop action.
ii. Select the Active cell radio button.
iii. In the Active cell field, select One cell to the right cell type.
iv. Click Apply.

i. Move one cell below


i. From the Actions panel, drag and drop the Excel advanced: Go to cell action within
the Loop action.
ii. Select the Active cell radio button.
iii. In the Active cell field, select One cell below cell type.
iv. Click Apply.

j. Move to the beginning of the row


i. From the Actions panel, drag and drop the Excel advanced: Go to cell action outside
the Loop action.
ii. Select the Active cell radio button.
iii. In the Active cell field, select Beginning of the row cell type.
iv. Click Apply.

k. Close the workbook


i. From the Actions panel, drag and drop the Excel advanced: Close action.
ii. Select Save changes when closing file checkbox.
Note: Alternatively, you can use the Save workbook action.

l. Wait for a certain time period


i. From the Actions panel, drag and drop the Delay action at the end.
ii. In the Delay field, enter the delay time in seconds.
iii. Select the Seconds radio button under Time unit section.
iv. Click Apply.
v. Click Save.

m. Click Run to execute the task bot.


i. The output is an Excel sheet with data collected from the website.

You have successfully set up the If/Else conditions for your task bot. Your bot is now resilient.

You might also like