Hey everyone! I’m working on a Telegram bot and I’m trying to figure out something. You know how when you’re chatting with someone on Telegram, you can see when they were last active? Even if you haven’t talked to them in a while, it shows their ‘last seen’ status.
I was wondering if there’s a way to get this info through the bot API. I’ve been looking through the docs but I can’t seem to find anything about it. Has anyone managed to do this before? Is it even possible?
It would be super helpful for my project if I could grab this data. Any ideas or suggestions would be awesome! Thanks in advance for any help you can give me!
Unfortunately, accessing a user’s last activity timestamp through the Telegram Bot API isn’t possible due to privacy concerns. Telegram deliberately restricts this information to protect user privacy. Even if you could see it in the app, bots don’t have the same level of access.
Instead, you might consider alternatives like tracking when users last interacted with your bot or using presence notifications in groups (if applicable). These methods won’t give you the exact ‘last seen’ time, but they could provide useful activity data for your project within the bounds of what’s allowed by the API.
As someone who’s worked extensively with Telegram bots, I can confirm that fetching a user’s last activity timestamp isn’t possible through the Bot API. It’s a deliberate limitation to protect user privacy.
However, there’s a workaround I’ve used in my projects. You can implement a system where your bot records the timestamp of each interaction with a user. This won’t give you the exact ‘last seen’ time, but it will provide a ‘last interacted with bot’ timestamp.
To do this, you’ll need to set up a database to store user IDs and their last interaction time. Update this timestamp every time a user sends a message to your bot or interacts with it in any way. It’s not perfect, but it’s the closest you can get within Telegram’s privacy constraints.
Remember, though, that this method only tracks activity related to your bot, not the user’s overall Telegram activity.
yeah, i’ve been there too. telegram’s pretty tight on privacy stuff. bots can’t get that ‘last seen’ info, even if we can see it ourselves. kinda frustrating when you’re building something cool. maybe try tracking when users last used your bot instead? not perfect, but might help a bit.