9

I know how to use telegram commands, and know how to read what command has been executed. What I would like to do is something like this:

User: /send_address
Bot: Hello, please type your address..
User: my address...

so far, i can read the /send_address command and reply with "hello,...." and obviously I can also read the answer of the user, just like I have read the /send_address command. Question is, how do i know if the answer he sends is in response to my "hello, please type your address.." request, or if he sent it just because? I could have 100 users chatting with the bot, would i have to store a variable for each user remembering that he sent the /send_address cmd?

1 Answer 1

12

As I known, telegram has no way to save state for user. I use a table in database for saving comands of user.

How it works:

  1. User say /command
  2. Store /command for User.
  3. User say "something" we try to get data from database for this user. If we find out that previos message is command /command than do some action and save nowly added data (if you have multiple steps for some command)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.