Description
Library for Object-Oriented and type-safe work with Telegram Bot API.
TelegramBotAPI alternatives and similar libraries
Based on the "Multiplatform" category.
Alternatively, view TelegramBotAPI alternatives based on common mentions on social networks and blogs.
-
kotlin-multiplatform-bignum
A Kotlin multiplatform library for arbitrary precision arithmetics -
🍲 Foodium (Kotlin Multiplatform Mobile)
📱Sample application built to demonstrate the use of Kotlin Multiplatform Mobile for developing Android and iOS applications using Jetpack Compose 🚀. -
Kotlin Spotify Web API
Spotify Web API wrapper for Kotlin, Java, JS, and Native - Targets JVM, Android, JS (browser), Native (Desktop), and Apple tvOS/iOS. Includes a Spotify Web Playback SDK wrapper for Kotlin/JS, and a spotify-auth wrapper for Kotlin/Android. -
NoCopy Compiler Plugin
A Kotlin compiler plugin that removes the `copy` method of data classes. -
KMQTT
Kotlin Multiplatform MQTT client & embeddable and standalone broker -
krontab
Library for using Crontab-like syntax in scheduling of some Kotlin Coroutines tasks to do from time to time -
NonEmptyCollections
A type-safe implementation for collections that cannot be empty. Life is too short for emptiness-checks!
Appwrite - The Open Source Firebase alternative introduces iOS support
Do you think we are missing an alternative of TelegramBotAPI or a related project?
README
TelegramBotAPI

Docs | |
---|---|
Useful repos | |
Misc |
<!--- [Telegram Channel](./resources/tg_channel_qr.jpg) --->
Hello! This is a set of libraries for working with Telegram Bot API.
Examples
There are several things you need to do to launch examples below:
- Add
mavenCentral()
to your project repositories - Add dependency
implementation "dev.inmo:tgbotapi:$tgbotapi_version"
- Replace
tgbotapi_version
with exact version (see last one in the table above) or put variable with this name in project - Alternative variant for maven here
- Replace
More including instructions available here. Other configuration examples:
Most common example
suspend fun main() {
val bot = telegramBot(TOKEN)
bot.buildBehaviourWithLongPolling {
println(getMe())
onCommand("start") {
reply(it, "Hi:)")
}
}.join()
}
In this example you will see information about this bot at the moment of starting and answer with Hi:)
every time it
gets message /start
Handling only last messages
suspend fun main() {
val bot = telegramBot(TOKEN)
val flowsUpdatesFilter = FlowsUpdatesFilter()
bot.buildBehaviour(flowUpdatesFilter = flowsUpdatesFilter) {
println(getMe())
onCommand("start") {
reply(it, "Hi:)")
}
retrieveAccumulatedUpdates(this).join()
}
}
The main difference with the previous example is that bot will get only last updates (accumulated before bot launch and maybe some updates it got after launch)
Build a little bit more complex behaviour
suspend fun main() {
val bot = telegramBot(TOKEN)
bot.buildBehaviourWithLongPolling {
println(getMe())
val nameReplyMarkup = ReplyKeyboardMarkup(
matrix {
row {
+SimpleKeyboardButton("nope")
}
}
)
onCommand("start") {
val photo = waitPhoto(
SendTextMessage(it.chat.id, "Send me your photo please")
).first()
val name = waitText(
SendTextMessage(
it.chat.id,
"Send me your name or choose \"nope\"",
replyMarkup = nameReplyMarkup
)
).first().text.takeIf { it != "nope" }
sendPhoto(
it.chat,
photo.mediaCollection,
entities = buildEntities {
if (name != null) regular(name) // may be collapsed up to name ?.let(::regular)
}
)
}
}.join()
}
More examples
You may find examples in this project. Besides, you are always welcome in our bookstack and chat.