I
I
Ivan Drozhzhin2017-09-18 22:43:56
JavaScript
Ivan Drozhzhin, 2017-09-18 22:43:56

How to create dialogue branches for a bot in telegram?

I am writing a bot on node telegram bor api
Due to my little experience, I can’t find it in the documentation or figure out on my own how to make dialogue branches.
Those. I want to create a /dialog command after which the bot asks a question, for example, "What is the weather like today?".
Next, the user must write something like "Sunny" or "Cloudy" and the bot will respond to this message, for example, with the message "It will get better soon", etc.
BUT, at the same time, if you write "cloudy" without entering the "dialogue" with the bot using the /dialog command, the bot would not react the same way ... i.e. handler on text.toLowerCase() == 'cloudy' no hang up.
You need to create a kind of form, with specific answers to it, and so that these answers are not processed without a form.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Weridy, 2017-09-18
@RotarYMonkeY

You need to keep the "state" somewhere, or if it's clearer, the point of conversation between God and the user. For example, you create several such "paths" along which the user must walk. And then you save, for example, in the database the "position" of the user on the path, so the bot will know what to put next on the user after his command. Or use the next step function , in python I know exactly what it is. Such a thing (most often a function) that the bot will use to process the next message. So you can build chains of sequences, clinging one more step at the next step, and so on until old age.

N
nllm, 2017-09-21
@nllm

There were many similar questions:
State machine, how to implement with a for loop when using the telegram api?
How to write a state machine (api telegram)?
What is the standard bot algorithm?
How to make sure that the bot does not lose the “thread of the conversation”?
How to carry out some kind of session with a user when using a Telegram bot?
etc.
States are not the job of the platform api. This is a task that must be solved when creating a bot. Therefore, they did not find anything in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question