Transform any Telegram bot into (almost) an app
Tags: telegram, lifehack, chatbots
Published: 2022-01-13 21:49:59

Telegram bots are powerful tools that can do a lot of things. However, they have at least one major drawback: to use a bot you have to find the Telegram app, open it, find and, finally, open the bot. It introduces significant overhead and friction, reducing the likelihood that the bot will be used.

Turns out, you can create a shortcut for any one on one chat with a bot – it will open the Telegram app and required chat automatically. My access time decreased from 5-10 seconds to 1.

## How it works

When you open a bot link `https://telegram.me/[bot_handle]`, for example, [https://telegram.me/list_ok_bot](https://telegram.me/list_ok_bot), in most cases the browser will suggest opening the bot in the Telegram app. It does it by calling a link like `tg://resolve?domain=[bot_handle]` (you can look it up in the page's sources). This is a Telegram call to open a chat with this bot, either existing or a new one.

As far as I can judge, it should work on any modern platform. I have tested it on iOS, Windows, and Linux (Linux Mint to be precise). I see no reasons why it should not work elsewhere.

Therefore, to use this mechanism you can create a shortcut that opens one of the two links:

1. `https://telegram.me/[bot_handle]` aka web link – it will first open the default browser, which in turn should redirect to the bot. The exact behavior will depend on your browser and settings.

2. `tg://resolve?domain=[bot_handle]` aka app link – it will directly call the Telegram app, without the browser as an intermediary.

The second approach should be faster and I will use it in the examples below. It may take a couple of tries to find the best way for your device.

A word on styling the shortcut: usually you can provide your logo (e.g., the bot picture) or choose from existing.

## iOS

In the Shortcuts app you need to create a new shortcut with one command:

![iOS shortcut settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnrsi6fliodauxicvz29.jpg)

After that you can add it to the Home Screen as an icon from the sharing or shortcut settings interface (third icon):

![iOS Telegram bot shortcut on Home Screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm3a8m7dp5au5kvofzkn.jpg)

## macOS

On macOS, you can use the Shortcuts app with the same settings as on iOS. You can also enable your iOS shortcuts on your Mac.

## Android

I do not have an Android device at the moment, but I am sure that it can be done here as well – you just need to create a shortcut with the web or app link, or use similar a approach as on iOS.

## Windows

On Windows, it is enough to create a shortcut with the app link `tg://resolve?domain=[bot_handle]`.

## Linux

### Shortcut

Details in each Linux distribution may be different, but the idea should be the same: create a shortcut with a command that would open the web or app link.

For example, the following does the trick in Linux Mint Cinnamon: `xdg-open tg://resolve?domain=[bot_handle]`. To add this shortcut (they are called launchers in LM) to the panel you need first to agree to add it to the menu (you will be prompted after creating the launcher), then find it in the menu, right-click and choose 'Add to panel'.

![Adding launcher to Linux Mint Cinnamon panel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/belcd183plwq4bpmtp2f.png)

### Ulauncher

In [Ulauncher](https://ulauncher.io/) – an application launcher for Linux – you need to open settings and create a shortcut with `xdg-open tg://resolve?domain=[bot_handle]` (as discussed, can differ in other distributions) and allow it to run without arguments.

![Adding launcher to Linux Mint Cinnamon panel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9todnt6yzqzzwyhrln2v.png)

After that you can call the shortcut as follows:

![Ulauncher Telegram bot shortcut](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bxjevnrqr6yyr7rrdt38.png)

## Browser

Add a bookmark with the web or app link – depending on the browser and settings one or the other may work better.