This repository provides a robust template for creating Robotic Process Automation (RPA) bots using the BotCity framework. The template includes integration with BotMaestroSDK, Telegram Bot notifications, detailed logging, and resource tracking for efficient and scalable automation tasks.
-
Environment-Specific Execution: Easily switch between Maestro (
--environment maestro
) and local (--environment local
) execution modes. -
BotMaestroSDK Integration: Leverage BotCity Maestro for task management and artifact handling.
-
Telegram Notifications: Send real-time execution updates and upload log files to Telegram groups.
-
Detailed Resource Usage Logging: Tracks CPU, RAM, and GPU usage during bot execution.
-
Flexible Configuration: Customize bot settings such as server credentials, log directories, and Telegram groups.
Before running the bot, ensure you have the following installed:
- Python 3.8+
- Poetry (for dependency management)
- BotCity SDK (BotCity Maestro)
- Telegram Bot Token (for bot interaction, if needed)
-
Clone this repository:
git clone https://github.com/vinicinhus/botcity-rpa-template.git cd botcity-rpa-template
-
Install dependencies. You can choose one of the following methods:
-
Using Poetry:
If you are using Poetry for dependency management, run:
poetry install
-
Using
requirements.txt
:Alternatively, if you prefer to use pip and a requirements.txt file, you can install the dependencies as follows:
pip install -r requirements.txt
-
-
Set up your environment variables in a
.env
file:SERVER_MAESTRO="your_maestro_server_url" LOGIN_MAESTRO="your_maestro_login" KEY_MAESTRO="your_maestro_key"
-
Set up your Telegram Bot token:
- Create a bot via BotFather on Telegram.
- Retrieve the token and store it securely in BotCity Maestro under a credential labeled Telegram.
-
Modify
bot.py
orsrc/main.py
to include your automation logic.
To run the bot, specify the desired environment:
-
Maestro Execution (default):
poetry run python bot.py --environment maestro # Or python bot.py --environment maestro
-
Local Execution:
poetry run python bot.py --environment local # Or python bot.py --environment local
- Environment Selection: Use the
--environment
flag to specify the execution environment (maestro
orlocal
). - Bot Details: Set the bot name, server credentials, and Telegram group in
bot.py
or via environment variables. - Logs Directory: Logs are stored in the
logs
folder by default but can be customized.
-
Execution Modes:
- Maestro Mode: Uses the BotMaestroSDK to execute tasks and interact with the BotCity platform.
- Local Mode: Runs tasks locally while still providing logs and notifications via Telegram.
-
Resource Tracking:
- Logs CPU, RAM, and GPU usage during execution for analysis and debugging.
-
Error Handling:
- Sends error messages and uploads logs to Telegram and BotCity Maestro in case of failures.
- Notifications are sent to the configured group about bot execution status (completion and error).
- Log files are automatically uploaded to the Telegram group for analysis.
Logs:
- Generated for each execution and saved in the
logs
directory. - Includes execution time, resource usage, and errors.
Artifacts:
- Automatically uploaded to BotCity Maestro under the associated task.
To extend or modify the bot’s functionality:
-
Implement your custom automation logic in
src/main.py
. -
Add or modify utility classes such as
BotRunnerLocal
orBotRunnerMaestro
. -
Use the
_execute_bot_task
method to define task-specific behavior.
- Fork this repository.
- Create a feature branch.
- Make your changes.
- Commit and push your changes.
- Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
- BotCity for providing the powerful framework for automation.
- Telegram Bot API for integrating with Telegram for bot interactions.
- Poetry for managing project dependencies.