How to fetch Telegram user data through Bot API integration

What I’m trying to do

I’m building a web-based game using Unity WebGL that runs inside Telegram. I need to get the user’s profile details when they start playing the game through my Telegram bot.

Current setup

I already created a bot through BotFather and connected it to my web game. The bot and web app are working fine.

What I tried

I used the getUpdates method with offset parameters to try getting user profile data. But this approach only gives me chat-level information instead of the specific user’s profile details that I need for my game.

The problem

I can’t figure out the right way to access individual user profile information through the Bot API. The documentation shows different methods but I’m not sure which one works for getting user data in a web app context.

The getUpdates method won’t give you what you need for a WebGL game integration. Since you’re running inside Telegram’s web app environment, you should be using Telegram’s Web Apps API instead of trying to pull user data through the Bot API directly. When a user opens your game through the bot, Telegram automatically passes the user data through the window.Telegram.WebApp.initDataUnsafe object or the more secure window.Telegram.WebApp.initData string. This includes the user’s ID, username, first name, and other profile information without requiring additional API calls. You’ll need to parse this data on your Unity WebGL side when the game initializes. The Bot API methods like getChat or getUserProfilePhotos require you to already know the user ID, which you can get from the Web Apps data I mentioned above.

honestly sounds like you’re overcomplicating this. telegram webapps automatically inject user data when someone opens your game thru the bot - just check window.Telegram.WebApp.initDataUnsafe in your unity webgl build. no need for getUpdates or polling, that stuffs for message bots not webapp integrations.

You’re approaching this from the wrong angle with getUpdates. That method is designed for polling bot messages, not extracting user profile data for web applications. What you actually need is to leverage the Telegram Mini Apps framework since you’re working with WebGL inside Telegram. When users launch your game through the bot, Telegram provides user information directly through the JavaScript bridge without requiring separate API calls. Check for the Telegram.WebApp.initData parameter which contains signed user data including user ID, username, and basic profile info. You can then validate this data server-side using your bot token to ensure authenticity. I’ve implemented similar functionality for a WebGL project and found this approach much more reliable than trying to correlate bot API calls with web sessions. The user data flows naturally through the Mini App context rather than requiring complex API integrations.