This library provides the official Java support for developing bots that run inside a Botica environment.
If you are starting from scratch, we recommend using the official template to set up your project:
https://github.com/isa-group/botica-seed-java
This template contains:
- A Maven project configured for Botica bots
- Scripts for building and packaging your bot:
build.sh(Linux/macOS)build.bat(Windows)
- A Dockerfile preconfigured for Botica environments
- Example bots implemented with the library
- A
pom.xmlfile exposing theimageTagproperty, used by the build scripts
Add the library dependency in your pom.xml:
<dependency>
<groupId>io.github.isa-group.botica</groupId>
<artifactId>botica-lib-java</artifactId>
<version>0.6.0</version>
</dependency>Tip
We really encourage creating your bot's repository using the official template. It contains build scripts that simplify the entire build process of your bot into a single step, from compilation to Docker image creation.
To implement a bot, extend BaseBot and define its behavior either through annotations or through
the functional API in the configure() method.
This bot defines an order handler for process_data actions using the @OrderHandler annotation.
public class MyBot extends BaseBot {
@OrderHandler("process_data")
public void onProcessData(String payload) {
System.out.println("Processing data: " + payload);
String processedResult = process(payload);
publishOrder("results_key", "store_processed_results", processedResult);
}
private String process(String data) {
return data.toUpperCase(); // Example processing
}
}This bot defines a proactive task using the @ProactiveTask annotation, which will run periodically
as configured in the environment file.
public class GeneratorBot extends BaseBot {
@ProactiveTask
public void generateData() {
publishOrder("raw_data", "process_data", "sample");
}
}Each bot requires an entry point class that starts the Botica runtime.
The BotLauncher.run(...) method establishes the connection with the Botica Director and
initializes your bot.
public class BotBootstrap {
public static void main(String[] args) {
BotLauncher.run(new MyBot(), args);
}
}Important
Botica bots are designed to run exclusively within a Botica environment, not as standalone
applications. You cannot simply run the main method of your BotBootstrap class manually.
Check out Running your bot in the documentation to learn how to run your bot in a Botica environment.
For a complete overview of botica-lib-java features and detailed guides, please refer to the
full documentation:
This project is distributed under the MIT License.