This project is a simplest way to create a Telegram bot with Scala API: TelegramBotScalaApi.
It have all dependencies that you need, CLI parsing, logging, monitoring and packaging into docker. You will have you own bot platform.
Requirements for your environmet:
- SBT and Scala version 2.12 or higher
- Docker and Docker Compose version 2 or higher
To create your own bot just follow next steps:
- Create your bot in Telegram and get bot API key, instructions: Creating your bot in Telegram
- Clone this repository to your computer:
git clone https://github.com/kgribov/TelegramBot.git
- Go to directory with project:
cd TelegramBot
- Build it using SBT:
sbt docker
- Grand permissions for start script:
chmod +x startup.sh
- Start bot with script:
./startup.sh <Bot API key>
That's all, your bot is running now!
You can type something to him and he will calculate your message size or type /random
command to get a random number.
Open bot dashboard Bot Dashboard to see metrics of your bot.
If you don't see any data on dashboard, don't panic! Give some time to system to fully start-up (like 1-2 minutes).
To create your bot in Telegram follow official instructions from Telegram team: Instructions.
Don't forget to disable privacy rules for your bot, to read all messages in chat, BotFather could do it with command: /setprivacy
, set status to DISABLED.
If you want to implement your own message processing, your own commands and dialogs with bot, open and modify class CreateBotSchema
.
To discover all bot Scala API features, read documentation in Scala API repo: API features
TODO
With your bot, in docker we start next services: Logstash
, Graphite
, Grafana
.
Logstash post metrics from logs to Graphite, and Grafana show dashboard with your metrics.
Your Grafana dashboard is here: Bot Dashboard
Example of dashboard view:
You could read more about this frameworks here: