Creating your first bot with IBM Robotic Process Automation with Automation Anywhere

To help you get started with IBM® RPA with Automation Anywhere, this step-by-step guide walks you through creating your first bot. It shows you how to record a task and extend it with commands. If you have the corresponding permissions, you can then upload your bot to the control room and create the schedule and triggers for running it.

Checking your system and permissions

To complete the steps successfully, ensure you satisfied the following prerequisites:

  • You have a bot creator device license and a bot creator is installed on your machine.
  • You have permission to upload, schedule, and run a production bot.
  • You are logged into a bot creator.

Recording a task

Your first bot is based on a recorded task that involves starting Windows Notepad, entering a customer's name, and then saving the resulting text file. The recorded task mimics your mouse clicks and keyboard keystrokes.

  1. Open the Notepad application.
  2. InBot Creator, select Record. In the Recorder window, select Untitled - Notepad from the list of windows and click Start.
    Tip: Bot Creator provides several recorders; the default recorder is the Smart Recorder, which is the preferred recorder because it interacts directly with an object and isn't affected by the screen resolution or the size and position of a window.
  3. In Notepad, enter a customer's name, for example, Jennifer Brown, then save the file by pressing Ctrl+S. Specify a file name, for example customerNames, then press Enter.
    Tip: Where possible, use the keyboard equivalent of a mouse click because keystrokes automate more reliably.
  4. Your task is now complete so you can stop the recording by clicking Stop in the Recording window. The Save Task window opens. Give your bot a name, such as My first bot, and click Save.
    The Workbench editor opens to show the steps you recorded. In IBM RPA with Automation Anywhere, bots are implemented as tasks and the steps in the task are represented by a set of Object Cloning commands. Your bot should look similar to the following example. Notice that the commands include both the text you entered and the keyboard keystrokes.

Starting Notepad automatically

When your bot goes into production, it runs on a bot runner. Because you can't assume that Notepad is already started on the bot runner machine, it's a good idea to automate starting Notepad by adding the Open Program/File command to your task:
  1. In the Workbench editor, go to Commands and drag the Open Program/File command to your task. The command must be the first line of your task.
    Tip: If the command ends up in the wrong place, you can move it to the beginning of the task by clicking Actions > Move Up.
  2. In the Open Program/File window, specify the fully qualified path to the Notepad application in the Step 1: Program/File Path field, for example, C:\Windows\System32\notepad.exe, and click Save.
    Tip: For system applications, such as Notepad, you don't need to specify the fully qualified path because system applications are always installed in the System32 directory, and this directory is by default included in the PATH system environment variable that is used to look up files. However, you must always specify the fully qualified path for external applications, and ensure that they are installed in the same place in both the Bot Creator and Bot Runner clients
    Line 1 of your task should now look similar to the following example:
  3. Save your changes and run the bot. The bot starts Notepad and enters the name.

Adding a condition to check for a file

You might notice that when your bot finishes, it always asks you whether you want to replace the existing customerNames.txt file. For task automation, it's better if the bot checks whether the file exists and deletes it before the actual "bot work" begins. Add an If/Else command to the beginning of the task to do the checking and deleting for you.
  1. In the Workbench editor, go to Commands and drag the If/Else command to the beginning of your task.
  2. Specify the If clause.
    1. In the If window, set Select If Command to If, set Select Condition to File exists, enter the fully qualified path to the customerName.txt file, and then save the command.
  3. Specify the body of the If clause. In this case, the body must include a command to delete the customerNames.txt file.
    1. Drag the Files/Folders command to the If statement.
    2. In the Files/Folders window, set Files or Folders command to File, set Select Command to Delete Files, enter the fully qualified path to the customerName.txt file, and then save the command.
  4. If necessary, move the If command up so that it is the first one in the task and adjust the comment. Your task should look similar to the following example:
  5. Save your changes and run the bot. If everything worked, you shouldn't be prompted to replace the file.

Replacing the customer name with a variable

Currently, the bot types the name of the customer into Notepad. To make the task repeatable, replace the hardcoded name with a variable and assign a value to the variable. At run time, the value of the variable is used instead of the hardcoded name.
  1. Create the variable.
    1. In the Workbench editor, click Variable Manager > Add.
    2. In the Add Variable window, select Value as the Type, give the variable a name, for example customerName, provide a value, for example Tom Smith, and save the variable.
  2. Add the variable to your task.
    1. In the Task Actions list, double-click the line that contains "Jennifer Brown".
    2. In the Text to Set field, delete "Jennifer Brown" from the string, then insert your variable by pressing F2.
    3. Select customerName from the $Variables$ list.
    4. Verify that the variable appears at the beginning of the Text to Set string, and then click Save. Your task should look similar to the following example:
  3. Save your updates to the task actions and run your bot. When the bot runs, you should see the bot entering "Tom Smith" in Notepad instead of "Jennifer Brown".

Uploading your bot to the control room

You develop and test your bot on your bot creator. However, production bots run on remote bot runners. When your bot is ready for production, upload it to the control room.
Tip: To upload a bot, your Control Room administrator must assign you to a role that has upload permission.
  1. In the My Tasks list, right-click your bot and then click Upload.
  2. Check that you get an Upload is successful message. In your bot creator, go to Tools > Repository; you should see your bot in the My Tasks folder in the server repository.

Scheduling your bot to run

Depending on your permissions and needs, you can schedule your bot in one of the following ways:
  • In the control room, create a task schedule for running the bot on a bot runner.
  • In the Bot Runner client, download the bot from the control room, and then configure a trigger or a schedule.
The control room procedure is described here. Let's assume that you want your bot to run every Sunday at 10 PM.
Note: To schedule a bot, your Control Room administrator must assign you to a custom role that has permission to run bots.
  1. In the control room, navigate to BOTS > My bots, and click Schedule bot.
  2. On the BOT + DEPENDENCIES tab, select the bot you uploaded from the My Tasks folder, and click Next.
  3. On the SCHEDULE + DEVICES tab, define the schedule, select Bot Runner device, and click Next.
  4. Give the schedule a name and a description and click Schedule bot.
Your first bot is now complete.

Extending your bot

The step-by-step guide described how to create a basic bot. You can now extend your bot, for example, by replacing the hardcoded variable value with values read in from a file. Or, you can try out some of the IBM RPA with Automation Anywhere samples published in the IBMBPMCommunity.