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

1

11

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.

Seismic answered 4/5, 2023 at 10:43 Comment(0)
S
16

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!

Selby answered 4/5, 2023 at 11:23 Comment(4)
Web App for bot is not such application. It's web application coded in React for example. How can I connect this app with App configuration?Seismic
Yep, you're right, please see my edit. I've created a WebApp to test this and it automatically opens the app!Selby
I banged my head trying to implement this in node. BotFather is the cure to all problems.Deponent
When I open the URL https://t.me/botusername/appname?startapp=command. How can I pass the telegram username of the user? Do I need to update anything in my code to handle the /startapp ?Ledford

© 2022 - 2024 — McMap. All rights reserved.