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
Name | Type | Description |
---|---|---|
flags | # | Flags, see TL conditional fields |
game | flags.1?true | Whether this is a "play game" button |
peer | InputPeer | Where was the inline keyboard sent |
msgId | int | ID of the Message with the inline keyboard |
data | flags.0?bytes | Callback data |
password | flags.2?InputCheckPasswordSRP | For buttons requiring you to verify your identity with your 2FA password, the SRP payload generated using SRP. |
Result
Possible errors
Code | Type | Description |
---|---|---|
400 | BOT_RESPONSE_TIMEOUT | A timeout occurred while fetching data from the bot. |
400 | CHANNEL_INVALID | The provided channel is invalid. |
400 | CHANNEL_PRIVATE | You haven't joined this channel/supergroup. |
400 | DATA_INVALID | Encrypted data invalid. |
400 | MESSAGE_ID_INVALID | The provided message id is invalid. |
400 | PEER_ID_INVALID | The provided peer id is invalid. |
-503 | Timeout | Timeout while fetching data. |
Can bots use this method?
No
Related pages
keyboardButtonCallback
Callback button
Two-factor authentication
How to login to a user's account if they have enabled 2FA, how to change password.