'Retrieve all chat ids using Telegram bot

the main question is how do I get the chat ids for all the conversations ever held with the bot?

Imagine that during the execution of the bot there is a conversation with the user A.

Now I stop the bot process and start it again.

How do I get the chat id of that past chat with the user A?

I understand you get the chat id when the user sends you a message, and you use that id to reply, but what if user A no longer sends messages to the bot during the current execution? how to get the past conversation id?

Is the only one option to store the ids and retrieve them when the second execution starts?

UPDATE:

Looks like the current solution is to store the chat id somewhere safe, as answered by @Tick Tock.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source