Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ApiClient
    • Telegram

Index

Constructors

constructor

  • new Telegram(token: string, options?: Partial<Options>, response?: ServerResponse): Telegram
  • Parameters

    • token: string
    • Optional options: Partial<Options>
    • Optional response: ServerResponse

    Returns Telegram

Properties

Readonly options

options: Options

Readonly token

token: string

Accessors

webhookReply

  • get webhookReply(): boolean
  • set webhookReply(enable: boolean): void

Methods

addStickerToSet

  • Add a new sticker to a set created by the bot

    Parameters

    • ownerId: number

      User identifier of sticker set owner

    • name: string

      Sticker set name

    • stickerData: ExtraAddStickerToSet

    Returns Promise<true>

answerCbQuery

  • answerCbQuery(callbackQueryId: string, text?: string, extra?: ExtraAnswerCbQuery): Promise<true>

answerGameQuery

  • answerGameQuery(callbackQueryId: string, url: string): Promise<true>
  • Parameters

    • callbackQueryId: string
    • url: string

    Returns Promise<true>

answerInlineQuery

  • answerInlineQuery(inlineQueryId: string, results: readonly InlineQueryResult[], extra?: ExtraAnswerInlineQuery): Promise<true>
  • Send answers to an inline query. No more than 50 results per query are allowed.

    Parameters

    Returns Promise<true>

answerPreCheckoutQuery

  • answerPreCheckoutQuery(preCheckoutQueryId: string, ok: boolean, errorMessage?: string): Promise<true>
  • Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.

    Parameters

    • preCheckoutQueryId: string
    • ok: boolean

      Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.

    • Optional errorMessage: string

      Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.

    Returns Promise<true>

answerShippingQuery

  • answerShippingQuery(shippingQueryId: string, ok: boolean, shippingOptions: undefined | readonly ShippingOption[], errorMessage: undefined | string): Promise<true>
  • If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Reply to shipping queries.

    Parameters

    • shippingQueryId: string
    • ok: boolean

      Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)

    • shippingOptions: undefined | readonly ShippingOption[]

      Required if ok is True. A JSON-serialized array of available shipping options.

    • errorMessage: undefined | string

      Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.

    Returns Promise<true>

callApi

  • callApi<M>(method: M, payload: Opts<M>, __namedParameters?: CallApiOptions): Promise<ReturnType<{}[M]>>
  • Type parameters

    • M: "sendMessage" | "getUpdates" | "setWebhook" | "deleteWebhook" | "getWebhookInfo" | "getMe" | "logOut" | "close" | "forwardMessage" | "copyMessage" | "sendPhoto" | "sendAudio" | "sendDocument" | "sendVideo" | "sendAnimation" | "sendVoice" | "sendVideoNote" | "sendMediaGroup" | "sendLocation" | "editMessageLiveLocation" | "stopMessageLiveLocation" | "sendVenue" | "sendContact" | "sendPoll" | "sendDice" | "sendChatAction" | "getUserProfilePhotos" | "getFile" | "kickChatMember" | "banChatMember" | "unbanChatMember" | "restrictChatMember" | "promoteChatMember" | "setChatAdministratorCustomTitle" | "setChatPermissions" | "exportChatInviteLink" | "createChatInviteLink" | "editChatInviteLink" | "revokeChatInviteLink" | "setChatPhoto" | "deleteChatPhoto" | "setChatTitle" | "setChatDescription" | "pinChatMessage" | "unpinChatMessage" | "unpinAllChatMessages" | "leaveChat" | "getChat" | "getChatAdministrators" | "getChatMembersCount" | "getChatMemberCount" | "getChatMember" | "setChatStickerSet" | "deleteChatStickerSet" | "answerCallbackQuery" | "setMyCommands" | "deleteMyCommands" | "getMyCommands" | "editMessageText" | "editMessageCaption" | "editMessageMedia" | "editMessageReplyMarkup" | "stopPoll" | "deleteMessage" | "sendSticker" | "getStickerSet" | "uploadStickerFile" | "createNewStickerSet" | "addStickerToSet" | "setStickerPositionInSet" | "deleteStickerFromSet" | "setStickerSetThumb" | "answerInlineQuery" | "sendInvoice" | "answerShippingQuery" | "answerPreCheckoutQuery" | "setPassportDataErrors" | "sendGame" | "setGameScore" | "getGameHighScores"

    Parameters

    • method: M
    • payload: Opts<M>
    • __namedParameters: CallApiOptions = {}

    Returns Promise<ReturnType<{}[M]>>

close

  • close(): Promise<true>
  • Close the bot instance before moving it from one local server to another

    Returns Promise<true>

copyMessage

  • copyMessage(chatId: string | number, fromChatId: string | number, messageId: number, extra?: ExtraCopyMessage): Promise<MessageId>
  • Send copy of existing message

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • fromChatId: string | number

      Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)

    • messageId: number

      Message identifier in the chat specified in from_chat_id

    • Optional extra: ExtraCopyMessage

    Returns Promise<MessageId>

createChatInviteLink

createNewStickerSet

  • Create new sticker set owned by a user. The bot will be able to edit the created sticker set

    Parameters

    • ownerId: number

      User identifier of created sticker set owner

    • name: string

      Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “by”. is case insensitive. 1-64 characters.

    • title: string

      Sticker set title, 1-64 characters

    • stickerData: ExtraCreateNewStickerSet

    Returns Promise<true>

deleteChatPhoto

  • deleteChatPhoto(chatId: string | number): Promise<true>
  • Parameters

    • chatId: string | number

    Returns Promise<true>

deleteChatStickerSet

  • deleteChatStickerSet(chatId: string | number): Promise<true>
  • Parameters

    • chatId: string | number

    Returns Promise<true>

deleteMessage

  • deleteMessage(chatId: string | number, messageId: number): Promise<true>
  • Delete a message, including service messages, with the following limitations:

    • A message can only be deleted if it was sent less than 48 hours ago.
    • Bots can delete outgoing messages in groups and supergroups.
    • Bots granted can_post_messages permissions can delete outgoing messages in channels.
    • If the bot is an administrator of a group, it can delete any message there.
    • If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • messageId: number

    Returns Promise<true>

deleteMyCommands

  • deleteMyCommands(extra?: {}): Promise<true>

deleteStickerFromSet

  • deleteStickerFromSet(sticker: string): Promise<true>
  • Delete a sticker from a set created by the bot.

    Parameters

    • sticker: string

      File identifier of the sticker

    Returns Promise<true>

deleteWebhook

  • deleteWebhook(extra?: { drop_pending_updates?: boolean }): Promise<true>
  • Remove webhook integration

    Parameters

    • Optional extra: { drop_pending_updates?: boolean }
      • Optional drop_pending_updates?: boolean

    Returns Promise<true>

editChatInviteLink

  • editChatInviteLink(chatId: string | number, inviteLink: string, extra?: ExtraEditChatInviteLink): Promise<ChatInviteLink>

editMessageCaption

  • editMessageCaption(chatId: undefined | string | number, messageId: undefined | number, inlineMessageId: undefined | string, caption: undefined | string, extra?: ExtraEditMessageCaption): Promise<true | (Edited & CaptionableMessage)>
  • Edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

    Parameters

    • chatId: undefined | string | number

      Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • messageId: undefined | number

      Required if inlineMessageId is not specified. Identifier of the sent message

    • inlineMessageId: undefined | string

      Required if chatId and messageId are not specified. Identifier of the inline message

    • caption: undefined | string

      New caption of the message

    • Optional extra: ExtraEditMessageCaption

    Returns Promise<true | (Edited & CaptionableMessage)>

editMessageLiveLocation

  • editMessageLiveLocation(chatId: undefined | string | number, messageId: undefined | number, inlineMessageId: undefined | string, latitude: number, longitude: number, extra?: ExtraEditMessageLiveLocation): Promise<true | (Edited & LocationMessage)>
  • Parameters

    • chatId: undefined | string | number
    • messageId: undefined | number
    • inlineMessageId: undefined | string
    • latitude: number
    • longitude: number
    • Optional extra: ExtraEditMessageLiveLocation

    Returns Promise<true | (Edited & LocationMessage)>

editMessageMedia

  • editMessageMedia(chatId: undefined | string | number, messageId: undefined | number, inlineMessageId: undefined | string, media: {} | {} | {} | {} | {}, extra?: ExtraEditMessageMedia): Promise<true | (Edited & AnimationMessage) | (Edited & AudioMessage) | (Edited & DocumentMessage) | (Edited & PhotoMessage) | (Edited & VideoMessage)>
  • Edit animation, audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL.

    Parameters

    • chatId: undefined | string | number

      Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • messageId: undefined | number

      Required if inlineMessageId is not specified. Identifier of the sent message

    • inlineMessageId: undefined | string

      Required if chatId and messageId are not specified. Identifier of the inline message

    • media: {} | {} | {} | {} | {}

      New media of message

    • Optional extra: ExtraEditMessageMedia

    Returns Promise<true | (Edited & AnimationMessage) | (Edited & AudioMessage) | (Edited & DocumentMessage) | (Edited & PhotoMessage) | (Edited & VideoMessage)>

editMessageReplyMarkup

  • editMessageReplyMarkup(chatId: undefined | string | number, messageId: undefined | number, inlineMessageId: undefined | string, markup: undefined | InlineKeyboardMarkup): Promise<true | ((Edited & LocationMessage) & (Edited & TextMessage) & (Edited & AnimationMessage) & (Edited & AudioMessage) & (Edited & DocumentMessage) & (Edited & PhotoMessage) & (Edited & VideoMessage) & (Edited & ChannelChatCreatedMessage) & (Edited & ConnectedWebsiteMessage) & (Edited & DeleteChatPhotoMessage) & (Edited & GroupChatCreatedMessage) & (Edited & InvoiceMessage) & (Edited & LeftChatMemberMessage) & (Edited & MessageAutoDeleteTimerChangedMessage) & (Edited & MigrateFromChatIdMessage) & (Edited & MigrateToChatIdMessage) & (Edited & NewChatMembersMessage) & (Edited & NewChatPhotoMessage) & (Edited & NewChatTitleMessage) & (Edited & PassportDataMessage) & (Edited & ProximityAlertTriggeredMessage) & (Edited & PinnedMessageMessage) & (Edited & SuccessfulPaymentMessage) & (Edited & SupergroupChatCreated) & (Edited & VoiceChatScheduledMessage) & (Edited & VoiceChatStartedMessage) & (Edited & VoiceChatEndedMessage) & (Edited & VoiceChatParticipantsInvitedMessage) & (Edited & ContactMessage) & (Edited & DiceMessage) & (Edited & GameMessage) & (Edited & PollMessage) & (Edited & StickerMessage) & (Edited & VenueMessage) & (Edited & VideoNoteMessage) & (Edited & VoiceMessage))>
  • Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).

    Parameters

    • chatId: undefined | string | number

      Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • messageId: undefined | number

      Required if inlineMessageId is not specified. Identifier of the sent message

    • inlineMessageId: undefined | string

      Required if chatId and messageId are not specified. Identifier of the inline message

    • markup: undefined | InlineKeyboardMarkup

      A JSON-serialized object for an inline keyboard.

    Returns Promise<true | ((Edited & LocationMessage) & (Edited & TextMessage) & (Edited & AnimationMessage) & (Edited & AudioMessage) & (Edited & DocumentMessage) & (Edited & PhotoMessage) & (Edited & VideoMessage) & (Edited & ChannelChatCreatedMessage) & (Edited & ConnectedWebsiteMessage) & (Edited & DeleteChatPhotoMessage) & (Edited & GroupChatCreatedMessage) & (Edited & InvoiceMessage) & (Edited & LeftChatMemberMessage) & (Edited & MessageAutoDeleteTimerChangedMessage) & (Edited & MigrateFromChatIdMessage) & (Edited & MigrateToChatIdMessage) & (Edited & NewChatMembersMessage) & (Edited & NewChatPhotoMessage) & (Edited & NewChatTitleMessage) & (Edited & PassportDataMessage) & (Edited & ProximityAlertTriggeredMessage) & (Edited & PinnedMessageMessage) & (Edited & SuccessfulPaymentMessage) & (Edited & SupergroupChatCreated) & (Edited & VoiceChatScheduledMessage) & (Edited & VoiceChatStartedMessage) & (Edited & VoiceChatEndedMessage) & (Edited & VoiceChatParticipantsInvitedMessage) & (Edited & ContactMessage) & (Edited & DiceMessage) & (Edited & GameMessage) & (Edited & PollMessage) & (Edited & StickerMessage) & (Edited & VenueMessage) & (Edited & VideoNoteMessage) & (Edited & VoiceMessage))>

    If edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

editMessageText

  • editMessageText(chatId: undefined | string | number, messageId: undefined | number, inlineMessageId: undefined | string, text: string, extra?: ExtraEditMessageText): Promise<true | (Edited & TextMessage)>
  • Edit text and game messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

    Parameters

    • chatId: undefined | string | number

      Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • messageId: undefined | number

      Required if inlineMessageId is not specified. Identifier of the sent message

    • inlineMessageId: undefined | string

      Required if chatId and messageId are not specified. Identifier of the inline message

    • text: string

      New text of the message

    • Optional extra: ExtraEditMessageText

    Returns Promise<true | (Edited & TextMessage)>

exportChatInviteLink

  • exportChatInviteLink(chatId: string | number): Promise<string>
  • Export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    Returns Promise<string>

forwardMessage

  • forwardMessage(chatId: string | number, fromChatId: string | number, messageId: number, extra?: { disable_notification?: boolean }): Promise<Message>
  • Forward existing message.

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • fromChatId: string | number

      Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)

    • messageId: number

      Message identifier in the chat specified in from_chat_id

    • Optional extra: { disable_notification?: boolean }
      • Optional disable_notification?: boolean

    Returns Promise<Message>

getChat

  • getChat(chatId: string | number): Promise<ChatFromGetChat>
  • Get 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 supergroup or channel (in the format @channelusername)

    Returns Promise<ChatFromGetChat>

getChatAdministrators

  • getChatAdministrators(chatId: string | number): Promise<ChatMember[]>
  • Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

    Returns Promise<ChatMember[]>

getChatMember

  • getChatMember(chatId: string | number, userId: number): Promise<ChatMember>
  • Get information about a member of a chat.

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

    • userId: number

      Unique identifier of the target user

    Returns Promise<ChatMember>

getChatMembersCount

  • getChatMembersCount(chatId: string | number): Promise<number>
  • Get the number of members in a chat

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

    Returns Promise<number>

getFile

  • getFile(fileId: string): Promise<File>
  • Get basic info about a file and prepare it for downloading

    Parameters

    • fileId: string

      Id of file to get link to

    Returns Promise<File>

getFileLink

  • getFileLink(fileId: string | File): Promise<URL>
  • Get download link to a file

    Parameters

    • fileId: string | File

    Returns Promise<URL>

getGameHighScores

  • getGameHighScores(userId: number, inlineMessageId: undefined | string, chatId: undefined | number, messageId: undefined | number): Promise<GameHighScore[]>
  • Parameters

    • userId: number
    • inlineMessageId: undefined | string
    • chatId: undefined | number
    • messageId: undefined | number

    Returns Promise<GameHighScore[]>

getMe

  • getMe(): Promise<UserFromGetMe>
  • Get basic information about the bot

    Returns Promise<UserFromGetMe>

getMyCommands

  • getMyCommands(extra?: {}): Promise<BotCommand[]>
  • Get the current list of the bot's commands.

    Parameters

    • extra: {} = {}

      Returns Promise<BotCommand[]>

    getStickerSet

    • getStickerSet(name: string): Promise<StickerSet>
    • Parameters

      • name: string

      Returns Promise<StickerSet>

    getUpdates

    • getUpdates(timeout: number, limit: number, offset: number, allowedUpdates: undefined | readonly UpdateType[]): Promise<Update[]>
    • Directly request incoming updates. You should probably use Telegraf::launch instead.

      Parameters

      • timeout: number
      • limit: number
      • offset: number
      • allowedUpdates: undefined | readonly UpdateType[]

      Returns Promise<Update[]>

    getUserProfilePhotos

    • getUserProfilePhotos(userId: number, offset?: number, limit?: number): Promise<UserProfilePhotos>
    • Parameters

      • userId: number
      • Optional offset: number
      • Optional limit: number

      Returns Promise<UserProfilePhotos>

    getWebhookInfo

    • getWebhookInfo(): Promise<WebhookInfo>

    kickChatMember

    • kickChatMember(chatId: string | number, userId: number, untilDate?: number, extra?: ExtraKickChatMember): Promise<true>
    • Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights

      Parameters

      • chatId: string | number

        Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)

      • userId: number
      • Optional untilDate: 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

      • Optional extra: ExtraKickChatMember

      Returns Promise<true>

    leaveChat

    • leaveChat(chatId: string | number): Promise<true>
    • Use this method for your bot to leave a group, supergroup or channel

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

      Returns Promise<true>

    logOut

    • logOut(): Promise<true>
    • Log out from the cloud Bot API server before launching the bot locally

      Returns Promise<true>

    pinChatMessage

    • pinChatMessage(chatId: string | number, messageId: number, extra?: { disable_notification?: boolean }): Promise<true>
    • Pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

      • messageId: number
      • Optional extra: { disable_notification?: boolean }
        • Optional disable_notification?: boolean

      Returns Promise<true>

    promoteChatMember

    • Promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • userId: number
      • extra: ExtraPromoteChatMember

      Returns Promise<true>

    restrictChatMember

    • Restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

      • userId: number
      • extra: ExtraRestrictChatMember

      Returns Promise<true>

    revokeChatInviteLink

    • revokeChatInviteLink(chatId: string | number, inviteLink: string): Promise<ChatInviteLink>
    • Parameters

      • chatId: string | number
      • inviteLink: string

      Returns Promise<ChatInviteLink>

    sendAnimation

    • sendAnimation(chatId: string | number, animation: string | InputFile, extra?: ExtraAnimation): Promise<AnimationMessage>
    • Send .gif animations

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • animation: string | InputFile
      • Optional extra: ExtraAnimation

      Returns Promise<AnimationMessage>

    sendAudio

    • sendAudio(chatId: string | number, audio: string | InputFile, extra?: ExtraAudio): Promise<AudioMessage>
    • Send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • audio: string | InputFile
      • Optional extra: ExtraAudio

      Returns Promise<AudioMessage>

    sendChatAction

    • sendChatAction(chatId: string | number, action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "find_location" | "record_video_note" | "upload_video_note"): Promise<true>
    • Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "find_location" | "record_video_note" | "upload_video_note"

      Returns Promise<true>

    sendContact

    • sendContact(chatId: string | number, phoneNumber: string, firstName: string, extra?: ExtraContact): Promise<ContactMessage>
    • Parameters

      • chatId: string | number
      • phoneNumber: string
      • firstName: string
      • Optional extra: ExtraContact

      Returns Promise<ContactMessage>

    sendCopy

    • sendCopy(chatId: string | number, message: Message, extra?: ExtraCopyMessage): Promise<MessageId>
    • Send copy of existing message.

      deprecated

      use copyMessage instead

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • message: Message

        Received message object

      • Optional extra: ExtraCopyMessage

      Returns Promise<MessageId>

    sendDice

    • sendDice(chatId: string | number, extra?: ExtraDice): Promise<DiceMessage>
    • Send a dice, which will have a random value from 1 to 6.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • Optional extra: ExtraDice

      Returns Promise<DiceMessage>

    sendDocument

    • sendDocument(chatId: string | number, document: string | InputFile, extra?: ExtraDocument): Promise<DocumentMessage>
    • Send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • document: string | InputFile
      • Optional extra: ExtraDocument

      Returns Promise<DocumentMessage>

    sendGame

    • sendGame(chatId: number, gameName: string, extra?: ExtraGame): Promise<GameMessage>
    • Parameters

      • chatId: number

        Unique identifier for the target chat

      • gameName: string
      • Optional extra: ExtraGame

      Returns Promise<GameMessage>

    sendInvoice

    sendLocation

    • sendLocation(chatId: string | number, latitude: number, longitude: number, extra?: ExtraLocation): Promise<LocationMessage>
    • Send point on the map

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • latitude: number
      • longitude: number
      • Optional extra: ExtraLocation

      Returns Promise<LocationMessage>

    sendMediaGroup

    • sendMediaGroup(chatId: string | number, media: readonly ({} | {})[] | readonly {}[] | readonly {}[], extra?: ExtraMediaGroup): Promise<(DocumentMessage | AudioMessage | PhotoMessage | VideoMessage)[]>
    • Send a group of photos or videos as an album

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • media: readonly ({} | {})[] | readonly {}[] | readonly {}[]

        A JSON-serialized array describing photos and videos to be sent, must include 2–10 items

      • Optional extra: ExtraMediaGroup

      Returns Promise<(DocumentMessage | AudioMessage | PhotoMessage | VideoMessage)[]>

    sendMessage

    • sendMessage(chatId: string | number, text: string, extra?: ExtraReplyMessage): Promise<TextMessage>
    • Send a text message

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • text: string

        Text of the message to be sent

      • Optional extra: ExtraReplyMessage

      Returns Promise<TextMessage>

    sendPhoto

    • sendPhoto(chatId: string | number, photo: string | InputFile, extra?: ExtraPhoto): Promise<PhotoMessage>
    • Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • photo: string | InputFile
      • Optional extra: ExtraPhoto

      Returns Promise<PhotoMessage>

    sendPoll

    • sendPoll(chatId: string | number, question: string, options: readonly string[], extra?: ExtraPoll): Promise<PollMessage>
    • Send a native poll.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • question: string

        Poll question, 1-255 characters

      • options: readonly string[]

        A JSON-serialized list of answer options, 2-10 strings 1-100 characters each

      • Optional extra: ExtraPoll

      Returns Promise<PollMessage>

    sendQuiz

    • sendQuiz(chatId: string | number, question: string, options: readonly string[], extra: ExtraPoll): Promise<PollMessage>
    • Send a native quiz.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • question: string

        Poll question, 1-255 characters

      • options: readonly string[]

        A JSON-serialized list of answer options, 2-10 strings 1-100 characters each

      • extra: ExtraPoll

      Returns Promise<PollMessage>

    sendSticker

    • sendSticker(chatId: string | number, sticker: string | InputFile, extra?: ExtraSticker): Promise<StickerMessage>
    • Send .webp stickers

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • sticker: string | InputFile
      • Optional extra: ExtraSticker

      Returns Promise<StickerMessage>

    sendVenue

    • sendVenue(chatId: string | number, latitude: number, longitude: number, title: string, address: string, extra?: ExtraVenue): Promise<VenueMessage>
    • Parameters

      • chatId: string | number
      • latitude: number
      • longitude: number
      • title: string
      • address: string
      • Optional extra: ExtraVenue

      Returns Promise<VenueMessage>

    sendVideo

    • sendVideo(chatId: string | number, video: string | InputFile, extra?: ExtraVideo): Promise<VideoMessage>
    • Send video files, Telegram clients support mp4 videos (other formats may be sent as Document) Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • video: string | InputFile
      • Optional extra: ExtraVideo

      Returns Promise<VideoMessage>

    sendVideoNote

    • sendVideoNote(chatId: string | number, videoNote: string | InputFileVideoNote, extra?: ExtraVideoNote): Promise<VideoNoteMessage>
    • Send video messages

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • videoNote: string | InputFileVideoNote
      • Optional extra: ExtraVideoNote

      Returns Promise<VideoNoteMessage>

    sendVoice

    • sendVoice(chatId: string | number, voice: string | InputFile, extra?: ExtraVoice): Promise<VoiceMessage>
    • Send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • voice: string | InputFile
      • Optional extra: ExtraVoice

      Returns Promise<VoiceMessage>

    setChatAdministratorCustomTitle

    • setChatAdministratorCustomTitle(chatId: string | number, userId: number, title: string): Promise<true>
    • Parameters

      • chatId: string | number
      • userId: number
      • title: string

      Returns Promise<true>

    setChatDescription

    • setChatDescription(chatId: string | number, description?: string): Promise<true>
    • Parameters

      • chatId: string | number
      • Optional description: string

      Returns Promise<true>

    setChatPermissions

    • setChatPermissions(chatId: string | number, permissions: ChatPermissions): Promise<true>
    • Parameters

      • chatId: string | number
      • permissions: ChatPermissions

      Returns Promise<true>

    setChatPhoto

    • setChatPhoto(chatId: string | number, photo: InputFile): Promise<true>
    • Parameters

      • chatId: string | number
      • photo: InputFile

      Returns Promise<true>

    setChatStickerSet

    • setChatStickerSet(chatId: string | number, setName: string): Promise<true>
    • Parameters

      • chatId: string | number
      • setName: string

      Returns Promise<true>

    setChatTitle

    • setChatTitle(chatId: string | number, title: string): Promise<true>
    • Change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights

      Parameters

      • chatId: string | number

        Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)

      • title: string

        New chat title, 1-255 characters

      Returns Promise<true>

    setGameScore

    • setGameScore(userId: number, score: number, inlineMessageId: undefined | string, chatId: undefined | number, messageId: undefined | number, editMessage?: boolean, force?: boolean): Promise<true | (Edited & GameMessage)>
    • Parameters

      • userId: number
      • score: number
      • inlineMessageId: undefined | string
      • chatId: undefined | number
      • messageId: undefined | number
      • editMessage: boolean = true
      • force: boolean = false

      Returns Promise<true | (Edited & GameMessage)>

    setMyCommands

    • Change the list of the bot's commands.

      Parameters

      • commands: readonly BotCommand[]

        A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.

      • Optional extra: ExtraSetMyCommands

      Returns Promise<true>

    setPassportDataErrors

    • setPassportDataErrors(userId: number, errors: readonly PassportElementError[]): Promise<true>
    • Parameters

      • userId: number
      • errors: readonly PassportElementError[]

      Returns Promise<true>

    setStickerPositionInSet

    • setStickerPositionInSet(sticker: string, position: number): Promise<true>
    • Move a sticker in a set created by the bot to a specific position

      Parameters

      • sticker: string

        File identifier of the sticker

      • position: number

        New sticker position in the set, zero-based

      Returns Promise<true>

    setStickerSetThumb

    • setStickerSetThumb(name: string, userId: number, thumb: string | InputFile): Promise<true>
    • Parameters

      • name: string
      • userId: number
      • thumb: string | InputFile

      Returns Promise<true>

    setWebhook

    • Specify a url to receive incoming updates via an outgoing webhook

      Parameters

      • url: string

        HTTPS url to send updates to. Use an empty string to remove webhook integration

      • Optional extra: ExtraSetWebhook

      Returns Promise<true>

    stopMessageLiveLocation

    • stopMessageLiveLocation(chatId: undefined | string | number, messageId: undefined | number, inlineMessageId: undefined | string, markup?: InlineKeyboardMarkup): Promise<true | (Edited & LocationMessage)>
    • Parameters

      • chatId: undefined | string | number
      • messageId: undefined | number
      • inlineMessageId: undefined | string
      • Optional markup: InlineKeyboardMarkup

      Returns Promise<true | (Edited & LocationMessage)>

    stopPoll

    • stopPoll(chatId: string | number, messageId: number, extra?: ExtraStopPoll): Promise<Poll>
    • Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • messageId: number

        Identifier of the original message with the poll

      • Optional extra: ExtraStopPoll

      Returns Promise<Poll>

    unbanChatMember

    • unbanChatMember(chatId: string | number, userId: number, extra?: { only_if_banned?: boolean }): Promise<true>
    • Unban a user from a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights

      Parameters

      • chatId: string | number

        Unique identifier for the target group or username of the target supergroup or channel (in the format @username)

      • userId: number

        Unique identifier of the target user

      • Optional extra: { only_if_banned?: boolean }
        • Optional only_if_banned?: boolean

      Returns Promise<true>

    unpinAllChatMessages

    • unpinAllChatMessages(chatId: string | number): Promise<true>
    • Clear the list of pinned messages in a chat

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      Returns Promise<true>

    unpinChatMessage

    • unpinChatMessage(chatId: string | number, messageId?: number): Promise<true>
    • Unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.

      Parameters

      • chatId: string | number

        Unique identifier for the target chat or username of the target channel (in the format @channelusername)

      • Optional messageId: number

      Returns Promise<true>

    uploadStickerFile

    • uploadStickerFile(ownerId: number, stickerFile: InputFile): Promise<File>
    • Upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times) https://core.telegram.org/bots/api#sending-files

      Parameters

      • ownerId: number

        User identifier of sticker file owner

      • stickerFile: InputFile

        Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.

      Returns Promise<File>

    Generated using TypeDoc