Orchestration

RPA Orchestration: How to create and execute your automation tasks in BotCity Orchestrator

We’ve reached our third article in the RPA Orchestration series, and this time, we will talk about how to run our automation tasks in BotCity Orchestrator with BotCity Runner. At this stage, the deployment of the automation has already happened. If you still need to learn how this process works, check out our step-by-step article on how to do it.

If you’re following the series, we’re using a project developed with Selenium as a model—this robot’s code accesses a login test site. You can verify by visiting our repository on GitHub.

Configuring BotCity Runner to run the automation

Your tasks will run with the support of the BotCity Runner tool. I invite you to explore it in this article with a guide to understanding how to manage it.

While we are in the final stages of deploying our automation in BotCity Orchestrator, one of the configurations is to set which runner we will use to execute the tasks.

Easy Deploy screen in the third step with fields for configuring an existing runner or creating a new one

Then, open BotCity Runner from the wizard interface or the folder where you installed the BotCity SDK.

BotCity Runner screen with the BotCity logo on the left and the start button in the middle.

You can check that the configuration is correct by validating the information in Orchestrator and consulting a file in the folder where you installed the BotCity SDK. In the menu on the left-hand side, identify the “Developer” category and the “Dev Environment” option within it. The screen that opens when you click this option will contain the information you need to confirm. At the top, identify the following data:

  • Workspace;
  • Login;
  • Key.

Dev environment screen pointing to workspace, login and key data.

In the folder where you installed the BotCity SDK, you’ll find a folder called “conf.” And inside it, there will be a file called “conf.bcf”. You can open this file by right-clicking on it, then clicking on the “open as” option and choosing Notepad or another text editor to make it easier to view or edit if necessary.

conf file opened in notepad

The “conf.bcf” file contains some information. Some of this information is what you identified in the Orchestrator, within the Dev Environment screen. Check that the login, workspace, and key data are the same. If not, update the file and save the changes. Another important field is “machineId”. It will contain the name of the runner you created. In our example, we created a runner called “vm-new-runner.” But you can name it whatever you like.

For more details about this file and these settings, see our documentation showing the runner configuration. Keep BotCity Runner open for the next steps by clicking the “Start” button. From that moment on, the runner will be available and waiting for tasks.

BotCity Runner screen with status awaiting new tasks

Creating your automation tasks

  • There are a few ways to create tasks related to your automation. You can choose one of the two ways to do this process using the orchestrator’s interface.
    • After deploying, there will be the option to create a task;

Easy Deploys screen at the end, when the deployment has been successful, with the close button and the new task button.

  • By clicking on “New Task” in the left menu and choosing the automation from which the task will be created, then clicking on the “New Task” button on the right side;

New task screen with the filter made with the automation name bot-selenium

Note: The creation and settings screen will be the same for both situations according to the guidelines below.

New task creation configuration screen

  • Test Task: optional field. Select if you want to create a test task, which means that you can restart it as many times as necessary;
  • Minimum run date: optional field. You only need to fill in this field if you want to set a minimum date and time for the task to start running;
  • Priority: required field. You should set a priority to execute this task. This priority is from 0 to 10. The higher the number, the higher the priority;
  • Params: optional field. You only need to fill in if there are parameters for your task.

Another way to create tasks for your automation is to use the BotCity Orchestrator API. The first thing you need to do is to import the library:

from botcity.maestro import *

Then, we need to call the “create_task” function as follows:

task = maestro.create_task(
    activity_label="bot-selenium",
    parameters=params,
    test=False
)

You can see more examples in other programming languages and more guidance on using the API in our documentation.

You should know that as soon as your task is created, regardless of how you create it, it will be available in the task queue. This screen is in the menu on the left side, under the “Control Room” category.

Task queue screen

Let’s create the task using Orchestrator’s graphical interface. Then click on “New Task” in the left-hand menu. Then, to make it easier, filter by the name of the automation and, when you find it, identify the button it also has called “New Task.”

New task screen pointing to the menu and the new task button as in the explanation

As this creation will only be a test, we’ll set the “Test Task” flag to on. That way, we’ll be able to do it more than once. Then click on “Create”.

Task creation screen showing the test task flag highlighted

After clicking on “Create,” it will redirect to the “Task Queue” screen. The status will be “in queue,” which means that the task is in the queue waiting to run.

Task queue screen with an arrow pointing to the in queue state

When the runner identifies the task ready to execute, it changes the status to “executing task.” Note that it has also identified the “bot-selenium” automation.

BotCity Runner screen showing that the task is running

The first run of automation will be slower than usual because the runner needs to create the virtual environment and install all the dependencies. But don’t worry; after that, it will be practically immediate since the virtual environment already exists, and only the dependencies will be updated when necessary.

As the seconds tick by, you’ll be able to verify that the task’s status changes to “running,” which means that the task is executing.

Screenshot of the task queue with the runner attached showing that it's running

After that, the task changed to “failed,” which means that it has finished execution and failed. And again, the runner has the status “waiting for new tasks.”

Screenshot of the task queue with the runner attached showing that the task has failed status and the runner is waiting for the task.

Understanding task failure

To analyze what has happened to the task, you can click on the task’s three-dot icon and then select the “info” option.

printout of the task card showing the open menu with info and restart options

Clicking on “info” takes you to the details of the task. The “Finish Message” field can contain an error message about what happened. In this case, it is telling us that the task has finished, but we didn’t report the status.

Task details screen

To do this, you can finalize the task, giving it the status of finished if it was successful. An example of how to do this would be the code below. But you can find more details in our documentation.

    maestro.finish_task(
        task_id=execution.task_id,
        status=finish_status,
        message=finish_message
    )

We’ll also explore task statuses in our next article in this series on RPA orchestration. Ok?

Questions or suggestions?

If you have any questions, feel free to join our global community on Slack or get in touch via our forum. And remember to create your free account to test out the features we’re exploring in our content.

She/her. I am a Tech Writer and Developer Relations at BotCity. I am also a tech content creator who loves tech communities and people.

Leave a Reply

%d