E
E
Egor Davydov2019-02-13 11:31:15
PHP
Egor Davydov, 2019-02-13 11:31:15

What is the best way to organize a Telegram bot with multiple screens?

Greetings!
The task is this - we have several telegram bot screens, between which we need to move. For example, let's take the following structure: On the "Payment History"
Главная -> Баланс -> История платежей.
screen , we can enter a date in text and the bot should show payments for this date. The bot, having received a message, must first understand that this is a message from the "Payment History" screen , and then parse the received text for the correct date. Now the question is how to organize it all? So far, the only option that is in my head is to store some kind of Step of the user. Like a table in the database, where there is a UserID and Step, in Step we store the current user page, respectively (the "Balance" page, for example)


And when we enter the date, we take this Step, we see that the user is on the "Payment History" page and parse the text accordingly. Either the user is on another page, and there, respectively, other actions.
But somehow it all looks like crap, it is inconveniently stored, unreliable, it breaks easily (if the user does a simple manipulation like restarting the bot)
Does anyone have a solution?
PS: Yes, the interest is in the algorithm itself, not in the implementation. So you can give examples even in Java, but it’s better not to)
UPD: Unfortunately, I didn’t find any convenient solutions. In my project, I settled on the only solution described above - to store user_step in the database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iBird Rose, 2019-02-13
@iiiBird

Alternatively, you can edit the command itself. I don't know how the cart's api works, but for example:
1) A person wrote the date while on the "Payment History" page
2) We parse the text and form something like a url for ourselves. And we already write the sparse text itself in the form: '/История платежей?date="дата, которую ввел юзер"'
3) Then we send this command further and process it according to all the canons.

D
Danil K., 2019-02-17
@Danya_Violet

You can use Inline Keyboard to create a menu
GIF example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question