How to create telegram bots in Ruby
Source: Dev.to

You must have heard of or used Telegram bots.
Now the deep question is: how are they created? We’re going to see that—get your IDE ready because we’re going to create a bot in 5 minutes.
Requirements
- A good IDE with Ruby installed
- Basic or advanced knowledge of Ruby
- Bot token from @BotFather
If you don’t know how to get your bot token, check out this post 👉 How to get your Telegram token.
Setup
1. Create a Gemfile
source 'https://rubygems.org'
gem 'telegem', '~> 3.0.4'
gem 'dotenv', '~> 2.8'
# add any other gems you wish (httparty, nethttp, json, etc.)
2. Install dependencies
If you’re using Bundler:
bundle install
Or install the gems manually:
gem install telegem dotenv
3. Add your bot token
Create a .env file in the project root:
BOT_TOKEN=11234:445849489449 # replace with your actual token
Creating the Bot
Create a file named bot.rb:
# bot.rb
require 'telegem'
require 'dotenv/load'
bot = Telegem.new(ENV['BOT_TOKEN'])
bot.command('start') do |ctx|
ctx.reply('welcome to test2bot')
end
bot.command('help') do |ctx|
ctx.reply('**u need help**', parse_mode: 'Markdown')
end
bot.start_polling
puts 'bot has started'
Running the Bot
bundle exec ruby bot.rb
Your bot will now respond to the /start and /help commands.
Further Resources
For a more in‑depth tutorial and additional examples, see the official repository: 👉 Telegem examples.