GramJS

messages.SetInlineBotResults

Answer an inline query, for bots only

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.SetInlineBotResults({
      queryId: BigInt("-4156887774564"),
      results: [
        new Api.InputBotInlineResult({
          id: "some string here",
          type: "some string here",
          sendMessage: new Api.InputBotInlineMessageMediaAuto({
            message: "Hello there!",
          }),
          title: "My very normal title",
          description: "some string here",
          url: "some string here",
          thumb: new Api.InputWebDocument({
            url: "some string here",
            size: 43,
            mimeType: "some string here",
            attributes: [
              new Api.DocumentAttributeImageSize({
                w: 43,
                h: 43,
              }),
            ],
          }),
          content: new Api.InputWebDocument({
            url: "some string here",
            size: 43,
            mimeType: "some string here",
            attributes: [
              new Api.DocumentAttributeImageSize({
                w: 43,
                h: 43,
              }),
            ],
          }),
        }),
      ],
      cacheTime: 43,
      gallery: true,
      private: true,
      nextOffset: "some string here",
      switchPm: new Api.InlineBotSwitchPM({
        text: "some string here",
        startParam: "some string 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.Bool = await client.invoke(
    new Api.messages.SetInlineBotResults({
      queryId: BigInt("-4156887774564"),
      results: [
        new Api.InputBotInlineResult({
          id: "some string here",
          type: "some string here",
          sendMessage: new Api.InputBotInlineMessageMediaAuto({
            message: "Hello there!",
          }),
          title: "My very normal title",
          description: "some string here",
          url: "some string here",
          thumb: new Api.InputWebDocument({
            url: "some string here",
            size: 43,
            mimeType: "some string here",
            attributes: [
              new Api.DocumentAttributeImageSize({
                w: 43,
                h: 43,
              }),
            ],
          }),
          content: new Api.InputWebDocument({
            url: "some string here",
            size: 43,
            mimeType: "some string here",
            attributes: [
              new Api.DocumentAttributeImageSize({
                w: 43,
                h: 43,
              }),
            ],
          }),
        }),
      ],
      cacheTime: 43,
      gallery: true,
      private: true,
      nextOffset: "some string here",
      switchPm: new Api.InlineBotSwitchPM({
        text: "some string here",
        startParam: "some string here",
      }),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
galleryflags.0?trueSet this flag if the results are composed of media files
privateflags.1?trueSet this flag if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
queryIdlongUnique identifier for the answered query
resultsVector<InputBotInlineResult>Vector of results for the inline query
cacheTimeintThe maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
nextOffsetflags.2?stringPass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
switchPmflags.3?InlineBotSwitchPMIf passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with a certain parameter.

Result

Bool

Possible errors

CodeTypeDescription
400ARTICLE_TITLE_EMPTYThe title of the article is empty.
400AUDIO_CONTENT_URL_EMPTYThe remote URL specified in the content field is empty.
400AUDIO_TITLE_EMPTYAn empty audio title was provided.
400BUTTON_DATA_INVALIDThe data of one or more of the buttons you provided is invalid.
400BUTTON_TYPE_INVALIDThe type of one or more of the buttons you provided is invalid.
400BUTTON_URL_INVALIDButton URL invalid.
400DOCUMENT_INVALIDThe specified document is invalid.
400FILE_CONTENT_TYPE_INVALIDFile content-type is invalid.
400FILE_TITLE_EMPTYAn empty file title was specified.
400GIF_CONTENT_TYPE_INVALIDGIF content-type invalid.
400MESSAGE_EMPTYThe provided message is empty.
400MESSAGE_TOO_LONGThe provided message is too long.
400NEXT_OFFSET_INVALIDThe specified offset is longer than 64 bytes.
400PHOTO_CONTENT_TYPE_INVALIDPhoto mime-type invalid.
400PHOTO_CONTENT_URL_EMPTYPhoto URL invalid.
400PHOTO_INVALIDPhoto invalid.
400PHOTO_THUMB_URL_EMPTYPhoto thumbnail URL is empty.
400QUERY_ID_INVALIDThe query ID is invalid.
400REPLY_MARKUP_INVALIDThe provided reply markup is invalid.
400RESULTS_TOO_MUCHToo many results were provided.
400RESULT_ID_DUPLICATEYou provided a duplicate result ID.
400RESULT_TYPE_INVALIDResult type invalid.
400SEND_MESSAGE_MEDIA_INVALIDInvalid media provided.
400SEND_MESSAGE_TYPE_INVALIDThe message type is invalid.
400START_PARAM_INVALIDStart parameter invalid.
400STICKER_DOCUMENT_INVALIDThe specified sticker document is invalid.
400URL_INVALIDInvalid URL provided.
403USER_BOT_INVALIDThis method can only be called by a bot.
400VIDEO_TITLE_EMPTYThe specified video title is empty.
400WEBDOCUMENT_INVALIDInvalid webdocument URL provided.
400WEBDOCUMENT_MIME_INVALIDInvalid webdocument mime type provided.
400WEBDOCUMENT_SIZE_TOO_BIGWebdocument is too big!
400WEBDOCUMENT_URL_INVALIDThe specified webdocument URL is invalid.

Can bots use this method?

Yes