There are two ways a bot can be run: polling, which is when the bot sends constant requests to Telegram and looks for new updates, and webhooks, which is where the bot listens for updates, and Telegram sends them as they come in. Both methods have their pros and cons; for instance, it's much easier to do a multi-tenant bot using webhooks.
Note: Telegram requires webhooks to be run using HTTPS.
Setting a Webhook
Tourmaline comes with a few webhook specific methods:
serve. To set a webhook and start your bot listening for requests it's pretty simple.
It's recommended by Telegram to include either your bot's token, or some kind of randomly generated identifier in the path since then only Telegram will know exactly where to send requests.
Unsetting or Deleting a Webhook
Should you decide to switch back to polling it would be good to either unset or delete your webhook so that Telegram stops sending updates there. Doing that is easy:
Local Webhook Testing
It can be nice to test your bot locally using webhooks, as they are a bit faster than polling. Doing so is pretty easy if you use Tourmaline in conjunction with the ngrok.cr shard. Here is a simple example of that working: