When coding telegram bots, one of the things you will find is that each HTTP query that the system does to your code is independent and sessionless. The Telegram API does not provide a way to remember things; it is up to you to do that.
Why remember? Useful bots are not those where you answer one question and they give you an answer, and then you ask the same question and they give the same answer. Bots have to evolve and remember your last actions; you may want to have a bot that chats with you, it needs to remember your name and so on.
Fortunately for us, PHP has sessions, an easy way to have a memory of what happens. PHP sessions out of the box won't work with Telegram bot; when a browser interacts with a PHP script that uses sessions, the browser uses a cookie to name the session and PHP automatically gets it. In this case, you are attending a headless client that doesn't support the cookies. Here is what I did.
This article assumes knowledge of the Longman PHP Telegram Bot library. Which in my opinion is the best PHP library to write Telegram bots. Also note that this is a short-term memory solution, it is not meant to be long-term.
Lately, I have discovered how powerful is Telegram comparing to other instant messaging platforms. One of the best features it has is the ability of customized bots. Bots can do a lot of things, from giving you hidden account information, weather information, currency exchange information to some more complex things such as e-commerce (you can order a pizza!), specific application interaction and more.
I will be putting here the bots I have been coding with a summary of what they do and any other information.
So, after a while o writing few Telegram bots, I realized that multiple language support is always appreciated if the public doesn't speak the original language. To work around this, I got inspired by the Laravel approach, a big associative array.
The code is published at https://github.com/daniel-lucio/multilingual-support after you download you have to create the language files, for example, es.php, en.php, fr.php and so on. The following example is just for the /start command utilizing the Longman PHP library.