Template project to facilitate implementing, compiling, and building Botica bots using Maven and botica-lib-java.
You have two main options for setting up your bot project:
If you want to create this bot as a subdirectory to an existing Botica project (e.g., alongside your
environment.yml file), use the Botica Director's init command:
./botica-director init java <your-bot-directory-name>Replace <your-bot-directory-name> with the desired folder name for your bot's project (e.g.,
worker-bot). This command will create the project files directly in that subdirectory.
If you want to develop this bot in its own dedicated Git repository, click the Use this template button on GitHub to create a new repository based on this one.
Modify the pom.xml file, specifically:
- The
<groupId>and<artifactId>tags to match your project's naming conventions. - The
<mainClass>property, pointing to your bot's entry point class (e.g.,com.myorg.BotBootstrap). This assumes you might rename the template classes or packages insrc/.
Implement your bot's logic by extending BaseBot. You can follow one
of these examples for inspiration.
Note
Full project examples are also available, with their respective Java implementations. Check out botica-infrastructure-fishbowl or botica-infrastructure-restest.
How you run your bot depends on how you set it up in Step 1.
The Botica Director can automatically build your bot from the source code before starting the environment. You do not need to run any manual build scripts.
In your environment.yml file, use the build property to point to your bot's directory:
bots:
my-java-bot:
# The 'build' property tells the Director to build a Docker image from the
# project located at the specified relative path before running it.
build: "./worker-bot"
replicas: 1
lifecycle:
type: reactiveWhen you run ./botica-director, it will detect the build property, execute the build process
defined in the project's Dockerfile, and then launch the container.
If you are working in a standalone repository, you need to manually build the Docker image so it is
available to your Docker daemon. You can tag it however you like (e.g.,
my-org/my-bot:latest):
docker build -t my-org/my-bot:latest .In your environment.yml file, use the image property to reference the tag you just created:
bots:
my-java-bot:
# The 'image' property tells the Director to look for an existing
# Docker image with this tag.
image: "my-org/my-bot:latest"
replicas: 1
lifecycle:
type: reactive