Guides

Editing Inline MessagesBOT-ONLY

Bot Walkthrough 18 of 18

Bots can edit inline messages after a user selects an inline query result or interacts with an inline keyboard.

Editing the Text

In a chosenInlineResult or callbackQuery handler, use the context shortcut for editInlineMessageText.

client.on("chosenInlineResult", async (ctx) => {
  await ctx.editInlineMessageText("Updated content.");
});

Editing the Caption

Use the context shortcut for editInlineMessageCaption to update the caption.

client.on("chosenInlineResult", async (ctx) => {
  await ctx.editInlineMessageCaption({ caption: "New caption." });
});

Editing the Reply Markup

Use the context shortcut for editInlineMessageReplyMarkup to change the inline keyboard.

client.callbackQuery("refresh", async (ctx) => {
  await ctx.editInlineMessageReplyMarkup({
    replyMarkup: [[{ text: "Refreshed", callbackData: "done" }]],
  });
  await ctx.answerCallbackQuery();
});