herokupython-telegram-botheroku-redis

Using database for python telegram bot


I'm creating a bot using python-telegram-bot. I'm using a third party application in the bot and user have to login into that app to further use the bot commands, I've hosted the bot on heroku.

Now the problem is, my heroku application sleeps after 30 minutes of inactivity and because of that user loses the access tokens and have to connect again to the application.

I was thinking to store the access tokens within a database, and I found that heroku has 3 database options. My preference is redis but I want to know will the database be available even during the sleep or will the database get refreshed?

Also if someone has a better solution that is more than welcome!


Solution

  • Just an update, I was able to solve this problem using Redis. Answering to the question, the database does not get refreshed even when the dynos are sleeping. Also, it was very easy to integrate Heroku Redis with python.