OpengramContext

When your bot receives a message, Telegram sends an update object to your bot. The update contains information about the chat, the user, and of course the message itself. There are numerous other updates, too: https://core.telegram.org/bots/api#update

When Opengram receives an update, it wraps this update into a context object for you. Context objects are commonly named ctx. A context object does two things:

  1. ctx.update holds the update object that you can use to process the message. This includes providing useful shortcuts for the update, for instance, ctx.message is a shortcut that gives you the message object from the update.
  2. ctx.telegram gives you access to the full Telegram Bot API so that you can directly call any method, such as responding via ctx.telegram.sendMessage. Also, here, the context objects has some useful shortcuts for you. For instance, if you want to send a message to the same chat that a message comes from (i.e. just respond to a user) you can call ctx.reply. This is nothing but a wrapper for ctx.telegram.sendMessage with the right chat_id pre-filled for you. Almost all methods of the Telegram Bot API have their own shortcut directly on the context object, so you probably never really have to use ctx.telegram at all.

This context object is then passed to all the listeners (called middleware) that you register on your bot. Because this is so useful, the context object is often used to hold more information. One example are sessions (a chat-specific data storage that is stored in some store - RAM for in memory sessions / database / file system), and another example is ctx.match that is used by bot.action and other methods to keep information about how a regular expression was matched.

Constructor

new OpengramContext(update, telegram, options)

Constructor of Opengram context object

Parameters:
NameTypeDescription
updateUpdate

Raw update object from telegram

telegramTelegram

Instance of Telegram

optionsContextOptions

Extra options

Members

anyEntities

Returns MessageEntity array for current update.

Shortcut to

  • context.message.entities
  • context.editedMessage.entities
  • context.callbackQuery.message.entities
  • context.channelPost.entities
  • context.editedChannelPost.entities
  • context.message.caption_entities
  • context.editedMessage.caption_entities
  • context.callbackQuery.message.caption_entities
  • context.channelPost.caption_entities
  • context.editedChannelPost.caption_entities

anyMessage

Returns Message object for current update.

Shortcut to

  • context.message
  • context.editedMessage
  • context.callbackQuery.message
  • context.channelPost
  • context.editedChannelPost

anyText

Returns text for current update.

Shortcut to

  • context.message.caption
  • context.editedMessage.caption
  • context.callbackQuery.message.caption
  • context.ctx.channelPost.caption
  • context.editedChannelPost.caption
  • context.message.text
  • context.editedMessage.text
  • context.callbackQuery.message.text
  • context.ctx.channelPost.text
  • context.editedChannelPost.text

callbackQuery

Returns CallbackQuery object for current update

Shortcut to context.update.callback_query

channelPost

Returns channel post object for current update

Shortcut to context.update.channel_post

chat

Returns Chat object for current update

Shortcut to

  • context.myChatMember.chat
  • context.chatMember.chat
  • context.chatJoinRequest.chat
  • context.message.chat
  • context.editedMessage.chat
  • context.callbackQuery.message.chat
  • context.channelPost.chat
  • context.editedChannelPost.chat

chatJoinRequest

Returns ChatJoinRequest object for current update

Shortcut to context.update.chat_join_request

chatMember

Returns ChatMemberUpdated object for current update

Shortcut to context.update.chat_member

chosenInlineResult

Returns ChosenInlineResult object for current update

Shortcut to context.update.chosen_inline_result

editedChannelPost

Returns edited channel post object for current update

Shortcut to context.update.edited_channel_post

editedMessage

Returns edited message object for current update

Shortcut to context.update.edited_message

from

Returns User object for current update

Shortcut to

  • context.inlineQuery.from
  • context.shippingQuery.from
  • context.preCheckoutQuery.from
  • context.chosenInlineResult.from
  • context.myChatMember.from
  • context.chatJoinRequest.from
  • context.message.from
  • context.editedMessage.from
  • context.callbackQuery.message.from
  • context.channelPost.from
  • context.editedChannelPost.from

inlineMessageId

Returns inline message id string for current update

Shortcut to context.callbackQuery.inline_message_id, context.chosenInlineResult.inline_message_id

inlineQuery

Returns InlineQuery object for current update

Shortcut to context.update.inline_query

me

Getter for getting bot username

message

Returns Message object for current update

Shortcut to context.update.message

myChatMember

Returns ChatMemberUpdated object for current update

Shortcut to context.update.my_chat_member

passportData

Returns PassportData object for current update

Shortcut to context.message.passport_data

poll

Returns Poll object for current update

Shortcut to context.update.poll

pollAnswer

Returns PollAnswer object for current update

Shortcut to context.update.poll_answer

preCheckoutQuery

Returns PreCheckoutQuery object for current update

Shortcut to context.update.pre_checkout_query

senderChat

Returns Chat object for current update

Shortcut to

  • context.message.sender_chat
  • context.editedMessage.sender_chat
  • context.callbackQuery.message.sender_chat
  • context.channelPost.sender_chat
  • context.editedChannelPost.sender_chat

shippingQuery

Returns ShippingQuery object for current update

Shortcut to context.update.shipping_query

state

Getter returns state object, available only in current update which be destroyed after update processed

You can store some temporary data for sharing with other middlewares in chain

state

Setter for state object, available only in current update which be destroyed after update processed

You can store some temporary data for sharing with other middlewares in chain

telegram

Returns instance of Telegram for api calls

Alias for context.tg

tg :Telegram

update :Update

Type:

updateType :UpdateType

webhookReply

Getter for webhookReply

Use this property to control reply via webhook feature for current context.

webhookReply

Setter for webhookReply

Use this property to control reply via webhook feature for current context.

Methods

addStickerToSet(name, extra, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to add a new sticker to a set created by the bot for user from current update. You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
namestring

Sticker set name

extraExtraAddStickerToSet

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

answerCbQuery(textopt, showAlertopt, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to send answers to current callback query sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.

Returns True on success or WebhookResponse when webhook response enabled.

Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.

Parameters:
NameTypeAttributesDescription
textstring<optional>

Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters

showAlertboolean<optional>

If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.

extraExtraAnswerCbQuery<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

answerGameQuery(urlopt, signalopt) → {Promise}

Alias to answerCbQuery for game query

Parameters:
NameTypeAttributesDescription
urlstring<optional>

URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @BotFather, specify the URL that opens your game - note that this will only work if the query comes from a callback_game button.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise

answerInlineQuery(results, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to send answers to current inline query.

Returns True on success or WebhookResponse when webhook response enabled. No more than 50 results per query are allowed.

Parameters:
NameTypeAttributesDescription
resultsArray.<InlineQueryResult>

A array of results for the inline query

extraExtraAnswerInlineQuery<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

answerPreCheckoutQuery(ok, errorMessageopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

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. Use this method to respond to current pre-checkout queries.

Returns True on success or WebhookResponse when webhook response enabled.

Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.

Parameters:
NameTypeAttributesDescription
okboolean

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.

errorMessagestring<optional>

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.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

answerShippingQuery(ok, shippingOptionsopt, errorMessageopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

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. Use this method to reply to cvurrent shipping queries.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
okboolean

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)

shippingOptionsArray.<ShippingOption><optional>

Required if ok is True. Array of available shipping options.

errorMessagestring<optional>

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.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

approveChatJoinRequest(userId, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to approve join request for chat from current update. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

banChatMember(userId, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to ban a user in current group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat 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 administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

extraExtraBanChatMember<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

banChatSenderChat(senderChatId, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to ban a channel chat in current supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
senderChatIdnumber

Unique identifier of the target sender chat

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

closeForumTopic(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

closeGeneralForumTopic(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

copyMessage(chatId, extraopt, signalopt) → {Promise.<MessageId>}

Use this method to copy messages of any kind from current chat. Service messages and invoice messages can't be copied. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message.

Returns the MessageId of the sent message on success.

Parameters:
NameTypeAttributesDescription
chatIdnumber | string

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

extraExtraCopyMessage | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<MessageId>

Use this method to create an additional invite link for chat from current update. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink.

Returns the new invite link as ChatInviteLink object.

Parameters:
NameTypeAttributesDescription
extraExtraCreateChatInviteLink<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<ChatInviteLink>

createForumTopic(name, extraopt, signalopt) → {Promise.<ForumTopic>}

Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.

Returns information about the created topic as a ForumTopic object.

Parameters:
NameTypeAttributesDescription
namestring

Topic name, 1-128 characters

extraExtraCreateForumTopic<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<ForumTopic>

Use this method to create a link for an invoice.

Returns the created invoice link as String on success.

Parameters:
NameTypeAttributesDescription
invoiceInvoiceLinkParams

Object with invoice properties

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<string>

createNewStickerSet(name, title, extra, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to create a new sticker set owned by current user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
namestring

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_<bot_username>". <bot_username> is case insensitive. 1-64 characters.

titlestring

Sticker set title, 1-64 characters

extraExtraCreateNewStickerSet

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

declineChatJoinRequest(userId, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to decline join request for chat from current update. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

deleteChatPhoto(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to delete current chat photo. Photos 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 administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

deleteChatStickerSet(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to delete a group sticker set from current supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

deleteForumTopic(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

deleteMessage(messageId, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to delete message from current update or message with id specified in arguments, including service messages, with the following limitations:

  • A message can only be deleted if it was sent less than 48 hours ago.
  • A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
  • Bots can delete outgoing messages in private chats, groups, and supergroups.
  • Bots can delete incoming messages in private chats.
  • 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.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
messageIdnumber

Identifier of the message to delete

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

deleteMyCommands(extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
extraExtraDeleteMyCommands<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

deleteStickerFromSet(sticker, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to delete a sticker from a set created by the bot.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
stickerstring

File identifier of the sticker

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

Use this method to edit a non-primary invite link created by the bot for chat from current update. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.

Returns the edited invite link as a ChatInviteLink object.

Parameters:
NameTypeAttributesDescription
inviteLinkstring

The invite link to edit

extraExtraEditChatInviteLink<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<ChatInviteLink>

editForumTopic(nameopt, iconCustomEmojiIdopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
namestring<optional>

Topic name, 1-128 characters

iconCustomEmojiIdstring<optional>

New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

editGeneralForumTopic(name, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
namestring

New topic name, 1-128 characters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

editMessageCaption(captionopt, extraopt, signalopt) → {Promise.<(boolean|Message)>}

Use this method to edit captions of inline messages / messages from current update.

On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
NameTypeAttributesDescription
captionstring<optional>

New caption of the message, 0-1024 characters after entities parsing

extraExtraEditMessageCaption | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|Message)>

editMessageLiveLocation(latitude, longitude, extraopt, signalopt) → {Promise.<(boolean|Message)>}

Use this method to edit live location inline message / message from current update. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation.

On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
NameTypeAttributesDescription
latitudenumber

Latitude of new location

longitudenumber

Longitude of new location

extraExtraEditMessageLiveLocation | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|Message)>

editMessageMedia(media, extraopt, signalopt) → {Promise.<(boolean|Message)>}

Use this method to edit animation, audio, document, photo, or video inline messages / messages from current update. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL.

On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
NameTypeAttributesDescription
mediaInputMedia

Object for a new media content of the message

extraExtraEditMessageMedia | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|Message)>

editMessageReplyMarkup(markupopt, signalopt) → {Promise.<(boolean|Message)>}

Use this method to edit only the reply markup of inline message / message from current update.

On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
NameTypeAttributesDescription
markupObject | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|Message)>

editMessageText(text, extraopt, signalopt) → {Promise.<(boolean|Message)>}

Use this method to edit text and game inline messages for current from current update.

On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
NameTypeAttributesDescription
textstring

New text of the message, 1-4096 characters after entities parsing

extraExtraEditMessageText | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|Message)>

Use this method to generate a new primary invite link for current chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.

Returns the new invite link as String on success.

Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise

forwardMessage(chatId, extraopt, signalopt) → {Promise.<Message>}

Use this method to forward messages of any kind from current chat. Service messages can't be forwarded.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
chatIdstring | number

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

extraExtraForwardMessage | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

getChat(signalopt) → {Promise.<Chat>}

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

Returns a Chat object on success.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Chat>

getChatAdministrators(signalopt) → {Promise.<Array.<ChatMember>>}

Use this method to get a list of administrators in chat from current update.

On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Array.<ChatMember>>

getChatMember(userId, signalopt) → {Promise.<ChatMember>}

Use this method to get information about a member of chat from current update.

Note that the method getChatMember is only guaranteed to work if the bot is an administrator in the chat. (for hidden members after Bots API 6.4) Returns a ChatMember object on success.

Parameters:
NameTypeAttributesDescription
userIdnumber | string

Unique identifier of the target user

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<ChatMember>

getChatMemberCount(signalopt) → {Promise.<number>}

Use this method to get the number of members in chat from current update.

Returns Int on success.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<number>

getChatMembersCount(signalopt) → {Promise.<number>}

Use this method to get the number of members in chat from current update.

Returns Int on success.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Deprecated
  • Use getChatMemberCount
Returns:
Type: 
Promise.<number>

getChatMenuButton(signalopt) → {Promise.<MenuButton>}

Use this method to get the current value of the bot's menu button in private chat from current update, or the default menu button.

Returns MenuButton on success.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<MenuButton>

getCustomEmojiStickers(customEmojiIds, signalopt) → {Promise.<Array.<Sticker>>}

Use this method to get information about custom emoji stickers by their identifiers.

Returns an Array of Sticker objects.

Parameters:
NameTypeAttributesDescription
customEmojiIdsArray.<string>

List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Array.<Sticker>>

getMyCommands(extraopt, signalopt) → {Promise.<Array.<BotCommand>>}

Use this method to get the current list of the bot's commands for the given scope and user language.

Returns Array of BotCommand on success. If commands aren't set, an empty list is returned.

Parameters:
NameTypeAttributesDescription
extraExtraGetMyCommands<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Array.<BotCommand>>

getMyDefaultAdministratorRights(forChannelsopt, signalopt) → {Promise.<ChatAdministratorRights>}

Use this method to get the current default administrator rights of the bot.

Returns ChatAdministratorRights on success.

Parameters:
NameTypeAttributesDescription
forChannelsboolean<optional>

Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<ChatAdministratorRights>

getStickerSet(name, signalopt) → {Promise.<StickerSet>}

Use this method to get a sticker set.

On success, a StickerSet object is returned.

Parameters:
NameTypeAttributesDescription
namestring

Name of the sticker set

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<StickerSet>

hideGeneralForumTopic(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

kickChatMember(userId, untilDateopt, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Alias to banChatMember, but have different arguments (Deprecated after Bots API 5.3)

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

untilDatenumber<optional>

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. Applied for supergroups and channels only.

extraExtraKickChatMember<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

leaveChat(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method for your bot to leave from group, supergroup or channel from current update.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

pinChatMessage(messageId, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to add a message to the list of pinned messages in current chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
messageIdnumber

Identifier of a message to pin

extraExtraPinChatMessage | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

promoteChatMember(userId, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to 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 administrator rights. Pass False for all boolean parameters to demote a user.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

extraExtraPromoteChatMember<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

reopenForumTopic(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

reopenGeneralForumTopic(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

reply(text, extraopt, signalopt) → {Promise.<Message>}

Use this method to send text messages to current chat.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
textstring

Text of the message to be sent, 1-4096 characters after entities parsing

extraExtraSendMessage | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithAnimation(animation, extraopt, signalopt) → {Promise.<Message>}

Use this method to send animation files to chat from current update (GIF or H.264/MPEG-4 AVC video without sound).

On success, the sent Message is returned.

Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

Parameters:
NameTypeAttributesDescription
animationInputFile | FileId

Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. More information on Sending Files »

extraExtraAnimation | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithAudio(audio, extraopt, signalopt) → {Promise.<Message>}

Use this method to send audio files to chat from current update, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format.

On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

For sending voice messages, use the OpengramContext#replyWithVoice method instead.

Parameters:
NameTypeAttributesDescription
audioInputFile | FileId

Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »

extraExtraAudio | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithChatAction(action, signalopt) → {Promise.<(boolean|WebhookResponse)>}

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).

Returns True on success or WebhookResponse when webhook response enabled.

Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use replyWithChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.

We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.

Parameters:
NameTypeAttributesDescription
actionAction

Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

replyWithContact(phoneNumber, firstName, extraopt, signalopt) → {Promise.<Message>}

Use this method to send phone contacts to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
phoneNumberstring

Contact's phone number

firstNamestring

Contact's first name

extraExtraContact | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithDice(extraopt, signalopt) → {Promise.<Message>}

Use this method to send an animated emoji that will display a random value to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
extraExtraDice | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithDocument(document, extraopt, signalopt) → {Promise.<Message>}

Use this method to send general files to chat from current update.

On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

Parameters:
NameTypeAttributesDescription
documentInputFile | FileId

Document to send. Pass a file_id as String to send a document that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. More information on Sending Files »

extraExtraDocument | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithGame(gameName, extraopt, signalopt) → {Promise.<Message>}

Use this method to send a game to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
gameNamestring

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

extraExtraGame | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithHTML(html, extraopt, signalopt) → {Promise.<Message>}

Use this method to send text messages with HTML (parse_mode: 'HTML') to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
htmlstring

Text with HTML of the message to be sent, 1-4096 characters after entities parsing

extraExtraSendMessage | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithInvoice(invoice, extraopt, signalopt) → {Promise.<Message>}

Use this method to send invoice to current chat.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
invoiceInvoiceParams

Other invoice parameters

extraExtraInvoice | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithLocation(latitude, longitude, extraopt, signalopt) → {Promise}

Use this method to send point on the map to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
latitudenumber

Latitude of the location

longitudenumber

Longitude of the location

extraExtraLocation | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise

replyWithMarkdown(markdown, extraopt, signalopt) → {Promise.<Message>}

Use this method to send text messages with Markdown (parse_mode: 'Markdown') to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
markdownstring

Text with Markdown of the message to be sent, 1-4096 characters after entities parsing

extraExtraSendMessage | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithMarkdownV2(markdown, extraopt, signalopt) → {Promise.<Message>}

Use this method to send text messages with MarkdownV2 (parse_mode: 'MarkdownV2') to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
markdownstring

Text with MarkdownV2 of the message to be sent, 1-4096 characters after entities parsing

extraExtraSendMessage | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithMediaGroup(media, extraopt, signalopt) → {Promise.<Array.<Message>>}

Use this method to send a group of photos, videos, documents or audios as an album to chat from current update. Documents and audio files can be only grouped on an album with messages of the same type.

On success, an array of Messages that were sent is returned.

Parameters:
NameTypeAttributesDescription
mediaArray.<(InputMediaPhoto|InputMediaAudio|InputMediaVideo|InputMediaDocument)>

A array describing messages to be sent, must include 2-10 items

extraExtraMediaGroup | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Array.<Message>>

replyWithPhoto(photo, extraopt, signalopt) → {Promise.<Message>}

Use this method to send message with photo to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
photoInputFile | FileId

Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. More information on Sending Files »

extraExtraPhoto | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithPoll(question, options, extraopt, signalopt) → {Promise.<Message>}

Use this method to send a native poll with type regular to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
questionstring

Poll question, 1-300 characters

optionsArray.<string>

List of answer options, 2-10 strings 1-100 characters each

extraExtraPoll | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithQuiz(question, options, extraopt, signalopt) → {Promise.<Message>}

Use this method to send a native poll with type quiz to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
questionstring

Poll question, 1-300 characters

optionsArray.<string>

List of answer options, 2-10 strings 1-100 characters each

extraExtraQuiz | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithSticker(sticker, extraopt, signalopt) → {Promise.<Message>}

Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
stickerInputFile | FileId

Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files »

extraExtraSticker | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithVenue(latitude, longitude, title, address, extraopt, signalopt) → {Promise.<Message>}

Use this method to send information about a venue to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
latitudenumber

Latitude of the venue

longitudenumber

Longitude of the venue

titlestring

Name of the venue

addressstring

Address of the venue

extraExtraVenue | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithVideo(video, extraopt, signalopt) → {Promise.<Message>}

Use this method to send video files to chat from current update, Telegram clients support MPEG4 videos (other formats may be sent as Document).

On success, the sent Message is returned.

Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

Parameters:
NameTypeAttributesDescription
videoInputFile | FileId

Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. More information on Sending Files »

extraExtraVideo | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithVideoNote(videoNote, extraopt, signalopt) → {Promise.<Message>}

As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages to chat from current update.

On success, the sent Message is returned.

Parameters:
NameTypeAttributesDescription
videoNoteInputFile | FileId

Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More information on Sending Files ». Sending video notes by a URL is currently unsupported

extraExtraVideoNote | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

replyWithVoice(voice, extraopt, signalopt) → {Promise.<Message>}

Use this method to send audio files to chat from current update, 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:
NameTypeAttributesDescription
voiceInputFile | FileId

Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.

extraExtraVoice | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Message>

restrictChatMember(userId, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to restrict a user in current supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

extraExtraRestrictChatMember<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

Use this method to revoke an invite link created by the bot for chat from current update. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.

Returns the revoked invite link as ChatInviteLink object.

Parameters:
NameTypeAttributesDescription
inviteLinkstring

The invite link to revoke

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<ChatInviteLink>

setChatAdministratorCustomTitle(userId, title, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to set a custom title for an administrator in current supergroup promoted by the bot.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

titlestring

New custom title for the administrator; 0-16 characters, emoji are not allowed

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setChatDescription(descriptionopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to change the description of current group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.

Returns True on success or WebhookResponse when webhook response enabled. https://core.telegram.org/bots/api#setchatdescription

Parameters:
NameTypeAttributesDescription
descriptionstring<optional>

New chat description, 0-255 characters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setChatMenuButton(menuButtonopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to change the bot's menu button in private chat from current update, or the default menu button.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
menuButtonMenuButton<optional>

Unique identifier for the target private chat. If not specified, default bot's menu button will be changed

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setChatPermissions(permissions, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to set default chat permissions for all members in chat from current update. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
permissionsChatPermissions

A object for new default chat permissions

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setChatPhoto(photo, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to set a new profile photo for current chat. Photos 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 administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
photoInputFile

New chat photo, uploaded using multipart/form-data

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setChatStickerSet(setName, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to set a new group sticker set for supergroup from current update. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
setNamestring

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

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setChatTitle(title, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to change the title of a chat. Titles can't be changed for current private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
titlestring

New chat title, 1-255 characters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setMyCommands(commands, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
commandsArray.<BotCommand>

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

extraExtraSetMyCommands<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setMyDefaultAdministratorRights(rightsopt, forChannelsopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot.

Returns True on success or WebhookResponse when webhook response enabled. https://core.telegram.org/bots/api#setmydefaultadministratorrights

Parameters:
NameTypeAttributesDescription
rightsChatAdministratorRights<optional>

Object describing new default administrator rights. If not specified, the default administrator rights will be cleared.

forChannelsboolean<optional>

Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setPassportDataErrors(errors, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Informs current user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change).

Returns True on success or WebhookResponse when webhook response enabled.

Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.

Parameters:
NameTypeAttributesDescription
errorsArray.<PassportElementError>

Array describing the errors

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setStickerPositionInSet(sticker, position, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to move a sticker in a set created by the bot to a specific position.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
stickerstring

File identifier of the sticker

positionnumber

New sticker position in the set, zero-based

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setStickerSetThumb(name, userId, thumbnailopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
namestring

Sticker set name

userIdnumber

User identifier of the sticker set owner

thumbnailInputFile | FileId<optional>

A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements, or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated sticker set thumbnails can't be uploaded via HTTP URL.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Deprecated
Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

setStickerSetThumbnail(name, userId, thumbnailopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
namestring

Sticker set name

userIdnumber

User identifier of the sticker set owner

thumbnailInputFile | FileId<optional>

A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements, or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated sticker set thumbnails can't be uploaded via HTTP URL.

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

stopMessageLiveLocation(markupopt, signalopt) → {Promise.<(boolean|Message)>}

Use this method to edit live location inline message / message from current update. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation.

On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
NameTypeAttributesDescription
markupObject | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|Message)>

stopPoll(messageId, extraopt, signalopt) → {Promise.<Poll>}

Use this method to stop a poll in chat from current update. which was sent by the bot.

On success, the stopped Poll is returned.

Parameters:
NameTypeAttributesDescription
messageIdnumber

Identifier of the original message with the poll

extraExtraStopPoll | Extra<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<Poll>

unbanChatMember(userId, extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to unban a previously banned user in current supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
userIdnumber

Unique identifier of the target user

extraExtraUnbanMember<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

unbanChatSenderChat(senderChatId, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to unban a previously banned channel chat in current supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
senderChatIdnumber

Unique identifier of the target sender chat

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

unhideGeneralForumTopic(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

unpinAllChatMessages(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to clear the list of pinned messages in chat from current update. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

unpinAllForumTopicMessages(signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

unpinAllGeneralForumTopicMessages(chatId, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
chatIdnumber | string

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

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

unpinChatMessage(extraopt, signalopt) → {Promise.<(boolean|WebhookResponse)>}

Use this method to remove a message from the list of pinned messages in chat from current update. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel.

Returns True on success or WebhookResponse when webhook response enabled.

Parameters:
NameTypeAttributesDescription
extraExtraUnPinChatMessage<optional>

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<(boolean|WebhookResponse)>

uploadStickerFile(sticker, extra, signalopt) → {Promise.<File>}

Use this method to upload a .PNG file with a sticker owned by current user for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times).

Returns the uploaded File on success.

Parameters:
NameTypeAttributesDescription
stickerInputSticker

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. More information on Sending Files ».

extraExtraUploadStickerFile

Other parameters

signalAbortSignal<optional>

Optional AbortSignal to cancel the request

Returns:
Type: 
Promise.<File>