Objective
I’m building a Unity WebGL game for Telegram and need to access user profile data when players join through the Bot API.
Setup
I’ve created a bot through BotFather and connected a web application to my browser-based game.
Issue
I tried using the getUpdates method with offset parameters to fetch user profiles, but this approach only returned chat user information instead of individual user profile data.
Question
What’s the correct way to retrieve specific user profile information through the Telegram Bot API? Are there alternative methods or specific endpoints I should be using instead?
Yeah, getUpdates won’t work for profile queries - it’s just for incoming messages. You’ll want to use getChat with the user ID instead. This works if the user has messaged your bot before or if you’re calling it from within a Telegram Web App.
For Unity WebGL, I’d recommend using the Telegram Web Apps API alongside the Bot API. The WebApp.initDataUnsafe object has user data that’s ready to go without extra API calls. I’ve found this way more reliable than trying to get profile data through bot methods alone.
You’re mixing up different API purposes here. The Bot API’s getUpdates is for receiving messages, not fetching user profiles directly. What you need depends on your specific use case. If you’re working in a Telegram Web App context (sounds like you are), use the Telegram.WebApp.initData parameter that gets passed when users access your game. This has the user info you need without extra API calls. When you do need the Bot API, getChat works but requires the user to interact with your bot first. There’s also getChatMember if you need to check user status in a specific chat. One heads up for Unity WebGL - these calls are async, so handle the response properly in your game’s update loop to avoid blocking the main thread.
once u got the user_id from messages, try using getUserProfilePhotos method. make sure your bot permissions in BotFather are set correctly - that’s often the culprit. had a similar problem in my WebGL game last month.