Telegram API Token
Telegram API token
The event emitter for the telegram events
Method endpoint
Updates offset
Callback for the "callback_query" event
Callback for the "channel_post" event
Callback for the "chosen_inline_result" event
Callback for the "edited_channel_post" event
Callback for the "edited_message" event
Callback for the "inline_query" event
Callback for the "message" event
Callback for the "poll_answer" event
Callback for the "poll" event
Callback for the "pre_checkout_query" event
Callback for the "shipping_query" event
Timeout for the polling
Use this method to send answers to callback queries 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. On success, True is returned.
Unique identifier for the query to be answered
answerCallbackQueryOptions
Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned.
Unique identifier for the query to be answered
A JSON-serialized object describing the message to be sent
Use this method to approve a chat join request. 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Unique identifier of the target user
boolean
Use this method to ban a user in a 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.
Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
Unique identifier of the target user
banChatMemberOptions
boolean
Use this method to ban a channel chat in a 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Unique identifier of the target sender chat
boolean
Use this method to copy messages of any kind. 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.
Unique identifier for the target chat or username of the target channel.
Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
Message identifier in the chat specified in from_chat_id
copyMessageOptions
MessageId
// this method works just like forwardMessage with the exception not to link the new message to the original message.
await TelegramAPI.copyMessage(message.chat.id, message.chat.id, message.message_id);
// => will forward the message you sent in the chat back to you. chat_id is the target chat or username and from_chat_id is the id of the channel the message was sent in.
Use this method to create an additional invite link for a chat. 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
createChatInviteLinkOptions
IChatInviteLink
Use this method to create a link for an invoice. Returns the created invoice link as String on success.
Product name, 1-32 characters
Product description, 1-255 characters
Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
Payment provider token, obtained via BotFather
Three-letter ISO 4217 currency code, see more on currencies
Price breakdown, a ILabeledPrice of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
optional createInvoiceLinkOptions
Use this method to decline a chat join request. 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Unique identifier of the target user
boolean
Use this method to delete a 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
boolean
Use this method to delete a group sticker set from a 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.
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
boolean
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.
setMyCommandsOptions
boolean
Use this method to edit a non-primary invite link created by the bot. 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
The invite link to edit
editChatInviteLinkOptions
IChatInviteLink
Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
New caption of the message, 0-1024 characters after entities parsing
editMessageCaptionOptions
IMessage | boolean
Use this method to edit live location messages. 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.
Latitude of new location
Longitude of new location
editMessageLiveLocationOptions
IMessage | boolean
Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
New text of the message, 1-4096 characters after entities parsing
editMessageTextOptions
boolean | IMessage
Use this method to generate a new primary invite link for a 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.
boolean
Use this method to forward messages of any kind. Service messages can't be forwarded. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel.
Unique identifier for the chat where the original message was sent or channel username.
Message identifier in the chat specified in from_chat_id
forwardMessageOptions
IMessage
await TelegramAPI.forwardMessage(message.chat.id, message.chat.id, message.message_id);
// => will forward the message you sent in the chat back to you. chat_id is the target chat or username and from_chat_id is the id of the channel the message was sent in.
Use this method to 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.). Returns a Chat object on success.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
IChat
Use this method to get a list of administrators in a chat. 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.
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
IChatMember[]
Use this method to get information about a member of a chat. Returns a ChatMember object on success.
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
Unique identifier of the target user
IChatMember
Use this method to get the number of members in a chat. Returns Int on success.
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
number
Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
Unique identifier for the target private chat. If not specified, default bot's menu button will be returned
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot
File identifier to get info about
IFile
A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
IUser
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.
Object describing scope of users. Defaults to BotCommandScopeDefault.
Optional. A two-letter ISO 639-1 language code or an empty string.
IBotCommand[]
Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
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.
Use this method to get a list of profile pictures for a user. Returns a IUserProfilePhotos object.
Unique identifier of the target user
getUserProfilePhotosOptions
IUserProfilePhotos
Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
boolean
Event listener for the telegram events
TelegramEvents
TelegramEvents
void
Event listener for the telegram events
TelegramEvents
TelegramEvents
void
Use this method to add a message to the list of pinned messages in a 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Identifier of a message to pin
Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.
boolean
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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Unique identifier of the target user
promoteChatMemberOptions
boolean
Use this method to restrict a user in a 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.
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
Unique identifier of the target user
restrictChatMemberOptions
boolean
Use this method to revoke an invite link created by the bot. 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
The invite link to edit
IChatInviteLink
Use this method to send animation files (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.
Unique identifier for the target chat or username of the target channel.
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.
sendAnimationOptions
IMessage
// => using file_id
await TelegramAPI.sendAnimation(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")
// => using http URL
await Telegram.sendAnimation(message.chat.id, "gif link from the internet")
// => using local file
await TelegramAPI.sendAnimation(message.chat.id, {file: "./cute_kitty.gif", content_type: "image/gif"})
// content_type is optional
Use this method to send audio files, 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
Unique identifier for the target chat or username of the target channel.
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.
sendAudioOptions
IMessage
// => using file_id
await TelegramAPI.sendAudio(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")
// => using http URL
await Telegram.sendAudio(message.chat.id, "audio link from the internet")
// => using local file
await TelegramAPI.sendAudio(message.chat.id, {file: "./nice_song.mp3", content_type: "audio/mpeg"})
// content_type is optional
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.
Unique identifier for the target chat or username of the target channel
ActionType
boolean
Use this method to send phone contacts. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel
Contact's phone number
Contact's first name
sendContactOptions
IMessage
// this will send a phone contact in the specified chat.
await TelegramAPI.sendContact(message.chat.id, "3216513215", "Bob")
Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel
sendDiceOptions
IMessage
Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size.
Unique identifier for the target chat or username of the target channel.
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.
sendDocumentOptions
IMessage
// => using file_id
await TelegramAPI.sendDocument(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")
// => using http URL
await Telegram.sendDocument(message.chat.id, "pdf file link from the internet")
// => using local file
await TelegramAPI.sendDocument(message.chat.id, {file: "./invoide.pdf", content_type: "application/pdf"})
// content_type is optional
Use this method to send point on the map. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel
Latitude of the location
Longitude of the location
sendLocationOptions
IMessage[]
await TelegramAPI.sendLocation(message, chat_id, 40.712776, -74.005974, options);
// will send a location card in the chat.
Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.
Unique identifier for the target chat or username of the target channel.
A JSON-serialized array describing messages to be sent, must include 2-10 items
sendMediaGroupOptions
IMessage
Use this method to send text messages. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel.
Text of the message to be sent, 1-4096 characters after entities parsing
sendMessageOptions
IMessage
await TelegramAPI.sendMessage(message.chat.id, "Hey there!") // => returns IMessage Object
// With options
await TelegramAPI.sendMessage(message.chat.id, "Hey from the bot!", { disable_notification: true})
// => will send the message with no notification
Use this method to send photos. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel.
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 info on Sending Files »
sendPhotoOptions
IMessage
// => using file_id
await TelegramAPI.sendPhoto(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")
// => using http URL
await Telegram.sendPhoto(message.chat.id, "https://cdn.discordapp.com/attachments/658790463595347968/950469680445919272/bc517a2af06ebeed02591cbff6349d3e.png")
// => using local file
await TelegramAPI.sendPhoto(message.chat.id, {file: "./nice.png", content_type: "image/png"})
// content_type is optional
Use this method to send a native poll. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel.
Poll question, 1-300 characters
A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
sendPollOptions
IMessage
await TelegramAPI.sendPoll(message.chat.id, "How are you doing today sir?", [ "Good", "not so bad", "fine"]);
// => returns the IMessage object
// With options
await TelegramAPI.sendPoll(message.chat.id, "How are you doing today sir?", [ "Good", "not so bad", "fine"], {allows_multiple_answers: true, is_anonymous: true});
// => this will send an anonymous poll to the chat with the ability to select multiple answers. returns IMessage
Private Method for sending requests to the Telegram Bot API
API Endpoint URL
the data object if the request method is "POST"
Use this method to send information about a venue. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel
Latitude of the venue
Longitude of the venue
Name of the venue
Address of the venue
sendVenueOptions
IMessage
await TelegramAPI.sendVenue(message.chat.id, 40.712776, -74.005974, "New York","651 Fountain Ave, Brooklyn, NY 11208, USA");
// Will send A location venue. Returns IMessage
Use this method to send video files, Telegram clients support mp4 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.
Unique identifier for the target chat or username of the target channel.
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.
sendVideoOptions
IMessage
// => using file_id
await TelegramAPI.sendVideo(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")
// => using http URL
await Telegram.sendVideo(message.chat.id, "video link from the internet")
// => using local file
await TelegramAPI.sendVideo(message.chat.id, {file: "./nice_video.mp4", content_type: "video/mp4"})
// content_type is optional
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
Unique identifier for the target chat or username of the target channel.
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. Sending video notes by a URL is currently unsupported
sendVideoNoteOptions
// => using file_id
await TelegramAPI.sendVideoNote(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")
// => using local file
await TelegramAPI.sendVideoNote(message.chat.id, {file: "./someVideo.mp4", content_type: "video/mp4"})
// content_type is optional
Use this method to 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.
Unique identifier for the target chat or username of the target channel.
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.
IMessage
// => using file_id
await TelegramAPI.sendVoice(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")
// => using http URL
await Telegram.sendVoice(message.chat.id, "ogg audio link from the internet")
// => using local file
await TelegramAPI.sendVoice(message.chat.id, {file: "./voice.ogg", content_type: "audio/ogg"})
// content_type is optional
Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
Unique identifier of the target user
New custom title for the administrator; 0-16 characters, emoji are not allowed
boolean
Use this method to change the description of a 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Optional. New chat description, 0-255 characters
boolean
Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
Unique identifier for the target private chat. If not specified, default bot's menu button will be changed
A JSON-serialized object for the bot's new menu button. Defaults to MenuButtonDefault
Use this method to set default chat permissions for all members. 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.
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
Object for new default chat permissions
boolean
Use this method to set a new profile photo for the 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
New chat photo. Must be local
boolean
Use this method to set a new group sticker set for a 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.
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
Name of the sticker set to be set as the group sticker set
boolean
Use this method to 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 administrator rights. Returns True on success.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
New chat title, 1-255 characters
boolean
Use this method to change the list of the bot's commands. Returns True on success.
A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
setMyCommandsOptions
boolean
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 are free to modify the list before adding the bot. Returns True on success.
A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
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.
Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
HTTPS URL to send updates to. Use an empty string to remove webhook integration
optional setWebhookOptions
Starts polling updates from the Telegram API
Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.
stopMessageLiveLocationOptions
IMessage | boolean
Stops polling updates from the Telegram API
Use this method to unban a previously banned user in a 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.
Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
Unique identifier of the target user
Do nothing if the user is not banned
boolean
Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Unique identifier of the target sender chat
boolean
Use this method to clear the list of pinned messages in a 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
boolean
Use this method to remove a message from the list of pinned messages in a 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.
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Optional. Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
boolean
Generated using TypeDoc
TelegramAPI constructor