Sharing from a Mini App
What it is
A Mini App can prepare something and open Telegram's own window to pass it on: a message for any chat, a picture or video for the person's story, an icon on their phone's home screen. Each time, the person confirms.
How to do it
- Message: your bot prepares it for this person with `savePreparedInlineMessage`… Message: your bot prepares it for this person with `savePreparedInlineMessage` and chooses where it may go: chats with users, bots, groups, channels. The app calls `shareMessage` with its id, and Telegram opens the share dialog.
- Link: the app opens `t.me/share?url=<link>&text=<text>` with… Link: the app opens `t.me/share?url=<link>&text=<text>` with `openTelegramLink`. The person picks a chat, and the link and text land in the message field.
- Story: the app calls `shareToStory` with the HTTPS address of a picture or… Story: the app calls `shareToStory` with the HTTPS address of a picture or video and a caption, and Telegram's story editor opens with it.
- Home screen: `checkHomeScreenStatus` tells you whether an icon can be added, and `addToHomeScreen` offers it.
Watch out
- A story caption takes up to 200 characters, or 2048 for Premium users. Only Premium users can add a link, with a name of up to 48 characters.
- A prepared message works only for the person it was made for and expires, so make it right before sharing.
- Home screen status is `unsupported`, `unknown`, `added` or `missed`, and the "added" event may not arrive even when the icon is there.
With Gem
Everyone in your project gets an invite link, `gem.bot/<name>?i=<code>`, and Telegram's share box with a ready card; the first invite counts. Anyone can post your project to their story from its Mini App with "Share to your story" (only Premium users' stories get the link). Gem doesn't add home screen icons.
Sources
- https://core.telegram.org/bots/webapps#initializing-mini-apps
- https://core.telegram.org/bots/api#savepreparedinlinemessage
- https://core.telegram.org/api/links#share-links