Setup
This section will guide you through the setup of the BotCity Maestro SDK and how to establish a connection with the Maestro platform.
Installation¶
BotCity Maestro SDK is available as a Python package on PyPI.
You can install it with:
BotCity Maestro SDK is available as a Java dependency in the Nexus repository.
The dependency will be installed automatically after being added to your pom.xml
:
<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.0.3</version>
</dependency>
</dependencies>
BotCity Maestro SDK is available as Javascript Package on NPM.
You can install it with:
Importing the SDK¶
You can import the SDK into your code with:
You can import the SDK into your code with:
Creating a new Maestro Client¶
The BotMaestroSDK
is the main class to be used when interacting with BotMaestro.
You can create a new Maestro Client with:
Establishing a connection to Maestro¶
There are two ways to establish a connection with Maestro via code.
We can authenticate a new instance using the parameters passed by Runner or log in directly using the workspace information.
Using workspace information¶
The login information is available when you access BotCity Maestro and click on the Dev. Environment
menu.
We will need the Login
and Key
information from this page.
See the Dev. Environment section for more information.
Using the arguments passed by Runner¶
Another way to authenticate an instance of the Maestro SDK is through the arguments passed by the Runner when executing a task.
This way, when we run our automation through Runner, we will already have an authenticated instance of the SDK in the code.
Tip
If you are using BotCity project templates to develop automation, you will probably already have this code snippet included in the project.
Info
By default, the BotExecution
object is already configured in the BotCity Java project template.
Getting the current execution reference¶
After instantiating the Maestro SDK, we can obtain the reference of the current task being executed by Runner.
This way, we can more easily access information about this execution during the code, such as the task ID and parameters.
# Instantiating the Maestro SDK
maestro = BotMaestroSDK.from_sys_args()
# Getting the details of the current task being executed
execution = maestro.get_execution()
# Information about the task being executed
print(f"Task ID is: {execution.task_id}")
print(f"Task Parameters are: {execution.parameters}")
Info
By default, the BotExecution
object is already configured in the BotCity Java project template.
public void action(BotExecution botExecution) {
try {
// Instantiating the Maestro SDK
// The BotExecution object contains the information that is passed by the Runner
BotMaestroSDK maestro = new BotMaestroSDK();
maestro.login(botExecution);
// Information about the task being executed
System.out.println(botExecution.getTaskId());
...
// Getting the arguments passed by Runner
const args = process.argv.slice(2)
const [server, taskid, token] = args
// Instantiating the Maestro SDK
const maestro = new BotMaestroSdk()
maestro.login("https://developers.botcity.dev", "<LOGIN>", "<KEY>")
// Getting the details of the current task being executed
const executionTask = await maestro.getTask(taskid)
// Getting the arguments passed by Runner
const args = process.argv.slice(2)
const [server, taskid, token] = args
// Instantiating the Maestro SDK
const maestro: BotMaestroSdk = new BotMaestroSdk()
maestro.login("https://developers.botcity.dev", "<LOGIN>", "<KEY>")
// Getting the details of the current task being executed
const executionTask: Task = await maestro.getTask(taskid)