{"id":21169319,"url":"https://github.com/koraykoska/chatbot_helper-telegram","last_synced_at":"2026-05-19T03:04:56.583Z","repository":{"id":56843418,"uuid":"88500493","full_name":"koraykoska/chatbot_helper-telegram","owner":"koraykoska","description":"A helper library for telegram chatbots","archived":false,"fork":false,"pushed_at":"2017-04-20T17:48:45.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T20:07:58.961Z","etag":null,"topics":["rails","ruby","sinatra","telegram","telegram-bot","telegram-bot-api","telegram-chat-bot"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koraykoska.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-17T11:08:40.000Z","updated_at":"2017-04-20T17:49:33.000Z","dependencies_parsed_at":"2022-09-07T07:11:06.425Z","dependency_job_id":null,"html_url":"https://github.com/koraykoska/chatbot_helper-telegram","commit_stats":null,"previous_names":["ybrin/chatbot_helper-telegram"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koraykoska%2Fchatbot_helper-telegram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koraykoska%2Fchatbot_helper-telegram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koraykoska%2Fchatbot_helper-telegram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koraykoska%2Fchatbot_helper-telegram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koraykoska","download_url":"https://codeload.github.com/koraykoska/chatbot_helper-telegram/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243615564,"owners_count":20319733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","ruby","sinatra","telegram","telegram-bot","telegram-bot-api","telegram-chat-bot"],"created_at":"2024-11-20T15:28:22.327Z","updated_at":"2026-05-19T03:04:56.553Z","avatar_url":"https://github.com/koraykoska.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChatbotHelper::Telegram [![Gem Version](https://badge.fury.io/rb/chatbot_helper-telegram.svg)](https://badge.fury.io/rb/chatbot_helper-telegram) [![Build Status](https://travis-ci.org/Ybrin/chatbot_helper-telegram.svg?branch=master)](https://travis-ci.org/Ybrin/chatbot_helper-telegram) [![Code Climate](https://codeclimate.com/github/Ybrin/chatbot_helper-telegram/badges/gpa.svg)](https://codeclimate.com/github/Ybrin/chatbot_helper-telegram) [![Test Coverage](https://codeclimate.com/github/Ybrin/chatbot_helper-telegram/badges/coverage.svg)](https://codeclimate.com/github/Ybrin/chatbot_helper-telegram/coverage)\n\n`ChatbotHelper::Telegram` helps you build awesome Telegram chatbots without bothering much about the documentation, the message structure or other details. It is a wrapper around the [Telegram Bot API](https://core.telegram.org/bots/api).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'chatbot_helper-telegram'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install chatbot_helper-telegram\n\nThen require it and you are good to go:\n\n```ruby\nrequire 'chatbot_helper/telegram'\n```\n\n## Usage\n\nAs of now, you are responsible for getting messages or other objects from the Telegram Bot API with your favorite HTTP library. We consider adding all Bot API methods to this library in one of the next versions. Please open an [issue](https://github.com/Ybrin/chatbot_helper-telegram/issues) if you think that's a good idea.\n\nAn example with [typhoeus](https://github.com/typhoeus/typhoeus):\n\n```ruby\nrequire 'typhoeus'\nrequire 'chatbot_helper/telegram'\nrequire 'json'\n\n# Your environment must have set the `TELEGRAM_TOKEN` key to your telegram api\n# token. See https://core.telegram.org/bots#3-how-do-i-create-a-bot for more\n# information.\ntelegram_token = ENV['TELEGRAM_TOKEN']\nurl = \"https://api.telegram.org/bot#{telegram_token}/sendMessage\"\n\n# We create a message\nmessage = {\n  chat_id: 123456,\n  text: \"This is an example message sent by my telegram bot\"\n}\n\nrequest = Typhoeus::Request.new(\n  url,\n  method: :post,\n  body: JSON.generate(message),\n  headers: { 'Content-Type' =\u003e 'application/json' }\n)\nrequest.run\n\nbody = request.response.body\n\n# We create a Message object from the response body\nmessage = ChatbotHelper::Telegram::Message.new(string: body)\n\n# Now you can access all properties of the message object\nputs message.date\nputs message.from.first_name\n\n# Yay!\n```\n\nThe real power of this library is the update and command parsing.    \nSay, for example, you have set up [webhooks](https://core.telegram.org/bots/api#setwebhook) and you want to parse the updates retrieved from these webhook requests. This is a [sinatra](http://www.sinatrarb.com/) example but you can easily convert it to Rails code.    \n\n```ruby\nrequire 'sinatra'\nrequire 'chatbot_helper/telegram'\nrequire 'json'\n\npost \"/#{ENV['TELEGRAM_TOKEN']}/?\" do\n  request.body.rewind\n  payload_body = request.body.read\n\n  # Create an instance of Update from the request body...\n  update = ChatbotHelper::Telegram::Update.new(string: payload_body)\n\n  # Return a message based on the given command\n  message = {}\n  if update.message\n    # Access the chat id through the given message\n    message[:chat_id] = update.message.chat.id\n\n    case update.message.text\n    when '/start'\n      text = \"Hello and welcome to my awesome bot #{update.chat.first_name}!\"\n      message[:text] = text\n    when '/saysomething'\n      text = \"Why should I talk with you, #{update.chat.first_name}? Give me \"\\\n             \"a reason!\"\n      message[:text] = text\n    end\n\n    # Return the message which should be sent\n    return halt 200, { 'Content-Type' =\u003e 'application/json' }, JSON.generate(message)\n  end\n\n  # Fallback, return nothing\n  return halt 200, { 'Content-Type' =\u003e 'application/json' }, '{}'\nend\n```\n\nYou can work with nearly all Telegram Bot API [available types](https://core.telegram.org/bots/api#available-types).    \nOne exception are the `Inline mode` types which has currently just partial support and will be fully available in the next version.\n\nIf you need help or have a feature request feel free and open an [issue](https://github.com/Ybrin/chatbot_helper-telegram/issues).\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/Ybrin/chatbot_helper-telegram.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoraykoska%2Fchatbot_helper-telegram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoraykoska%2Fchatbot_helper-telegram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoraykoska%2Fchatbot_helper-telegram/lists"}