Getting Started¶
If you are just starting with BotCity or want to get a general idea of how processed items can be reported in the process code, simply follow the guide below:
Using the Maestro SDK to report data¶
You can easily report information about the processed items using the Maestro SDK in your automation code.
SDK Installation¶
If you haven't installed the dependency yet, simply follow these instructions:
Important
Besides installing, remember to include the dependency in the robot's requirements.txt file.
<repositories>
    <repository>
        <id>nexus-botcity-public</id>
        <url>https://devtools.botcity.dev:8081/repository/botcity-public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<dependencies>
    <!-- Your other dependencies -->
    <dependency>
        <groupId>dev.botcity</groupId>
        <artifactId>maestro-sdk</artifactId>
        <version>2.2.0</version>
    </dependency>
</dependencies>
Importing the SDK¶
After installation, simply import the dependency and instantiate the Maestro SDK:
# Importing the Maestro SDK dependency
from botcity.maestro import *
# Disabling errors if there is no connection with the Orchestrator
BotMaestroSDK.RAISE_NOT_CONNECTED = False
# Instantiating the Maestro SDK
maestro = BotMaestroSDK.from_sys_args()
# Getting the details of the current task being executed
execution = maestro.get_execution()
// Import for integration with BotCity Maestro SDK
using Dev.BotCity;
using Dev.BotCity.MaestroSdk.Model.Execution;
// Instantiating the Maestro SDK
BotMaestroSDK maestro = BotMaestroSDK.FromSysArgs();
// Fetching the details of the current task being executed
Execution execution = await maestro.GetExecutionAsync(maestro.GetTaskId());
Reporting process data¶
At the end of the execution, you can report information about the processed items when finishing the task.
Complete code¶
from botcity.core import DesktopBot
from botcity.maestro import *
# Disabling errors if there is no connection with the Orchestrator
BotMaestroSDK.RAISE_NOT_CONNECTED = False
def main():
    maestro = BotMaestroSDK.from_sys_args()
    execution = maestro.get_execution()
    # Implementing here the logic to process the items
    bot = DesktopBot()
    # The items can be any entity related to your automation process
    items = []
    processed_items = 0
    failed_items = 0
    # You can use the logic that is necessary to consume, process, and count the items
    for item in items:
        try:
            # Process the item...
            # Counting as an item processed successfully
            processed_items+=1
        except Exception:
            # Counting as an item processed with failure
            failed_items+=1
    # At the end, simply report the data of the processed items when finishing the task
    maestro.finish_task(
        task_id=execution.task_id,
        status=AutomationTaskFinishStatus.SUCCESS,
        message="Task Finished OK.",
        total_items=len(items), # Total number of items processed
        processed_items=processed_items, # Number of items processed successfully
        failed_items=failed_items # Number of items processed with failure
    )
def not_found(label):
    print(f"Element not found: {label}")
if __name__ == '__main__':
    main()
import java.util.List;
import java.util.ArrayList;
import dev.botcity.framework.bot.DesktopBot;
import dev.botcity.maestro_sdk.BotExecutor;
import dev.botcity.maestro_sdk.BotMaestroSDK;
import dev.botcity.maestro_sdk.model.AutomationTask.FinishStatus;
import dev.botcity.maestro_sdk.runner.BotExecution;
import dev.botcity.maestro_sdk.runner.RunnableAgent;
public class FirstBot extends DesktopBot implements RunnableAgent
{
    public FirstBot() {
        try {
            setResourceClassLoader(this.getClass().getClassLoader());
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public void action(BotExecution botExecution) {
        try {
            BotMaestroSDK maestro = new BotMaestroSDK();
            maestro.login(botExecution);
            // The items can be any entity related to your automation process
            List<Object> items = new ArrayList<Object>();
            int processedItems = 0;
            int failedItems = 0;
            // You can use the logic that is necessary to consume, process, and count the items
            for(Object item : items){
                try{
                    // Process the item...
                    // Counting as an item processed successfully
                    processedItems+=1;
                }
                catch(Exception e){
                    // Counting as an item processed with failure
                    failedItems+=1;
                }
            }
            // At the end, simply report the data of the processed items when finishing the task
            maestro.finishTask(
                botExecution.getTaskId(),
                "Task Finished OK.",
                FinishStatus.SUCCESS,
                items.size(), // Total number of items processed
                processedItems, // Number of items processed successfully
                failedItems // Number of items processed with failure
            );
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    private void notFound(String label) {
        System.out.println("Element not found: "+label);
    }
    public static void main(String[] args) {
        BotExecutor.run(new FirstBot(), args);
    }
}
using Dev.BotCity.MaestroSdk.Model.AutomationTask;
using Dev.BotCity.MaestroSdk.Model.Execution;
using System;
using System.Threading.Tasks;
namespace FirstBot
{
    class Program
    {
        static async Task Main(string[] args)
        {
            BotMaestroSDK maestro = BotMaestroSDK.FromSysArgs();
            Execution execution = await maestro.GetExecutionAsync(maestro.GetTaskId());
            Console.WriteLine("Task ID is: " + execution.TaskId);
            Console.WriteLine("Task Parameters are: " + string.Join(", ", execution.Parameters));
            // The items can be any entity related to your automation process
            string[] items;
            int processedItems = 0;
            int failedItems = 0;
            // You can use the logic that is necessary to consume, process, and count the items
            foreach (string item in items) 
            {
                try {
                    // Process the item...
                    // Counting as an item processed successfully
                    processedItems+=1;
                } catch (Exception ex) {
                    // Counting as an item processed with failure
                    failedItems+=1;
                }
            }
            // At the end, simply report the data of the processed items when finishing the task
            await maestro.FinishTaskAsync(
                execution.TaskId,
                FinishStatusEnum.SUCCESS,
                "Task Finished OK.",
                items.Length, // Total number of items processed
                processedItems, // Number of items processed successfully
                failedItems // Number of items processed with failure
            );
        }
    }
}
Tip
It is not mandatory to use a specific code structure in your automation process.
You have complete freedom to define the logic that will be used and also the way the items will be counted.
In the end, simply report this data by using the finish_task method of the Maestro SDK.