I created a button in my telegram bot named "contact us". How can I get the member's message after pressing "contact us" button ?
Asked
Active
Viewed 1,097 times
1 Answers
0
Every message that user type and sends, your bot receives it.
But if your question is how your bot can recognize that user press specific key "contact us
", answer is this: When someone touch that button, its caption (text
) field will send automatically to your bot e.g. "contact us
" string will send automatically to your bot.

Seyfi
- 1,832
- 1
- 20
- 35
-
Thanks, but for example one member press "contact us" and then write "Thanks for bot". I want to have this . I cannot use if($text==="Thanks for bot") – amin roshani Aug 21 '16 at 12:48
-
Also i known that first use this: if($text==='contact us'){
}. But in situation, user's text is "contact us" !!! – amin roshani Aug 21 '16 at 12:56 -
@aminroshani I couldn't understand your question very well but keep in mind: 1)KeyboardMarkup does have only text(one text) and when you press it, then it send this text. 2) I think your issue is this: when you send keyboard, scripts end and quit. when user press that key or do something else actually telegram runs your script again from start whith user's given data. – Seyfi Aug 21 '16 at 16:02
-
Thank you. When user send keyboard, scripts end and quit. After send keyboard bot waiting for insert text(e.g. Thanks for bot) from user. Ok, User send Thanks and I have a new data from user, well how I can save this new text? User send every message and I cannot use : if($text==="XXX"){
} – amin roshani Aug 21 '16 at 16:18 -
@aminroshani this is another question but in short and as a key answer, You should create a database(like MySQL) and save for each user something.Each user has a UNIQUE identifier that telegram sends in each message that your bot receives .As you know it is `chat_id`. grab it and save it to your DB. then compare each message that you receive with it and user's previous commands. – Seyfi Aug 21 '16 at 19:21