I’m building a Telegram bot that needs to send scheduled messages to users at specific times during their day. The problem is that users are located in different timezones around the world.
The Message object in Telegram API only provides timestamps in UNIX format, which doesn’t help me figure out what timezone each user is in. I want to avoid making users manually tell the bot their timezone since that creates extra friction.
Is there any built-in way to automatically determine a user’s timezone through the Telegram Bot API? Or are there any workarounds that don’t require users to input their location data manually?
Any suggestions would be helpful since I’m stuck on this timezone detection issue.
Telegram Bot API doesn’t give you timezone data directly. But here’s what worked for me: track when users are most active with your bot and match that against normal waking hours. Takes time to build up the data, but it’s completely hands-off for users. You could also check their language settings as a rough guess, though that’s hit-or-miss since people don’t always use their local language. I used the activity tracking method for a scheduling bot and it worked pretty well. Just needed several days of data before it got reliable.
u cant get timezone directly from telegram’s api. one way to do it is by asking users for their city when they start using the bot. just frame it casually like ‘Whats your city?’ to keep it friendly. then use that info to figure out their timezone.
Nope, Telegram’s API doesn’t give you timezone info directly. But here’s a workaround that actually works pretty well: track when users message your bot over several days. Most people use bots during their daytime hours, so you can figure out their timezone by spotting when they’re active versus quiet. It takes patience since you need enough data points, but it doesn’t require bugging users for their location. I’d suggest starting with UTC timestamps and then adjusting as you collect more interaction patterns from each user.