telegram-bot gem puts a controller between Rails and the Bot API
Ruby gem for building Telegram Bot with optional Rails integration
At a glance
- What is it?
- telegram-bot is a Ruby gem for building Telegram bots, built around a controller that dispatches updates to methods, a client over the Bot API, a development poller with source reloading and an async mode for queue-backed processing. It suits Rails teams that want webhook deployment with a readable handler layer, and it is a poor fit for a project that has moved off Rails or needs a maintained API client.
- Who is it for?
- telegram-bot is worth adopting for a Rails application that already wants webhook deployment, a controller layer instead of a case statement, and sessions, in a Ruby stack where a Bot API client is otherwise something you would write yourself. It is the wrong choice if you are on a modern Ruby release without Rails, because the readme is framed around Rails configuration and credentials, and if you want a client whose method list is guaranteed to track the current Bot API.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Activity is slowing. The repository last received commits 6 months ago.
- What is it written in?
- Mainly Ruby, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.
Editorial analysis
A controller for updates, so handlers are methods rather than branches
The central design decision in this gem is that a bot's update handling should look like a web controller rather than a long conditional. The readme puts it plainly: the controller does nothing more than finding the action name for an update and invoking it, so there is almost no overhead compared to a large switch, while actions can be represented as separate methods that keep the source readable and supportable. A new instance of the controller is created for each update, which the readme explains means every update is processed in isolation from the others. That is the piece that decides the concurrency story for you. The controller also inherits the familiar Rails controller features, including callbacks, rescue_from and instrumentation, so a team that already knows Rails does not have to learn a second model. Bot controllers are used the way ordinary Rails controllers are, with the bot's own type, and the class naming follows that convention. The tradeoff is real and worth naming: the isolation per update is convenient, but it means per-update state cannot simply live in an instance variable between messages, which is why the gem ships a session feature as a separate concept.
A thin client over the Bot API that returns parsed JSON
The client is the piece most people will touch first, and it is deliberately thin. A client is instantiated with Telegram::Bot::Client.new(token, username), where the username is optional and used only to parse commands with mentions. There is a generic request(path_suffix, body) method for any query, plus shortcuts for all available requests written in underscored style, so answer_inline_query(params) instead of answerInlineQuery, and the readme's example is : bot.request(:getMe) or bot.get_me. There is no magic in that, the parameters are passed as is and the path suffix is set. The method list is generated from the Bot API documentation into a file in the repository, and the readme asks for a pull request or an issue when a new API version adds methods that are missing. That request is worth weighing, because it tells you the surface area tracks the Telegram API only as far as someone has updated that file. Responses are parsed JSON by default, and any API request error raises Telegram::Bot::Error with a description in the message, while Telegram::Bot::Forbidden is raised when the bot can no longer post messages to a chat. Typed responses are opt-in through the separate telegram-bot-types gem, which returns virtus models rather than plain hashes.
One configuration shape for plain Ruby and a second for Rails secrets
Configuration is handled in two layers, and the difference matters if you are not on Rails. Clients can be instantiated explicitly, but there is also a Telegram.bots_config= method that configures app-wide clients, accepting a hash of bot_id to bot_config with a special :default id used by Telegram.bot. The readme's example shows a default bot, a second bot with a token, a username for commands with mentions such as /help@ChatBot, and a server pointing at a local Bot API server:
Telegram.bots_config = {
default: DEFAULT_BOT_TOKEN,
chat: {
token: CHAT_BOT_TOKEN,
username: 'ChatBot', # to support commands with mentions (/help@ChatBot)
server: 'http://local.bot.api.server', # for Local Bot API Server
},
}
Telegram.bot.get_updates
Telegram.bot == Telegram.bots[:default] # true
Telegram.bots[:chat].send_message(...)In a Rails application the same configuration is read from secrets.yml automatically, from the telegram section:
development:
telegram:
# Single bot can be specified like this
bot: TOKEN
# or
bot:
token: TOKEN
username: SomeBot
server: http://local.bot.api.serverThe Rails path also has a documented wrinkle. For Rails 5.2 and above the gem searches credentials first and then secrets, and to use credentials as the config store you add a telegram section with rails credentials:edit, with the caveat that Rails below 6.0 may not load credentials in the development environment by default. The author goes further and recommends against Rails 5.2 credentials, on the grounds that it can lead to leakage of sensitive data and is harder to use across multiple environments, pointing at the secure_credentials gem as a better option.
Install it as a gem, then pick poller or webhook for the mode
Installation is a normal Bundler dependency. You add the gem to the application's Gemfile:
gem 'telegram-bot'and then run bundle, or install it directly with:
gem install telegram-botRequiring it is optional, since the readme notes you require it if necessary:
require 'telegram/bot'The deployment mode is the decision that follows. The readme states the intended arrangement plainly: the gem is supposed to be used in webhook mode in production and poller mode in development, and you can use the poller in production if you want. The poller is described as having an automatic source-reloader for the development environment, which means a long-running process that watches your code and restarts or reloads when you change it, so editing a handler does not mean restarting the bot. The webhook path is supported by middleware and routes helpers, and the gem also ships rake tasks to update webhook URLs, which is the piece that makes the production switch a matter of running a task rather than editing a URL by hand. Both modes receive the same updates, so the choice is about where the process lives and who initiates the connection, and the readme links a wiki page for applications that are not Rails, plus a separate sample application and a Rails app template for generating a new project.
Async mode moves network errors into the queue, and carries limits
The async mode is listed as a package feature with a blunt summary: let the queue adapter handle network errors. The idea is that a Telegram API call made inside a job can fail transiently and be retried by whatever queue backend the application already runs, rather than by logic inside the bot. That is a sensible division of responsibility in a Rails application that already has ActiveJob or Sidekiq. The readme has a dedicated Limitations subsection under async mode, which is where the caveats live, and the whole section sits in the table of contents as a peer of deployment and testing. Two structural limits of the gem are visible elsewhere in the same table of contents and in the repository layout. The debugging and testing features are there, with a development and debugging section and a testing section, and the spec directory and .rspec file confirm an RSpec suite exists. The gemspec, Appraisals file and a gemfiles directory point to a matrix of dependency sets, and the .rubocop.yml and .codeclimate.yml files show a linting and quality setup, with a Code Climate badge in the readme.
Maintenance is the deciding fact for any new adopter
Here is the awkward part of the record. The last push to the repository was on 2026-04-05, which is outside the six month window from today, so this is not a project with a steady commit stream you can count on. The published releases tell a similar story. The newest tagged release is v0.12.4 from 2018-01-19, and the readme is explicit that it is not the latest release, and the one before it, v0.11.0, dates from 2017-02-10. A version line that ends in 2018 while commits continue into 2026 usually means the gem is still usable, and its maintainers push fixes, without a release train a new project can pin to. The practical consequence is that you should check the gem version actually available from your package source rather than assuming the tag history reflects the state of the code, and that dependency resolution on a current Ruby is the first thing to try. The licence is MIT, held in a LICENSE.txt file, and the repository keeps a CHANGELOG.md. Everything else the gem offers, sessions, keyboards, inline queries, is demonstrated in a separate sample application rather than in the readme, and the wiki is where the examples and cookbook live.
Editorial conclusion
telegram-bot is worth adopting for a Rails application that already wants webhook deployment, a controller layer instead of a case statement, and sessions, in a Ruby stack where a Bot API client is otherwise something you would write yourself. It is the wrong choice if you are on a modern Ruby release without Rails, because the readme is framed around Rails configuration and credentials, and if you want a client whose method list is guaranteed to track the current Bot API. Verify first that the gem still installs and its dependencies resolve on your Ruby version, since the last push was on 2026-04-05 and the newest published gem release is v0.12.4 from 2018-01-19, and that the poller and webhook modes both work before you rely on either.
Frequently asked questions
How do I install the telegram-bot gem?
Add gem 'telegram-bot' to your Gemfile and run bundle, or install it directly with gem install telegram-bot. You can require it with require 'telegram/bot' if the gem is not auto-loaded.
Should I run a Telegram bot in webhook or poller mode?
The readme says the gem is supposed to be used in webhook mode in production and poller mode in development, and you can use the poller in production if you want. The poller includes an automatic source reloader, and the gem ships rake tasks to update webhook URLs.
How do I configure multiple bots in one application?
Set Telegram.bots_config to a hash of bot_id to bot_config, using the special :default id for Telegram.bot. In a Rails app the same settings are read from the telegram section of secrets.yml or credentials, and clients are then reached as Telegram.bots[:chat].
What happens when a Telegram API request fails in the telegram-bot gem?
Any API request error raises Telegram::Bot::Error with the description in its message. A separate Telegram::Bot::Forbidden error is raised when the bot can no longer post messages to the chat.
Is telegram-bot still maintained?
The last push was on 2026-04-05, and the newest published release is v0.12.4 from 2018-01-19, which the readme notes is not the latest release. Commits continue but there is no recent release tag to pin to, so check the version your package source actually serves before adopting it.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/telegram-bot-rb-telegram-bot)Was this useful?