telebot-ts API Documentation - v1.0.0
    Preparing search index...

    Class Bot

    Primary HTTP Client for executing Telegram Bot API requests.

    Inherits all domain method mixins with full autocomplete and type safety.

    const bot = new Bot(process.env.BOT_TOKEN!, {
    retry: {
    maxRetryAttempts: 4,
    minDelaySeconds: 1,
    },
    });
    await bot.sendMessage({ chat_id: 123456, text: "Hello world!" });

    Hierarchy

    • BusinessAndEcosystemMethods
      • Bot
    Index
    addStickerToSet answerCallbackQuery answerChatJoinRequestQuery answerGuestQuery answerInlineQuery answerPreCheckoutQuery answerShippingQuery answerWebAppQuery approveChatJoinRequest approveSuggestedPost banChatMember banChatSenderChat close closeForumTopic closeGeneralForumTopic configureRetry convertGiftToStars copyMessage copyMessages createChatInviteLink createChatSubscriptionInviteLink createForumTopic createInvoiceLink createNewStickerSet declineChatJoinRequest declineSuggestedPost deleteAllMessageReactions deleteBusinessMessages deleteChatPhoto deleteChatStickerSet deleteEphemeralMessage deleteForumTopic deleteMessage deleteMessageReaction deleteMessages deleteMyCommands deleteStickerFromSet deleteStickerSet deleteStory deleteWebhook doApiRequest editChatInviteLink editChatSubscriptionInviteLink editEphemeralMessageCaption editEphemeralMessageMedia editEphemeralMessageReplyMarkup editEphemeralMessageText editForumTopic editGeneralForumTopic editMessageCaption editMessageChecklist editMessageLiveLocation editMessageMedia editMessageReplyMarkup editMessageText editStory editUserStarSubscription exportChatInviteLink forwardMessage forwardMessages getAvailableGifts getBusinessAccountGifts getBusinessAccountStarBalance getBusinessConnection getChat getChatAdministrators getChatGifts getChatMember getChatMemberCount getChatMenuButton getCustomEmojiStickers getFile getForumTopicIconStickers getGameHighScores getManagedBotAccessSettings getManagedBotToken getMe getMyCommands getMyDefaultAdministratorRights getMyDescription getMyName getMyShortDescription getMyStarBalance getStarTransactions getStickerSet getUpdates getUserChatBoosts getUserGifts getUserPersonalChatMessages getUserProfileAudios getUserProfilePhotos getWebhookInfo giftPremiumSubscription hideGeneralForumTopic initialize leaveChat logOut onApiError pinChatMessage postStory promoteChatMember readBusinessMessage refundStarPayment removeBusinessAccountProfilePhoto removeChatVerification removeHooksByTag removeMyProfilePhoto removeUserVerification reopenForumTopic reopenGeneralForumTopic replaceManagedBotToken replaceStickerInSet repostStory request restrictChatMember revokeChatInviteLink savePreparedInlineMessage savePreparedKeyboardButton sendAnimation sendAudio sendChatAction sendChatJoinRequestWebApp sendChecklist sendContact sendDice sendDocument sendGame sendGift sendInvoice sendLivePhoto sendLocation sendMediaGroup sendMessage sendMessageDraft sendPaidMedia sendPhoto sendPoll sendRichMessage sendRichMessageDraft sendSticker sendVenue sendVideo sendVideoNote sendVoice setBusinessAccountBio setBusinessAccountGiftSettings setBusinessAccountName setBusinessAccountProfilePhoto setBusinessAccountUsername setChatAdministratorCustomTitle setChatDescription setChatMemberTag setChatMenuButton setChatPermissions setChatPhoto setChatStickerSet setChatTitle setCustomEmojiStickerSetThumbnail setGameScore setManagedBotAccessSettings setMessageReaction setMyCommands setMyDefaultAdministratorRights setMyDescription setMyName setMyProfilePhoto setMyShortDescription setPassportDataErrors setStickerEmojiList setStickerKeywords setStickerMaskPosition setStickerPositionInSet setStickerSetThumbnail setStickerSetTitle setUserEmojiStatus setWebhook shutdown sleep stopMessageLiveLocation stopPoll transferBusinessAccountStars transferGift transformRequest transformResponse unbanChatMember unbanChatSenderChat unhideGeneralForumTopic unpinAllChatMessages unpinAllForumTopicMessages unpinAllGeneralForumTopicMessages unpinChatMessage upgradeGift uploadStickerFile verifyChat verifyUser
    • Constructs a new Bot client instance.

      Parameters

      • token: string

        Secret token provided by BotFather.

      • options: BotOptions = {}

        Custom HTTP, retry, and endpoint options.

      Returns Bot

    _fetch: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    Internal fetch adapter instance used for HTTP dispatch.

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>

    apiRoot: string

    Base endpoint URL of the Telegram Bot API server.

    baseDelayMs?: number

    Optional base delay in milliseconds used for retry calculations.

    options: BotOptions

    Client configuration options.

    requestTimeoutMs: number

    Default per-request abort timeout in milliseconds.

    token: string

    Secret Telegram Bot API token received from BotFather.

    • Sends answers to callback queries sent from inline keyboards.

      Parameters

      Returns Promise<boolean>

      true on success.

      TelegramApiError When answering callback query fails.

      await bot.answerCallbackQuery({
      callback_query_id: query.id,
      text: "Button clicked!",
      show_alert: false,
      });
    • Answers a guest query in a mini app.

      Parameters

      • guestQueryId: string

        Unique identifier of the query.

      • result: unknown

        Result payload to return.

      Returns Promise<{ inline_message_id?: string }>

      Object with optional inline_message_id.

    • Sends answers to an inline query from users.

      Parameters

      • options: AnswerInlineQueryOptions

        Options including inline_query_id, results array, cache_time, is_personal, next_offset, button.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When answering inline query fails.

      Inline mode must be enabled for your bot in Telegram via BotFather (/setinline).

      await bot.answerInlineQuery({
      inline_query_id: update.inline_query!.id,
      results: [
      {
      type: "article",
      id: "1",
      title: "Result Title",
      input_message_content: { message_text: "Result content" },
      },
      ],
      });
    • Replies to an incoming pre-checkout query to confirm or cancel the order.

      Parameters

      Returns Promise<boolean>

      true on success.

      TelegramApiError When confirming/canceling fails.

      await bot.answerPreCheckoutQuery({
      pre_checkout_query_id: "pcq_123",
      ok: true,
      });
    • Replies to an incoming shipping query.

      Parameters

      Returns Promise<boolean>

      true on success.

      TelegramApiError When replying fails.

      await bot.answerShippingQuery({
      shipping_query_id: "sq_123",
      ok: true,
      shipping_options: [
      { id: "express", title: "Express (1-2 days)", prices: [{ label: "Express", amount: 500 }] },
      ],
      });
    • Sets the result of an interaction with a Web App and sends a corresponding message on behalf of the user to the chat.

      Parameters

      • webAppQueryId: string

        Unique identifier for the query.

      • result: unknown

        An object describing the message to be sent.

      Returns Promise<{ inline_message_id?: string }>

      Object with optional inline_message_id.

      TelegramApiError When answering web app query fails.

    • Approves a chat join request from a user.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • userId: number

        Unique identifier of the target user.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When approval fails.

      await bot.approveChatJoinRequest(chatId, userId);
      
    • Approves a suggested post in a channel.

      Parameters

      • chatId: string | number

        Channel chat identifier.

      • messageId: number

        Identifier of the suggested post message.

      • OptionalsendDate: number

        Point in time (Unix timestamp) when the post will be published; defaults to the current date and time when omitted.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When the request fails.

    • Bans a user in a group, a supergroup or a channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target group or channel.

      • userId: number

        Unique identifier of the target user.

      • OptionaluntilDate: number

        Date when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever.

      • OptionalrevokeMessages: boolean

        Pass true to delete all messages from the chat for the user that is being banned.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When banning fails.

      await bot.banChatMember(chatId, userId, undefined, true);
      
    • Bans a channel in a chat, preventing it from sending messages.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • senderChatId: number

        Unique identifier of the target sender channel.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When banning sender chat fails.

      await bot.banChatSenderChat(chatId, channelId);
      
    • Closes the bot instance before moving it from one local server to another.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When close fails.

    • Closes an open topic in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • messageThreadId: number

        Unique identifier for the target message thread of the forum topic.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When closing topic fails.

      await bot.closeForumTopic(-1001234567890, 42);
      
    • Closes an open 'General' topic in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When closing General topic fails.

      await bot.closeGeneralForumTopic(-1001234567890);
      
    • Dynamically configures or updates the auto-retry and flood control settings.

      Parameters

      • options: Partial<RetryOptions>

        Partial retry options to update.

      Returns this

      This client instance for chaining.

      bot.configureRetry({
      maxRetryAttempts: 5,
      minDelaySeconds: 2,
      });
    • Converts a regular gift owned by a managed business account to Telegram Stars.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • ownedGiftId: string

        Unique identifier of the regular gift to convert.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When the request fails.

    • Copies a message of any kind, sending a new message with the same content without header links.

      Parameters

      • options: {
            allow_paid_broadcast?: boolean;
            caption?: string;
            caption_entities?: MessageEntity[];
            chat_id: string | number;
            direct_messages_topic_id?: number;
            disable_notification?: boolean;
            from_chat_id: string | number;
            message_effect_id?: string;
            message_id: number;
            message_thread_id?: number;
            parse_mode?: ParseMode;
            protect_content?: boolean;
            reply_markup?: ReplyMarkup;
            reply_parameters?: ReplyParameters;
            show_caption_above_media?: boolean;
            suggested_post_parameters?: SuggestedPostParameters;
            video_start_timestamp?: number;
        }

        Copy options including optional custom caption, parse_mode, and reply_markup.

      Returns Promise<{ message_id: number }>

      Object containing the message_id of the copied message.

      TelegramApiError When copying fails.

      const result = await bot.copyMessage({
      chat_id: targetChatId,
      from_chat_id: sourceChatId,
      message_id: 123,
      caption: "Here is your copy!",
      });
    • Copies multiple messages of any kind in batch.

      Parameters

      • options: CopyMessagesOptions

        Batch copy options including chat_id, from_chat_id, and message_ids.

      Returns Promise<MessageId[]>

      Array of MessageId objects containing the identifiers of copied messages.

      TelegramApiError When batch copying fails.

      const copies = await bot.copyMessages({
      chat_id: targetChatId,
      from_chat_id: sourceChatId,
      message_ids: [100, 101],
      remove_caption: true,
      });
      console.log(`Copied ${copies.length} messages`);
    • Creates a topic in a forum supergroup chat.

      Parameters

      • options: {
            chat_id: string | number;
            icon_color?: number;
            icon_custom_emoji_id?: string;
            name: string;
        }

        Options including target chat_id, name, and optional icon_color or icon_custom_emoji_id.

      Returns Promise<ForumTopic>

      The created ForumTopic object on success.

      TelegramApiError When creating topic fails.

      const topic = await bot.createForumTopic({
      chat_id: -1001234567890,
      name: "Announcements",
      icon_color: 0x6FB9F0,
      });
      console.log(`Created thread ID: ${topic.message_thread_id}`);
    • Creates an HTTP link for an invoice that can be shared in messages or buttons.

      Parameters

      Returns Promise<string>

      The created invoice link as a string.

      TelegramApiError When link creation fails.

      const link = await bot.createInvoiceLink({
      title: "Donation",
      description: "Support development",
      payload: "donation_50",
      currency: "XTR",
      prices: [{ label: "Stars", amount: 50 }],
      });
    • Creates a new sticker set owned by a user.

      Parameters

      Returns Promise<boolean>

      true on success.

      TelegramApiError When creation fails.

      await bot.createNewStickerSet({
      user_id: 123456,
      name: "custom_pack_by_bot",
      title: "Custom Pack",
      stickers: [{ sticker: uploadedFileId, emoji_list: ["😀"] }],
      sticker_format: "static",
      });
    • Declines a chat join request from a user.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • userId: number

        Unique identifier of the target user.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When declining fails.

      await bot.declineChatJoinRequest(chatId, userId);
      
    • Declines a suggested post in a channel.

      Parameters

      • chatId: string | number

        Channel chat identifier.

      • messageId: number

        Identifier of the suggested post message.

      • Optionalcomment: string

        Comment for the post author; pass an empty string for no comment.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When the request fails.

    • Removes all reactions on a message (this endpoint takes no message_id).

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      • OptionaluserId: number

        Identifier of the target user, for business connections only.

      • OptionalactorChatId: number

        Unique identifier of the business chat on behalf of which to act.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When clearing reactions fails.

    • Deletes messages on behalf of a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • messageIds: number[]

        List of message identifiers to delete.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting messages fails.

    • Deletes a chat photo.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting chat photo fails.

    • Deletes a group sticker set from a supergroup.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting sticker set fails.

    • Deletes an ephemeral message (Bot API 10.2+).

      Parameters

      • optionsOrChatId: string | number | DeleteEphemeralMessageOptions

        Options object or chat identifier.

      • OptionalreceiverUserId: number

        Receiver user identifier when passing positional arguments.

      • OptionalephemeralMessageId: number

        Ephemeral message identifier when passing positional arguments.

      Returns Promise<boolean>

      true on success.

    • Deletes a forum topic along with all its messages in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • messageThreadId: number

        Unique identifier for the target message thread of the forum topic.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting topic fails.

      await bot.deleteForumTopic(-1001234567890, 42);
      
    • Deletes a message in a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      • messageId: number

        Identifier of the message to delete.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When message cannot be deleted.

      await bot.deleteMessage(chatId, messageId);
      
    • Removes the calling user's or a managed business account's reaction from a message.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      • messageId: number

        Identifier of the target message.

      • OptionaluserId: number

        Identifier of the target user, for business connections only.

      • OptionalactorChatId: number

        Unique identifier of the business chat on behalf of which to act.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When clearing reaction fails.

    • Deletes multiple messages simultaneously in a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      • messageIds: number[]

        Array of 1-100 identifiers of messages to delete.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When messages cannot be deleted.

      await bot.deleteMessages(chatId, [101, 102, 103]);
      
    • Deletes the list of the bot's commands for the given scope and user language.

      Parameters

      • options: { language_code?: string; scope?: BotCommandScope } = {}

        Optional scope and language_code.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting commands fails.

      await bot.deleteMyCommands();
      
    • Deletes a sticker from a set created by the bot.

      Parameters

      • sticker: string

        File identifier of the sticker.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting sticker fails.

    • Deletes a sticker set that was created by the bot.

      Parameters

      • name: string

        Sticker set name.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting set fails.

    • Deletes a story previously posted on behalf of a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • storyId: number

        Identifier of the story to delete.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When deleting story fails.

    • Removes webhook integration, reverting to getUpdates polling.

      Parameters

      • OptionaldropPendingUpdates: boolean

        Pass true to discard all queued undelivered updates.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When removing webhook fails.

      await bot.deleteWebhook(true);
      
    • General-purpose raw API method executor.

      Type Parameters

      • T

        Expected result payload type.

      Parameters

      • method: string

        API method name.

      • payload: Record<string, unknown> = {}

        Request parameters.

      Returns Promise<T>

      Unwrapped API result.

    • Edits the name and icon of a topic in a forum supergroup chat.

      Parameters

      • options: {
            chat_id: string | number;
            icon_custom_emoji_id?: string;
            message_thread_id: number;
            name?: string;
        }

        Options including chat_id, message_thread_id, and updated name or icon_custom_emoji_id.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When editing topic fails.

      await bot.editForumTopic({
      chat_id: -1001234567890,
      message_thread_id: 42,
      name: "Updated Announcements",
      });
    • Edits the name of the 'General' topic in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • name: string

        New name of the topic (1-128 characters).

      Returns Promise<boolean>

      true on success.

      TelegramApiError When editing General topic fails.

      await bot.editGeneralForumTopic(-1001234567890, "General Chat");
      
    • Edits the caption of a media message previously sent by the bot.

      Parameters

      Returns Promise<boolean | Message>

      The edited Message or true if inline message.

      TelegramApiError When editing caption fails.

      await bot.editMessageCaption({
      chat_id: 123456,
      message_id: 789,
      caption: "Updated caption description",
      });
    • Edits the animation, audio, document, photo, or video content of a message.

      Parameters

      Returns Promise<boolean | Message>

      The edited Message or true if inline message.

      TelegramApiError When editing media fails.

      await bot.editMessageMedia({
      chat_id: 123456,
      message_id: 789,
      media: { type: "photo", media: "https://example.com/new_photo.jpg" },
      });
    • Edits the text of a message previously sent by the bot or via inline queries.

      Parameters

      • options: EditMessageTextOptions

        Options including text, chat_id+message_id or inline_message_id, reply_markup, and the optional business_connection_id.

      Returns Promise<boolean | Message>

      The edited Message or true if inline message.

      TelegramApiError When editing text fails.

      await bot.editMessageText({
      chat_id: 123456,
      message_id: 789,
      text: "Updated text content",
      });
    • Edits a story previously posted by the bot on behalf of a business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • storyId: number

        Unique identifier of the story to edit.

      • content: unknown

        New content for the story.

      • options: EditStoryOptions = {}

        Additional edit parameters.

      Returns Promise<Story>

      The edited Story object.

      TelegramApiError When editing story fails.

    • Allows the bot to cancel or re-enable a subscription paid with Telegram Stars for a user.

      Parameters

      • userId: number

        Identifier of the user whose subscription will be edited.

      • telegramPaymentChargeId: string

        Telegram payment identifier for the subscription charge.

      • isCanceled: boolean

        Pass true to cancel the subscription, or false to re-enable.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When updating subscription status fails.

      await bot.editUserStarSubscription(123456, "sub_charge_123", true);
      
    • Generates a new primary invite link for a chat; any previously generated primary link is revoked.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<string>

      The new invite link as a string.

      TelegramApiError When exporting link fails.

      const link = await bot.exportChatInviteLink(chatId);
      console.log(`Primary invite link: ${link}`);
    • Forwards a message of any kind.

      Parameters

      • options: {
            chat_id: string | number;
            direct_messages_topic_id?: number;
            disable_notification?: boolean;
            from_chat_id: string | number;
            message_effect_id?: string;
            message_id: number;
            message_thread_id?: number;
            protect_content?: boolean;
            suggested_post_parameters?: SuggestedPostParameters;
            video_start_timestamp?: number;
        }

        Forward options including chat_id, from_chat_id, and message_id.

      Returns Promise<Message>

      The forwarded Message.

      TelegramApiError When forwarding fails.

      await bot.forwardMessage({
      chat_id: targetChatId,
      from_chat_id: sourceChatId,
      message_id: 123,
      });
    • Forwards multiple messages of any kind in batch.

      Parameters

      Returns Promise<MessageId[]>

      Array of MessageId objects containing the identifiers of forwarded messages.

      TelegramApiError When batch forwarding fails.

      const sent = await bot.forwardMessages({
      chat_id: targetChatId,
      from_chat_id: sourceChatId,
      message_ids: [100, 101],
      });
      console.log(`Forwarded ${sent.length} messages`);
    • Returns the list of gifts that can be sent by the bot to users and channel chats.

      Returns Promise<Gifts>

      A Gifts object containing the available gifts.

      TelegramApiError When retrieving gifts fails.

      const gifts = await bot.getAvailableGifts();
      console.log(`Available gifts count: ${gifts.gifts.length}`);
    • Retrieves the gifts received and owned by a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • options: GetBusinessAccountGiftsOptions = {}

        Optional exclusion, sorting and pagination filters.

      Returns Promise<unknown>

      Owned gifts of the business account.

    • Retrieves the Telegram Star balance of a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      Returns Promise<{ amount: number }>

      Object containing the star amount.

    • Retrieves up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      Returns Promise<ChatFullInfo>

      A ChatFullInfo object.

      TelegramApiError When chat is not found or bot lacks access.

      The docs declare the return type as ChatFullInfo, not Chat. Because ChatFullInfo extends Chat, callers that annotated the result as a Chat keep compiling and additionally gain access to the documented full-info fields (max_reaction_count, parent_chat, accepted_gift_types, rating, community, guard_bot, …).

      const chat = await bot.getChat(chatId);
      console.log(`Chat title: ${chat.title}, max reactions: ${chat.max_reaction_count}`);
    • Retrieves a list of administrators in a chat, which includes the chat creator and all promoted admins.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • options: { return_bots?: boolean } = {}

      Returns Promise<ChatMember[]>

      Array of ChatMember objects.

      TelegramApiError When retrieving administrators fails.

      const admins = await bot.getChatAdministrators(chatId);
      console.log(`Found ${admins.length} administrators`);
    • Retrieves the gifts owned by a chat.

      Parameters

      • chatId: string | number

        Target chat identifier or channel @username.

      • options: GetChatGiftsOptions = {}

        Optional exclusion (including saved/unsaved), sorting and pagination filters.

      Returns Promise<unknown>

      List of chat gifts.

      TelegramApiError When the request fails.

    • Retrieves information about a specific member of a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • userId: number

        Unique identifier of the target user.

      Returns Promise<ChatMember>

      A ChatMember object.

      TelegramApiError When user is not found.

      const member = await bot.getChatMember(chatId, userId);
      console.log(`User status: ${member.status}`);
    • Retrieves the number of members in a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<number>

      Total member count as a number.

      TelegramApiError When retrieving count fails.

      const count = await bot.getChatMemberCount(chatId);
      console.log(`Chat members: ${count}`);
    • Retrieves the current value of the bot's menu button in a private chat, or the default menu button.

      Parameters

      • OptionalchatId: string | number

        Unique identifier for the target private chat. If not specified, default menu button is returned.

      Returns Promise<MenuButton>

      A MenuButton object.

      TelegramApiError When retrieving menu button fails.

      const menu = await bot.getChatMenuButton(123456);
      console.log(menu.type);
    • Retrieves information about custom emoji stickers by their identifiers.

      Parameters

      • customEmojiIds: string[]

        List of custom emoji identifiers (up to 200).

      Returns Promise<Sticker[]>

      Array of Sticker objects.

      TelegramApiError When retrieval fails.

      const emojis = await bot.getCustomEmojiStickers(["5368324170671202286"]);
      
    • Retrieves basic info about a file and prepares it for downloading.

      Parameters

      • fileId: string

        File identifier to get info about.

      Returns Promise<File>

      A File object with file_path.

      TelegramApiError When file is not found or exceeds 20MB bot limit.

      const file = await bot.getFile(photoFileId);
      const downloadUrl = `https://api.telegram.org/file/bot${bot.token}/${file.file_path}`;
    • Retrieves custom emoji stickers that can be used as forum topic icons.

      Returns Promise<unknown[]>

      Array of sticker objects.

    • Retrieves high score tables for a game.

      Parameters

      • userId: number

        Target user identifier.

      • options: { chat_id?: string | number; inline_message_id?: string; message_id?: number } = {}

        Target message coordinates.

      Returns Promise<GameHighScore[]>

      Array of GameHighScore objects.

      TelegramApiError When retrieving scores fails.

    • Retrieves access settings for a managed bot.

      Parameters

      • userId: number

        Unique identifier of the target user that owns the managed bot.

      Returns Promise<unknown>

      Access settings.

    • Retrieves the token of a managed bot.

      Parameters

      • userId: number

        Unique identifier of the target user that owns the managed bot.

      Returns Promise<{ token: string }>

      Object containing the bot token.

    • Basic information about the bot in form of a User object.

      Returns Promise<User>

      The User object representing the bot.

      TelegramApiError When token is invalid or request fails.

      const me = await bot.getMe();
      console.log(`Logged in as @${me.username} (${me.id})`);
    • Retrieves the current list of the bot's commands for the given scope and user language.

      Parameters

      • options: { language_code?: string; scope?: BotCommandScope } = {}

        Optional scope and language_code.

      Returns Promise<BotCommand[]>

      Array of BotCommand objects.

      TelegramApiError When retrieving commands fails.

      const commands = await bot.getMyCommands();
      console.log(commands);
    • Retrieves the current bot description for the given user language.

      Parameters

      • OptionallanguageCode: string

        Two-letter ISO 639-1 language code.

      Returns Promise<BotDescription>

      A BotDescription object.

      TelegramApiError When retrieving description fails.

      const { description } = await bot.getMyDescription("en");
      console.log(description);
    • Retrieves the current bot name for the given user language.

      Parameters

      • OptionallanguageCode: string

        Two-letter ISO 639-1 language code.

      Returns Promise<BotName>

      A BotName object.

      TelegramApiError When retrieving bot name fails.

      const { name } = await bot.getMyName("en");
      console.log(`Bot Name: ${name}`);
    • Retrieves the current bot short description for the given user language.

      Parameters

      • OptionallanguageCode: string

        Two-letter ISO 639-1 language code.

      Returns Promise<BotShortDescription>

      A BotShortDescription object.

      TelegramApiError When retrieving short description fails.

      const { short_description } = await bot.getMyShortDescription("en");
      console.log(short_description);
    • Retrieves the bot's current balance in Telegram Stars.

      Returns Promise<StarAmount>

      A StarAmount object containing amount and optional nanostar_amount.

      TelegramApiError When retrieving balance fails.

      const balance = await bot.getMyStarBalance();
      console.log(`Current Stars: ${balance.amount}`);
    • Retrieves the bot's Telegram Star transactions in chronological order.

      Parameters

      • Optionaloffset: number

        Number of transactions to skip in the response.

      • Optionallimit: number

        The maximum number of transactions to retrieve (1-100).

      Returns Promise<StarTransactions>

      A StarTransactions object.

      TelegramApiError When retrieving transactions fails.

      const txs = await bot.getStarTransactions(0, 20);
      console.log(`Total transactions returned: ${txs.transactions.length}`);
    • Retrieves a sticker set by its short name.

      Parameters

      • name: string

        Short name of the sticker set.

      Returns Promise<StickerSet>

      A StickerSet object.

      TelegramApiError When sticker set is not found.

      const set = await bot.getStickerSet("animals");
      console.log(`Sticker set title: ${set.title}, stickers: ${set.stickers.length}`);
    • Retrieves incoming updates using long polling.

      Parameters

      • options: GetUpdatesOptions = {}

        Polling options such as offset, limit, timeout, and allowed_updates.

      Returns Promise<RawUpdate[]>

      Array of RawUpdate objects.

      TelegramApiError When retrieving updates fails.

      const updates = await bot.getUpdates({ timeout: 10, offset: 0 });
      console.log(`Received ${updates.length} updates`);
    • Retrieves the list of boosts added to a chat by a user.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      • userId: number

        Unique identifier of the target user.

      Returns Promise<UserChatBoosts>

      A UserChatBoosts object containing the list of boosts.

      TelegramApiError When retrieving boosts fails.

      const boosts = await bot.getUserChatBoosts(chatId, 123456);
      console.log(`Total boosts: ${boosts.boosts.length}`);
    • Retrieves the gifts owned and hosted by a user.

      Parameters

      • userId: number

        Target user identifier.

      • options: GetUserGiftsOptions = {}

        Optional exclusion, sorting and pagination filters.

      Returns Promise<unknown>

      List of user gifts.

      TelegramApiError When the request fails.

    • Retrieves messages from a user's personal chat with the bot.

      Parameters

      • userId: number

        Unique identifier of the target user.

      • limit: number

        Maximum number of messages to be returned; 1-100.

      Returns Promise<Message[]>

      Array of Message objects.

      TelegramApiError When retrieving messages fails.

    • Retrieves profile audio files for a user.

      Parameters

      • userId: number

        Target user identifier.

      • Optionaloffset: number

        Query offset.

      • Optionallimit: number

        Maximum items to retrieve.

      Returns Promise<unknown>

      Profile audio objects.

    • Retrieves a list of profile pictures for a user.

      Parameters

      • userId: number

        Unique identifier of the target user.

      • Optionaloffset: number

        Sequential number of first photo to return (default 0).

      • Optionallimit: number

        Limits the number of photos to be retrieved (1-100, default 100).

      Returns Promise<UserProfilePhotos>

      A UserProfilePhotos object.

      TelegramApiError When retrieving photos fails.

      const photos = await bot.getUserProfilePhotos(123456, 0, 1);
      console.log(`User has ${photos.total_count} total photos`);
    • Retrieves current webhook status information.

      Returns Promise<WebhookInfo>

      A WebhookInfo object.

      TelegramApiError When retrieving webhook info fails.

      const info = await bot.getWebhookInfo();
      console.log(`Webhook URL: ${info.url}, Pending updates: ${info.pending_update_count}`);
    • Hides the 'General' topic in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When hiding General topic fails.

      await bot.hideGeneralForumTopic(-1001234567890);
      
    • Initializes client state and verifies credentials via getMe.

      Returns Promise<void>

    • Leaves a group, supergroup or channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When leaving chat fails.

    • Logs out from the cloud Bot API server before launching a local Bot API server.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When logout fails.

    • Registers an observer invoked whenever a Bot API request finally fails.

      Hooks run in registration order right before the TelegramApiError is thrown, after retries are exhausted. Observers cannot alter the error; exceptions inside a hook are swallowed and logged. Useful for alerting and metrics plugins.

      Parameters

      Returns this

      This client instance for chaining.

      bot.onApiError((method, error) => {
      console.error(`${method} failed: ${error.description}`);
      });
    • Pins a message in a group, a supergroup, or a channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • messageId: number

        Identifier of a message to pin.

      • OptionaldisableNotification: boolean

        Pass true if it is not necessary to send a notification to all chat members.

      • OptionalbusinessConnectionId: string

        Unique identifier of the business connection on behalf of which the message will be pinned.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When pinning message fails.

    • Posts a story on behalf of a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • content: unknown

        Content of the story.

      • options: PostStoryOptions

        Additional story options.

      Returns Promise<Story>

      The posted Story object.

      TelegramApiError When posting story fails.

    • Promotes or demotes a user in a supergroup or a channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • userId: number

        Unique identifier of the target user.

      • options: PromoteChatMemberOptions = {}

        Admin rights flags (e.g. can_manage_chat, can_delete_messages, can_invite_users).

      Returns Promise<boolean>

      true on success.

      TelegramApiError When promotion fails.

      await bot.promoteChatMember(chatId, userId, {
      can_delete_messages: true,
      can_invite_users: true,
      });
    • Marks incoming messages in a business account as read.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • chatId: number

        Unique identifier of the chat in which the message was received.

      • messageId: number

        Identifier of the message to mark as read.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When marking message fails.

    • Refunds a successful payment in Telegram Stars.

      Parameters

      • userId: number

        Identifier of the user who made the payment.

      • telegramPaymentChargeId: string

        Telegram payment identifier.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When refund fails.

      await bot.refundStarPayment(123456, "tx_charge_123");
      
    • Removes verification from a chat that was previously verified by the bot.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When removing verification fails.

      await bot.removeChatVerification(chatId);
      
    • Removes every request transform, response transform, and API error hook registered with the given owner tag.

      Parameters

      • tag: string

        Owner tag previously passed when registering hooks.

      Returns number

      The number of hooks removed.

      bot.removeHooksByTag("my-plugin");
      
    • Removes the profile photo of the bot.

      Returns Promise<boolean>

      true on success.

    • Removes verification from a user that was previously verified by the bot.

      Parameters

      • userId: number

        Unique identifier of the target user.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When removing verification fails.

      await bot.removeUserVerification(123456);
      
    • Reopens a closed topic in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • messageThreadId: number

        Unique identifier for the target message thread of the forum topic.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When reopening topic fails.

      await bot.reopenForumTopic(-1001234567890, 42);
      
    • Reopens a closed 'General' topic in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When reopening General topic fails.

      await bot.reopenGeneralForumTopic(-1001234567890);
      
    • Generates a replacement token for a managed bot.

      Parameters

      • userId: number

        Unique identifier of the target user that owns the managed bot.

      Returns Promise<{ token: string }>

      Object containing the new bot token.

    • Core request dispatcher to execute any raw Telegram Bot API endpoint.

      Automatically serializes JSON objects or multipart FormData when file buffers / InputFile are present. Handles HTTP 429 rate-limiting (honoring retry_after) and HTTP 5xx retries with exponential backoff, sharing a single retry budget across both so that repeated 429s cannot retry forever or starve genuine 5xx retries.

      Type Parameters

      • T

        The expected return payload type from Telegram.

      Parameters

      • method: string

        The Bot API method name (e.g. "sendMessage", "getMe", "setWebhook").

      • payload: Record<string, unknown> = {}

        Key-value parameters corresponding to the API method fields.

      Returns Promise<T>

      Resolves with the unwrapped result field returned by Telegram.

      TelegramApiError When Telegram returns ok: false, HTTP 4xx, or after retry exhaustion on 429/5xx/network errors.

      const user = await bot.request<User>("getMe");
      console.log(`Bot username: @${user.username}`);
    • Restricts a user in a supergroup.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • userId: number

        Unique identifier of the target user.

      • permissions: ChatPermissions

        Object for new user permissions (e.g. can_send_messages).

      • OptionaluseIndependentChatPermissions: boolean

        Pass true if chat permissions are set independently.

      • OptionaluntilDate: number

        Date when restrictions will be lifted; Unix time.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When restriction fails.

      await bot.restrictChatMember(chatId, userId, {
      can_send_messages: false,
      });
    • Revokes an invite link created by the bot.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • inviteLink: string

        The invite link to revoke.

      Returns Promise<ChatInviteLink>

      The revoked ChatInviteLink.

      TelegramApiError When revoking fails.

      await bot.revokeChatInviteLink(chatId, inviteLink);
      
    • Sends an audio file (.MP3 or .M4A format).

      Parameters

      • options: SendAudioOptions

        Options including chat_id, audio, performer, title, and optional duration.

      Returns Promise<Message>

      The sent Message.

      TelegramApiError When sending fails.

      await bot.sendAudio({
      chat_id: 123456,
      audio: audioFileId,
      performer: "Artist",
      title: "Track Title",
      });
    • Broadcasts a chat status action (e.g. typing, uploading photo) to chat members.

      Parameters

      Returns Promise<boolean>

      true on success.

      TelegramApiError When sending action fails.

      await bot.sendChatAction({ chat_id: 123456, action: ChatAction.TYPING });
      
    • Sends an animated dice, dart, basketball, football, slot machine, or bowling pin.

      Parameters

      • options: SendDiceOptions

        Options including chat_id and optional emoji (default 🎲).

      Returns Promise<Message>

      The sent Message with dice result value.

      TelegramApiError When sending dice fails.

      const msg = await bot.sendDice({ chat_id: 123456, emoji: "🎯" });
      console.log(`Dart score: ${msg.dice?.value}`);
    • Sends a game to a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • gameShortName: string

        Short name of the game, serves as the unique identifier for the game. Set up via BotFather.

      • options: {
            allow_paid_broadcast?: boolean;
            business_connection_id?: string;
            disable_notification?: boolean;
            message_effect_id?: string;
            message_thread_id?: number;
            protect_content?: boolean;
            reply_markup?: InlineKeyboardMarkup;
            reply_parameters?: ReplyParameters;
        } = {}

        Additional parameters for sending game.

      Returns Promise<Message>

      The sent Message.

      TelegramApiError When sending game fails.

    • Sends a gift to the given user or channel chat.

      Parameters

      • options: SendGiftOptions

        Options including gift_id and either user_id or chat_id, plus optional message text, text_parse_mode, text_entities and pay_for_upgrade.

      Returns Promise<boolean>

      true on success.

      Exactly one of user_id and chat_id must be provided. The gift can't be converted to Telegram Stars by the receiver.

      TelegramApiError When sending gift fails.

      await bot.sendGift({
      user_id: 123456,
      gift_id: "gift_abc123",
      text: "Enjoy your gift!",
      pay_for_upgrade: true,
      });
      // Send to a channel chat instead of a user
      await bot.sendGift({ chat_id: "@my_channel", gift_id: "gift_abc123" });
    • Sends an invoice to a user or channel.

      Parameters

      • options: SendInvoiceOptions

        Options including chat_id, title, description, payload, currency, and prices.

      Returns Promise<Message>

      The sent Message containing the invoice.

      TelegramApiError When sending invoice fails.

      await bot.sendInvoice({
      chat_id: 123456,
      title: "Premium Subscription",
      description: "1-month access",
      payload: "sub_premium_1m",
      currency: "XTR",
      prices: [{ label: "1 Month", amount: 100 }],
      });
    • Sends a group of 2-10 photos, videos, documents, or audios as an album.

      Parameters

      Returns Promise<Message[]>

      Array of sent Message objects.

      TelegramApiError When sending media group fails.

      await bot.sendMediaGroup({
      chat_id: 123456,
      media: [
      { type: "photo", media: "https://example.com/1.jpg" },
      { type: "photo", media: "https://example.com/2.jpg" },
      ],
      });
    • Sends a text message to a specific chat or user.

      Parameters

      • options: SendMessageOptions

        Message options including chat_id, text, parse_mode, reply_markup, and reply_parameters.

      Returns Promise<Message>

      The sent Message.

      TelegramApiError When sending fails.

      await bot.sendMessage({
      chat_id: 123456,
      text: "Hello *world*!",
      parse_mode: ParseMode.MARKDOWN_V2,
      });
    • Sends a native Telegram poll or quiz.

      Parameters

      • options: SendPollOptions

        Options including chat_id, question, options array, type, and is_anonymous.

      Returns Promise<Message>

      The sent Message.

      TelegramApiError When sending poll fails.

      await bot.sendPoll({
      chat_id: 123456,
      question: "What is your favorite language?",
      options: [{ text: "TypeScript" }, { text: "Rust" }, { text: "Go" }],
      is_anonymous: false,
      });
    • Sends information about a venue / location with title and address.

      Parameters

      • options: SendVenueOptions

        Options including chat_id, latitude, longitude, title, and address.

      Returns Promise<Message>

      The sent Message.

      TelegramApiError When sending fails.

      await bot.sendVenue({
      chat_id: 123456,
      latitude: 40.758896,
      longitude: -73.985130,
      title: "Times Square",
      address: "Manhattan, NY 10036",
      });
    • Sends a video file.

      Parameters

      • options: SendVideoOptions

        Options including chat_id, video, duration, width, height, and optional caption.

      Returns Promise<Message>

      The sent Message.

      TelegramApiError When sending fails.

      await bot.sendVideo({
      chat_id: 123456,
      video: "https://example.com/video.mp4",
      caption: "Watch this video",
      });
    • Changes the bio description of a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • Optionalbio: string

        New bio text.

      Returns Promise<boolean>

      true on success.

    • Changes the first and last name of a managed business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • firstName: string

        New first name of the business account; 1-64 characters.

      • OptionallastName: string

        New last name of the business account; 0-64 characters.

      Returns Promise<boolean>

      true on success.

    • Changes the username of a connected business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • Optionalusername: string

        New username.

      Returns Promise<boolean>

      true on success.

    • Sets a custom title for an administrator in a supergroup promoted by the bot.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • userId: number

        Unique identifier of the target user.

      • customTitle: string

        New custom title for the administrator; 0-16 characters.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting title fails.

      await bot.setChatAdministratorCustomTitle(chatId, userId, "Moderator");
      
    • Changes the description of a group, a supergroup or a channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • Optionaldescription: string

        New chat description, 0-255 characters.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting description fails.

    • Sets a custom tag for a chat member.

      Parameters

      • chatId: string | number

        Target chat identifier.

      • userId: number

        Target user identifier.

      • Optionaltag: string

        Tag name to set.

      Returns Promise<boolean>

      true on success.

    • Changes the bot's menu button in a private chat, or the default menu button.

      Parameters

      • OptionalchatId: string | number

        Unique identifier for the target private chat. If not specified, default menu button is changed.

      • OptionalmenuButton: MenuButton

        An object for the new bot menu button.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When changing menu button fails.

      await bot.setChatMenuButton(123456, {
      type: "web_app",
      text: "Open App",
      web_app: { url: "https://example.com/app" },
      });
    • Sets default chat permissions for all members.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • permissions: ChatPermissions

        Object for new default chat permissions.

      • OptionaluseIndependentChatPermissions: boolean

        Pass true if chat permissions are set independently.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting permissions fails.

      await bot.setChatPermissions(chatId, {
      can_send_messages: true,
      can_send_photos: false,
      });
    • Sets a new profile photo for the chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • photo: string | InputFile

        File ID, URL, or InputFile object.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting chat photo fails.

    • Sets a new group sticker set for a supergroup.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • stickerSetName: string

        Name of the sticker set to be set as the group sticker set.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting sticker set fails.

    • Changes the title of a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • title: string

        New chat title, 1-128 characters.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting title fails.

    • Sets the thumbnail of a custom emoji sticker set.

      Parameters

      • name: string

        Sticker set name.

      • OptionalcustomEmojiId: string

        Custom emoji identifier of a sticker from the set.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting thumbnail fails.

      await bot.setCustomEmojiStickerSetThumbnail("custom_emojis", "5368324170671202286");
      
    • Sets the score of the specified user in a game.

      Parameters

      • userId: number

        User identifier.

      • score: number

        New score, must be non-negative.

      • options: {
            chat_id?: string | number;
            disable_edit_message?: boolean;
            force?: boolean;
            inline_message_id?: string;
            message_id?: number;
        } = {}

        Additional parameters including target message coordinates.

      Returns Promise<boolean | Message>

      The edited Message or true.

      TelegramApiError When setting score fails.

    • Sets emoji or custom emoji reactions on a message.

      Parameters

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting reaction fails.

      await bot.setMessageReaction({
      chat_id: 123456,
      message_id: 789,
      reaction: "👍",
      });
    • Changes the list of the bot's commands for the given scope and user language.

      Parameters

      • options: { commands: BotCommand[]; language_code?: string; scope?: BotCommandScope }

        Options including commands array, and optional scope and language_code.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting commands fails.

      await bot.setMyCommands({
      commands: [{ command: "start", description: "Start the bot" }],
      });
    • Changes the default administrator rights requested by the bot when added as administrator.

      Parameters

      • Optionalrights: ChatAdministratorRights

        An object describing new default administrator rights.

      • OptionalforChannels: boolean

        Pass true to change default rights for channels, or false for groups/supergroups.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When changing administrator rights fails.

      await bot.setMyDefaultAdministratorRights({
      is_anonymous: false,
      can_manage_chat: true,
      can_delete_messages: true,
      can_manage_video_chats: false,
      can_restrict_members: true,
      can_promote_members: false,
      can_change_info: true,
      can_invite_users: true,
      });
    • Changes the bot's description, which is shown on the chat with the bot when empty.

      Parameters

      • Optionaldescription: string

        New bot description (0-512 characters). Pass undefined to remove description.

      • OptionallanguageCode: string

        Two-letter ISO 639-1 language code.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When changing description fails.

      await bot.setMyDescription("An awesome assistant bot.", "en");
      
    • Changes the bot's name.

      Parameters

      • Optionalname: string

        New bot name (0-64 characters). Pass empty or undefined to remove the name.

      • OptionallanguageCode: string

        Two-letter ISO 639-1 language code.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When changing bot name fails.

      await bot.setMyName("CoolBot", "en");
      
    • Sets the profile photo for the bot.

      Parameters

      • photo: unknown

        Photo file to set.

      Returns Promise<boolean>

      true on success.

    • Changes the bot's short description, which is shown on the bot's profile page and sent with links.

      Parameters

      • OptionalshortDescription: string

        New short description (0-120 characters). Pass undefined to remove.

      • OptionallanguageCode: string

        Two-letter ISO 639-1 language code.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When changing short description fails.

      await bot.setMyShortDescription("Fast and powerful Telegram Bot", "en");
      
    • Informs a user that some of the Telegram Passport elements they provided contains errors.

      Parameters

      • userId: number

        User identifier.

      • errors: PassportElementError[]

        Array describing the errors in the elements.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When reporting errors fails.

    • Changes the list of emoji assigned to a regular or custom emoji sticker.

      Parameters

      • sticker: string

        File identifier of the sticker.

      • emojiList: string[]

        List of 1-20 emoji associated with the sticker.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting emoji list fails.

    • Changes search keywords for a sticker.

      Parameters

      • sticker: string

        File identifier of the sticker.

      • Optionalkeywords: string[]

        List of 0-20 search keywords for the sticker.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting keywords fails.

    • Changes the mask position of a mask sticker.

      Parameters

      • sticker: string

        File identifier of the sticker.

      • OptionalmaskPosition: MaskPosition

        Object with the position where the mask should be placed.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting mask position fails.

    • Moves a sticker in a set created by the bot to a specific position.

      Parameters

      • sticker: string

        File identifier of the sticker.

      • position: number

        New 0-based position of the sticker in the set.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When moving position fails.

    • Sets the thumbnail of a regular or custom emoji sticker set.

      Parameters

      • name: string

        Sticker set name.

      • userId: number

        User identifier of the sticker set owner.

      • format: "static" | "animated" | "video"

        Format of the thumbnail ("static", "animated", or "video").

      • Optionalthumbnail: string | InputFile

        Thumbnail file identifier, URL, or InputFile.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting thumbnail fails.

    • Sets the title of a created sticker set.

      Parameters

      • name: string

        Sticker set name.

      • title: string

        Sticker set title, 1-64 characters.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting title fails.

      await bot.setStickerSetTitle("my_pack", "My Awesome Sticker Pack");
      
    • Changes the emoji status for a given user that granted permission to the bot.

      Parameters

      • userId: number

        Unique identifier of the target user.

      • OptionalemojiStatusCustomEmojiId: string

        Custom emoji identifier of the emoji status to set; pass an empty string to remove the status.

      • options: { emoji_status_expiration_date?: number } = {}

        Optional emoji_status_expiration_date.

      Returns Promise<boolean>

      true on success.

      Serialized as the documented emoji_status_custom_emoji_id and emoji_status_expiration_date fields.

      TelegramApiError When setting emoji status fails.

    • Configures a webhook URL to receive incoming updates via HTTPS POST requests.

      Parameters

      • options: SetWebhookOptions

        Webhook settings including url, optional secret_token, allowed_updates, and certificate.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When setting webhook fails.

      await bot.setWebhook({
      url: "https://bot.example.com/webhook",
      secret_token: "my-secret-token",
      allowed_updates: ["message", "callback_query"],
      });
    • Gracefully shuts down active client sessions and connections.

      Returns Promise<void>

    • Helper utility to pause asynchronous execution for a given number of seconds.

      Used internally during retry delays and rate-limit backoff.

      Parameters

      • seconds: number

        Duration in seconds to pause execution.

      Returns Promise<void>

      Promise that resolves once the specified duration elapses.

      await bot.sleep(2); // Pauses execution for 2 seconds
      
    • Stops a poll which was sent by the bot.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or channel.

      • messageId: number

        Identifier of the original message with the poll.

      • options: StopPollOptions = {}

        Additional stop options.

      Returns Promise<Poll>

      The final stopped Poll state.

      TelegramApiError When stopping poll fails.

      const poll = await bot.stopPoll(chatId, messageId);
      console.log(`Total voters: ${poll.total_voter_count}`);
    • Transfers Telegram Stars from a business account.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • starCount: number

        Number of stars to transfer.

      Returns Promise<boolean>

      true on success.

    • Transfers an owned unique gift to another user or chat.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • ownedGiftId: string

        Unique identifier of the gift to transfer.

      • newOwnerChatId: number

        Unique identifier of the chat which will own the gift.

      • options: TransferGiftOptions = {}

        Optional star_count paid for the transfer from the business account balance.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When the request fails.

    • Registers a hook invoked before every outgoing Bot API request.

      Hooks run in registration order and may mutate the payload. Intended for plugins that need to observe or decorate all API traffic (logging, metrics, throttling signals, test mocks).

      Parameters

      Returns this

      This client instance for chaining.

      bot.transformRequest((method, payload) => {
      console.log(`Calling ${method}`);
      payload["protect_content"] = true;
      });
    • Registers a hook invoked with every successful Bot API response.

      Hooks run in registration order. Returning a value replaces the result for subsequent hooks and the caller; returning undefined keeps it unchanged. Useful for response logging, caching, or normalization plugins.

      Parameters

      Returns this

      This client instance for chaining.

      bot.transformResponse((method, result) => {
      console.log(`${method} succeeded`);
      });
    • Unbans a previously banned user in a supergroup or channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target group or channel.

      • userId: number

        Unique identifier of the target user.

      • OptionalonlyIfBanned: boolean

        Do nothing if the user is not banned.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When unbanning fails.

      await bot.unbanChatMember(chatId, userId);
      
    • Unbans a previously banned channel in a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • senderChatId: number

        Unique identifier of the target sender channel.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When unbanning sender chat fails.

      await bot.unbanChatSenderChat(chatId, channelId);
      
    • Unhides the 'General' topic in a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When unhiding General topic fails.

      await bot.unhideGeneralForumTopic(-1001234567890);
      
    • Clears the list of pinned messages in a chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When clearing pinned messages fails.

    • Clears the list of pinned messages in a forum topic.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • messageThreadId: number

        Unique identifier for the target message thread of the forum topic.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When unpinning messages fails.

      await bot.unpinAllForumTopicMessages(-1001234567890, 42);
      
    • Clears the list of pinned messages in the 'General' topic of a forum supergroup chat.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When unpinning General topic messages fails.

      await bot.unpinAllGeneralForumTopicMessages(-1001234567890);
      
    • Unpins a message in a group, a supergroup, or a channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat.

      • OptionalmessageId: number

        Identifier of a message to unpin. If not specified, the most recent pinned message is unpinned.

      • OptionalbusinessConnectionId: string

        Unique identifier of the business connection on behalf of which the message will be unpinned.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When unpinning fails.

    • Upgrades a regular gift owned by a managed business account to a unique gift.

      Parameters

      • businessConnectionId: string

        Unique identifier of the business connection.

      • ownedGiftId: string

        Unique identifier of the regular gift to upgrade.

      • options: UpgradeGiftOptions = {}

        Optional keep_original_details and star_count parameters.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When the request fails.

    • Uploads a file with a sticker for later use in createNewStickerSet and addStickerToSet methods.

      Parameters

      • userId: number

        User identifier of sticker file owner.

      • sticker: string | InputFile

        A file with the sticker (.PNG, .WEBP, .TGS, or .WEBM).

      • stickerFormat: "static" | "animated" | "video"

        Format of the sticker: "static", "animated", or "video".

      Returns Promise<File>

      The uploaded File object.

      TelegramApiError When upload fails.

      const file = await bot.uploadStickerFile(userId, stickerInputFile, "static");
      
    • Verifies a chat on behalf of the organization which owns the bot.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel.

      • OptionalcustomDescription: string

        Custom description for the verification status; 0-70 characters.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When verification fails.

      await bot.verifyChat(chatId, "Verified Community");
      
    • Verifies a user on behalf of the organization which owns the bot.

      Parameters

      • userId: number

        Unique identifier of the target user.

      • OptionalcustomDescription: string

        Custom description for the verification status; 0-70 characters.

      Returns Promise<boolean>

      true on success.

      TelegramApiError When verification fails.

      await bot.verifyUser(123456, "Official Staff");