I am working on telegram bot where i want to store and retrieve some variables in user's phone memory similar to shared preferences in android. I am using nodejs language to create telegram bot. Kindly help me how to implement that.
Thanks
@IamDixit impossible. Bots don't have access to users' devices. Store that data on your server, preferably in some database.
Thanks for quick reply.
Is there any way to create different session for multiple user using bot application. And those variable become different for different users?
I feel storing and retrieving variable into database might take time. Is there any other way to do without using any database, liking storing in cache or something?
@IamDixit > Is there any way to create different session for multiple user using bot application
Yes. The easiest way is to use user id.
I feel storing and retrieving variable into database might take time.
You don't need to worry about it too much when you're starting, everything is fast for small n.
And databases are optimized to be fast.
If you're still worried: you mentioned storing in cache... you could use Redis. It's fast enough to be used as a cache, and it can be succesfully used as database as well (I use it that way for 2 small bots).
At least, if your data is simple and fits well into Redis's types.
I know how to get userid. But i dont know how to create session using that. Can you please elaborate how to make session using userid. Thanks
For Information : I have data of 150 users, I am using postgres database to store them. Will i need Redis in searching ?
@IamDixit ugh... just use user id as key / part of the key / field, depending on db of your choice.
And I don't think that 150 users is that much, postgres should do just fine by itself.
Don't optimize until you know you need it.
Thank you so much. Your guidance is very helpful ...
Just last thing: Telegram bot has inline keyboard, does it support dropdown menu? I searched about it but couldn't get any result.
@IamDixit no, it doesn't.
Thanks