I’m working with the Telegram Bot API and I need to figure out if users have deleted their chat with my bot. Right now when someone removes the conversation from their chat list, my bot keeps trying to send messages to them and I don’t get any error or notification about it.
I’ve been testing this behavior and noticed that even after a user deletes the chat, the bot continues sending messages without any indication that the chat no longer exists on the user’s end. This seems wasteful and I want to clean up my user database accordingly.
Does the Telegram Bot API provide any method or webhook event that can tell me when a user has deleted their chat with my bot? I need to detect this so I can stop sending messages to users who are no longer reachable.
Unfortunately, the Bot API doesn’t expose webhook events for chat deletions. I’ve had decent luck with a heartbeat system - send silent messages or use getChat calls periodically to check if the chat’s still accessible. When these consistently fail, you know the chat’s gone. You can also track message delivery - if you’re sending messages but getting zero user activity or read receipts for weeks, the chat’s probably deleted. I’d also set up exponential backoff for inactive users. Cuts down on pointless API calls while still letting you reach users who come back later.
Telegram doesn’t provide a method to know when users delete chats with your bot. Although the chat ID remains active, you may notice that messages continue to send without errors. From my experience, observing user engagement patterns can help. If a user remains inactive for an extended period, it might indicate that they have deleted the chat. I implemented a system that marks users as inactive after 30 days of inactivity, which allows me to adjust my messaging strategy. Keeping an eye on error responses can be helpful, but they often indicate that the user has blocked the bot rather than deleted the chat. Ultimately, creating a monitoring system based on user behavior is essential since the API does not provide direct notifications.
yeah, there’s really no way to know if someone deleted the chat. i just look for messages that bounce back after a few tries and then mark em inactive. not the best solution, but it helps to keep things organized.