Search code examples
web-applicationstelegram

How can I get the 'appname' to build t.me URL for launching Telegram Web App for Bots


On the documentation page of Telegram's Web Apps we can read this:

Direct Link Web Apps

You can use direct links to open a Web App directly in the current chat. If a non-empty startapp parameter is included in the link, it will be passed to the Web App in the start_param field and in the GET parameter tgWebAppStartParam.

In this mode, Web Apps can use the chat_type and chat_instance parameters to keep track of the current chat context. This introduces support for concurrent and shared usage by multiple chat members – to create live whiteboards, group orders, multiplayer games and similar apps.

Web Apps opened from a direct link have no access to the chat – they can't read messages or send new ones on behalf of the user. To send messages, the user must be redirected to inline mode and actively pick a result.

Examples
  • https://t.me/botusername/appname
  • https://t.me/botusername/appname?startapp=command

So, where we can get the appname? Does anybody can explain? Thanks.


Solution

  • If you want to create a t.me link to automatically open the WebApp, you'll need to register the app with the @BotFather:

    1. Use the /newapp command
    2. Fill in all the requested data, the username of the bot it's linked to, a title, description, photo and demo GIF
    3. Eventually, BotFather will ask for the short name:

      Good! Now please choose a short name for your web app: 3-30 characters, a-zA-Z0-9_. This short name will be used in URLs like t.me/some_bot/myapp and serve as a unique identifier for your web app.

    4. After passing the short name, BotFather will send you an example link to open the WebApp:

      You can now use testapp as the short_name parameter value in Bot API. Your web app link is t.me/some_bot/testapp. Open it to start developing your web app!