Skip to content
Example Rails 5 Telegram bot app
Ruby HTML JavaScript CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
app telegram-bot 0.14 Jun 7, 2018
config Update telegram-bot to 0.13.0 May 12, 2018
spec telegram-bot 0.14 Jun 7, 2018
vendor/assets rails new telegram_bot_app May 15, 2016
.gitignore Basic bot May 15, 2016
Gemfile telegram-bot 0.14 Jun 7, 2018
Gemfile.lock telegram-bot 0.14 Jun 7, 2018 Fix file_store configuration, add note about session stores Jan 3, 2018
Rakefile rails 5.0.1, add missing files after update to 5.0.0 Dec 30, 2016

Example telegram bot app

This app uses telegram-bot gem. Want to see the bot code first?

Explore separate commits to check evolution of code.

Want a clean setup instead? Here is app teamplate to help you.


  • /start - Greeting.
  • /help
  • /memo %text% - Saves text to session.
  • /remind_me - Replies with text from session.
  • /keyboard - Simple keyboard.
  • /inline_keyboard - Inline keyboard example.
  • Inline queries. Enable it in @BotFather, and your're ready to try 'em.
  • /last_chosen_inline_result - Your last chosen inline result (Enable feedback with sending /setinlinefeedback to @BotFather).


  • Create bot with @BotFather unless has_test_bot?
  • Clone repo.
  • run ./bin/setup.
  • Update config/secrets.yml with your bot's token.



bin/rake telegram:bot:poller


One way is just to run poller. You don't need anything else, just check your production secrets & configs. But there is better way: use webhooks.

You may want to use different token: after you setup the webhook, you need to unset it to run development poller again.

First you need to setup the webhook. There is rake task for it, but you're free to set it manually with API call. To use rake task you need to set host in routes.default_url_options for production environment (config.routes for Rails < 5). There is already such line in the repo in production.rb. Uncomment it, change the values, and you're ready for:

bin/rake telegram:bot:set_webhook RAILS_ENV=production

Now deploy your app in any way you like. You don't need run anything special for bot, but rails server as usual. Your rails app will receive webhooks and bypass them to bot's controller.

By default session is configured to use FileStore at Rails.root.join('tmp', 'session_store'). To use it in production make sure to share this folder between releases (ex., add to list shared of shared folders in capistrano). Read more about different session stores in original readme.




Async mode

  • Uncomment async: true in secrets.yml.
  • Run and check the logs out.
  • More info about async mode.


  • Get token at
  • Uncomment botan section in secrets.yml and update token.
  • Run.


Bug reports and pull requests are welcome on GitHub at

You can’t perform that action at this time.