Answer the question
In order to leave comments, you need to log in
How to make a Telegram bot state machine to receive answers to several questions in turn?
Please tell me how to make a state machine to receive responses from users (you need to take the first name, last name and age as an example), as I understand it, you need to use a database and wiretapping templates, how can this be connected for better work?
Answer the question
In order to leave comments, you need to log in
Recently I made a Telegram bot on Google Spreadsheet and Google Apps Script. You can store key-value data there .
When a message arrives, the id of the user who wrote it is known. Based on this id, a prefix for the keys is made, for example, "TG_12345" where 12345 is the user's id.
Possible dialogs are described in the type dictionary
{ "новый пользователь": [ // название диалога
{"propmt": "Введите ваше имя"}, // первый вопрос
{"propmt": "Введите email"}, // второй
{"propmt": "ник в телеграме"}, // третий
],
"ещё какой-то диалог":[/* вопросы */]
}
TG_12345_DIALOG: "новый пользователь" // из словаря диалогов
TG_12345_STEP: 2 // текущий шаг, ожидаемый ответ
TG_12345_REPLY_0: "Иван Петров" // полученные ответы
TG_12345_REPLY_1: "[email protected]"
I recommend looking at books or articles on the subject of "automatic programming".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question