Example Spring Boot application demonstrating telegrambot4j usage
/start,/help,/scancommand handlers- Inline buttons demo with callback handling (
/buttons) - Spring Boot auto-wiring of all handlers via
List<UpdateHandler>
handler/
StartCommandHandler.java - /start command
HelpHandler.java - /help command
ScanCommandHandler.java - /scan command
ButtonsCommandHandler.java - /buttons command, sends inline keyboard
ButtonsCallbackHandler.java - handles button callbacks (approve, reject, etc.)
config/
BotConfiguration.java - wires TelegramApiClient, UpdateDispatcher, PollingService
Add to application.properties:
telegram.bot.token=YOUR_BOT_TOKEN
telegram.bot.name=mybot
telegram.bot.polling.timeout=30
telegram.bot.polling.error-delay=3000
spring.main.keep-alive=true # Keeps Spring Boot alive after startupmvn spring-boot:runTo pull telegrambot4j from GitHub Packages, add to ~/.m2/settings.xml:
<servers>
<server>
<id>github</id>
<username>YOUR_GITHUB_USERNAME</username>
<password>YOUR_GITHUB_TOKEN</password>
</server>
</servers>Token needs read:packages scope.