• Stars
    star
    143
  • Rank 251,537 (Top 6 %)
  • Language
    Ruby
  • Created over 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

http://telegram.org Bot API Webhooks Framework, for Rubyists

BOTServer

Telegram Bot API Webhooks Framework, for Rubyists.
BOTServer configures, tests and deploys bots, running a fast rack server for webhooks routing.

Telegram Bots Platform Architectures ?

Details about Telegram Bot API long polling vs webhooks: Telegram Bot Platform

Webhooks ?

There are at least three Telegram Bot Ruby clients (as far as I know), here listed Telegram BOT Ruby clients:

NOTE: All of them implement Telegram Bot API long polling way, with getUpdates endpoint. No one of these gems implement the webhooks mode.

  • Webhooks vs long polling

    BOTServer first goal is to set-up a Ruby way to manage Telegram Bot API webhooks Updates, a performance improvement in comparison with HTTPS long polling mode.

    This project is related to telegram-bot-ruby gem, Alexander Tipugin's excellent Telegram Bot client APIs wrapper; to thank him for his work, I tried to solve issue #19: setting up webhooks with telegram-bot-ruby ?. BOTServer closed the issue :)

  • Multiple bots webhooks updates routing

Receiving HTTPS webhooks callbacks is probably more efficient than getting updates on a long polling connection, but the real need of webhooks is when you have dozen, hundreds of bots to manage at once with your server. In this scenario, it could pretty impossible to manage in a single host, using long polling connections, because the need to maintain open too many Ruby processes/ HTTPS (persistent) connections.

** BOTServer is a toolkit to test and deploy Bot tokens to receive webhooks with a very simple dynamic routing server: a rack server that dispatch dinamically incoming token webhooks, calling update method of an instance of a class generated with a template sckeleton, that define the bot. Details: Telegram Bot Architecture(s)**

  TELEGRAM Bot API Server                         
 --------------------------------------------------------------------
   v v v                                                       ^ ^ ^
   | | |                                                       | | |
   | | |    SSL/HTTPS                                          | | | 
   | | |    front-end       BOTServer                          | | |
   | | |    +-------+       Rack router                        | | |
   | | |    |       |       +------+                           | | |
   | | |    |       |       |      |     +-------+ HTTPS send  | | |
   | | |    |       |       |      |---->| App 1 |-------------+ | |
   | | |    |       | HTTP  |      |     +-------+               | |
   | | |    |       | POST  |      |                             | |
   | | +--->|       |------>|      |     +-------+ HTTPS send    | |
   | +----->|       |------>|      |---->| App 2 |---------------+ |
   +------->|       |------>|      |     +-------+                 |
   webhooks |       |       |      |                               |
 HTTPS POST |       |       |      |     +-------+  HTTPS send     |
            |       |       |      |---->| App   |-----------------+
            |       |       | Thin |     +-------+
            | NGINX |       +------+
            +-------+       

Assembly instructions in 7 steps

BOTServer is a devops utility to:

  • set-up and test tokens/webhooks
  • generate a template app for each bot
  • run a webhooks router/server.

Here assembly instruction steps:

  1. Installation (web/proxy server, Ruby project code)
  2. Get Telegram Bot token(s)
  3. Update configuration files
  4. Create (self-signed) Certificate
  5. Configure "Webhooks mode" for each token
  6. Generate template for each bot
  7. Deploy and run _BOTServer

Keep calm and follow step by step instrctions: Assembly instructions in 7 steps

After installation of the project, just run rake from your project home:

$ rake
rake app:new[token]        # Create bot app template for given token
rake certificate:new       # Create SSL certificate
rake certificate:show      # Show public certificate
rake proxy:config:new      # Generate nginx proxy SSL configuration from server.yml data
rake proxy:restart         # Restart proxy server
rake proxy:start           # Start proxy server
rake proxy:stop            # Stop proxy server
rake server:config:show    # Show server configuration: /home/solyaris/BOTServer/config/server.yml
rake server:config:test    # Check server configuration: /home/solyaris/BOTServer/config/server.yml
rake server:log            # Tail -f rack sever logfile: /home/solyaris/BOTServer/log/thin.log
rake server:pid            # Show rack server pid
rake server:restart        # Restart rack server
rake server:start          # Start rack server
rake server:stop           # Stop rack server
rake tokens:show           # Show tokens configuration file: /home/solyaris/BOTServer/config/tokens.yml
rake tokens:test           # Verify if tokens are valid, online querying Telegram Server
rake webhook:reset[token]  # Reset webhook for a given token
rake webhook:set[token]    # Set webhook for a given token

Documentation / wiki

To do/Releases

License

Credits/Contributing/Contact

More Repositories

1

posprinterdriver

Android ESC/POS Printer Driver (https://play.google.com/store/apps/details?id=com.fidelier.posprinterdriver) usage notes
HTML
65
star
2

dialogs

A dialog system framework for conversational services.
Ruby
61
star
3

WeBAD

Web Browser Audio Detection/Speech Recording Events API
JavaScript
29
star
4

voskJs

Vosk ASR offline engine API for NodeJs developers. With a simple HTTP ASR server.
JavaScript
28
star
5

naifjs

NaifJs, a simple state-machine based dialog manager.
JavaScript
23
star
6

sinatra-api-server-toolbox

Sinatra API Server Toolbox (Ruby, Sinatra, ActiveRecord, postgreSQL, JSON, jQuery, AJAX)
Ruby
21
star
7

Highlight.vim

Highlight vim plugin colorizes pattern of texts, with a random or specified background colors
Vim Script
17
star
8

CoquiSTTJs

Coqui STT offline engine API for NodeJs developers. With a simple HTTP ASR server.
JavaScript
17
star
9

PERE

Push Events with Return-receipt Engine: a Ruby-Sinatra SSE Pub/Sub demo framework
Ruby
12
star
10

DeepSpeechJs

DeepSpeech runtime transcript NodeJs native client
JavaScript
10
star
11

rChatScript

simple ChatScript client Ruby gem
Ruby
8
star
12

jointts

brainless concatenative text to speech
JavaScript
7
star
13

blomming_api

www.blomming.com social commerce client API Ruby wrapper
Ruby
4
star
14

nera.vim

Named Entities (Rasa-like) syntax Annotator for vim editor
Vim Script
4
star
15

SMS-Echo-Server

Simple Ruby Sinatra SMS Echo Server, using www.skebby.com SMS Gateways services.
Ruby
3
star
16

conversator

chat bot conversations "router": framework to connect users to operators (humans or bots)
3
star
17

ChatScript.vim

Vim syntax for ChatScript topic files.
Vim Script
3
star
18

iso6346

intermodal (shipping) containers markings (ISO 6346) validator
JavaScript
1
star