Answer the question
In order to leave comments, you need to log in
How are multi-level VKontakte bots made?
The structure of the simplest bot looks like this:
1) Received a message
2) Processed it
3) Answered
But how are multilevel bots made?
Rough example: we want to get from the user his name and age.
P - user, B - bot
P: Enter personal data
B: Enter your age
P: 25
B: Enter your name
P: Ivan
B: Ivan - 25 years old. Is everything right?
P: Confirm
In this example, the commands to get the age and name are processed only after the user wants to enter data about himself. That is, the commands: "get age" and "get name" are subcommands of "get user data".
So that by simply entering "25" or "John" nothing happens. In other words, so that the bot understands that data will be collected from the user now.
Answer the question
In order to leave comments, you need to log in
Finite State Machine (FSM) - finite state machine
Example here
https://mastergroosha.github.io/telegram-tutorial/...
So far, I see only such a solution:
Store in the user database a unique id of the last command entered and each time check which command was the last command for the user and build a procedure from this.
I am sure that there is a simpler and more competent option.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question