Pier Giorgio Misley Pier Giorgio Misley - 22 days ago 21
C# Question

How to make Keyboard Button message text different from its caption in Telegram bot API using C#

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:


  • When the user clicks this button, telegram client send a messages with
    /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
.

Answer

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

Comments