I need my bot to print a different message than its caption (which shows by telegram client on keyboard button element).
My custom button has this text: "Where am I?"
and when I click on it, it prints on the screen "Where am I?"
also.
I want the button to print "/location"
.(something different from its text
field)
How can I achieve it? I'm using C#
and Telegram Bot API
EDIT:
What I want:
/age
[as his typed message] but NOT send show my age
(which is that button text
field )So: I want a button with a text
. when the user clicks the button I want the message sent to be different from that text
.
Have you looked at InlineKeyboardMarkup instead of ReplyKeyboardMarkup
? It solves your problem.
UPD
Basic usage
public static InlineKeyboardMarkup TestInlineKeyboard { get; } = new InlineKeyboardMarkup
{
InlineKeyboard = new []{new[] {new InlineKeyboardButton("Text1","Data1"), new InlineKeyboardButton("text1","data2")} }
};
where "Text1"
and "text1"
are captions of the inline buttons, "Data1"
and "data2"
is CallbackQuery
text, which your bot will receive when user clicks inline button.
Note, that bot sends not any message to user when he clicks inline button. If you need to send any message at that moment - you can do that programmatically.
There is a boolean field for location, did you set it to true? https://core.telegram.org/bots/api#keyboardbutton
Update: hen you are sending a reply to the user, you are also sending a ReplyKeyboardMarkup. ReplyKeyboardMarkup has a field called keyboard which is Array of Array of KeyboardButton. on each KeyboardButton you have a bool for location that you need to set to true if you want that button to send the location
Update 2
it is not possible to have a message different than your text. text- String->Text of the button. If none of the optional fields are used, it will be sent to the bot as a message when the button is pressed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With