Telegram URL schema: which url to trigger the client to open the "share/send to" dialogue

teleme.io picture teleme.io · Jun 30, 2018 · Viewed 13.2k times · Source

I am working on an telegram bot, and looking for the exact URL schema to popup the "Share / Select Group / Send to" dialogue in the telegram client.

I have seen this link in @pollbot, for which I took following screenshots.

When click this link, Telegram client will popup send to dialogue


A bit more details:

  1. What I want is to give end-user an easy way to add the bot to their group, just like what PollBot does: When a poll being created, PollBot will return a special like to the user. Any by clicking that link, the user could easily add PollBot to a group. So I'm looking for the exact URL schema of that link.
  2. I then check that link PollBot sent to me in telegram web client, and found out it's a tg protocol url: tg://resolve?domain=PollBot&startgroup=5148bed5f90678b93246464b3e132052. So I tried to resend this url via bot.sendMessage. But it turned out Telegram api server won't parse the tg://resolve url.
  3. So, how could the bot manage to send such a link to the user?

Answer

Thorbijoern picture Thorbijoern · Jul 2, 2018

The link there works with deeplinking, please read about it here: https://core.telegram.org/bots#deep-linking

the url has the following scheme:

https://telegram.me/<YourBotUsername>?startgroup=<Payload>

the startgroup part (parameter) of the url tells telegram to open the 'add to group' dialog. when you choose a group there (and you can add bot's to it) the bot will be added to the group and /start PAYLOAD will be send to that group. The Payload is what you defined as value of the startgroup parameter, so your bot can assosiate it with something and send the matching reply.

please mind, that the Payload can only contain certain characters and don't mind that the telegram clients might internaly convert that link to an tg:// url.

you can also use start instead of startgroup to open a private chat.