Kemal Middleware


If you're not aware, kemal is a lightweight web application framework for Crystal similar to Ruby's Sinatra. It is extremely fast, and prefect for hosting a Telegram bot, especially if you wish to also integrate a web front end, API, etc.

The Kemal Adapter

Using Tourmaline in your Kemal project is pretty simple:

require "kemal"
require "tourmaline/adapters/kemal"
require "./yourbot" # change this to your bot
# Add handler is a Kemal method for adding middleware
# pass in a new instance of your bot
# set the url
url: "",
# set the path to serve the webhook on
path: "/bot-webhook/#{ENV["TGBOT_API_KEY"]}"