skip to Main Content

I have a telegram bot that sends a message to a channel. I want to implement the button attached to this post (inline keyboard button), but I also want to see the comment button. When you add an inline keyboard, it disappears.

Comments button:

Example #1

Inline Keyboard Button (the text doesn’t matter):

Example #2

Code Example without keyboard (Golang):

message := tgbotapi.NewPhotoUpload(channel.ID, tgbotapi.FileBytes{
    Name:  "image-name",
    Bytes: image,
})
message.Caption = "This is the caption"
message.ParseMode = "HTML"
response, err := bot.Send(message)
if err != nil {
    fmt.Println(err)
}

Code Example with keyboard (Golang):

var keyboard = tgbotapi.NewInlineKeyboardMarkup(
    tgbotapi.NewInlineKeyboardRow(
        tgbotapi.NewInlineKeyboardButtonData("Test", "test"),
    ),
)
message := tgbotapi.NewPhotoUpload(channel.ID, tgbotapi.FileBytes{
    Name:  "image-name",
    Bytes: image,
})
message.Caption = "This is the caption"
message.ParseMode = "HTML"
message.ReplyMarkup = keyboard
response, err := bot.Send(message)
if err != nil {
    fmt.Println(err)
}

Is there any way to use these feautures together?

3

Answers


  1. You must create an inline URL button with a link, e.g.,

    https://t.me/c/<groupId>/<groupMessageId + 1000000>?thread=<groupMessageId>
    

    where groupId is the id of your group for comments, and groupMessageId is the id of message of your post in group for comments.

    Login or Signup to reply.
  2. I found a simpler link for this.

    https://t.me/<channelName>/<originalMessageId>?comment=1
    

    where channelName – is username of your channel, originalMessageId is the id of the original message (not message id in the group for comments)

    update It seems this is not working with messages with the inline keyboard (only with native comment button).

    Login or Signup to reply.
  3. You must create an inline URL button with a link, e.g.,

    https://t.me/<channelName>/<originalMessageId>?thread=<originalMessageId>

    where channelName – is username of your channel, originalMessageId is the id of the original message (not message id in the group for comments)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search