GramJS

messages.GetBotCallbackAnswer

Press an inline callback button and get a callback answer from the bot

Example

const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.messages.GetBotCallbackAnswer({
      peer: "username",
      msgId: 43,
      game: true,
      data: Buffer.from("arbitrary data here"),
      password: new Api.InputCheckPasswordSRP({
        srpId: BigInt("-4156887774564"),
        a: Buffer.from("arbitrary data here"),
        m1: Buffer.from("arbitrary data here"),
      }),
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.messages.BotCallbackAnswer = await client.invoke(
    new Api.messages.GetBotCallbackAnswer({
      peer: "username",
      msgId: 43,
      game: true,
      data: Buffer.from("arbitrary data here"),
      password: new Api.InputCheckPasswordSRP({
        srpId: BigInt("-4156887774564"),
        a: Buffer.from("arbitrary data here"),
        m1: Buffer.from("arbitrary data here"),
      }),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
gameflags.1?trueWhether this is a "play game" button
peerInputPeerWhere was the inline keyboard sent
msgIdintID of the Message with the inline keyboard
dataflags.0?bytesCallback data
passwordflags.2?InputCheckPasswordSRPFor buttons requiring you to verify your identity with your 2FA password, the SRP payload generated using SRP.

Result

messages.BotCallbackAnswer

Possible errors

CodeTypeDescription
400BOT_RESPONSE_TIMEOUTA timeout occurred while fetching data from the bot
400CHANNEL_INVALIDThe provided channel is invalid
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup
400DATA_INVALIDEncrypted data invalid
400MESSAGE_ID_INVALIDThe provided message id is invalid
400PEER_ID_INVALIDThe provided peer id is invalid
-503TimeoutTimeout while fetching data

Can bots use this method?

No

keyboardButtonCallback

Callback button

Two-factor authentication

How to login to a user's account if they have enabled 2FA, how to change password.