Class: Bot

Class: Bot

Bot

Bot

new Bot(options)

Constructor for Telegram Bot API Client.
Parameters:
Name Type Description
options Object Configurations for the client
Properties
Name Type Description
token String Bot token
Source:
See:

Methods

_poll() → {Bot}

Start polling for messages
Source:
Returns:
Self
Type
Bot

_setWebhook(Error, Response)

Temporary solution to set webhook
Parameters:
Name Type Description
Error Error during request
Response Object from Telegram service
Source:

forwardMessage(options, callback) → {Promise}

Use this method to forward messages of any kind.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
from_chat_id Integer Unique identifier for the chat where the original message was sent — User or GroupChat id
message_id Integer Unique message identifier
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

getFile(options, callback) → {Promise}

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.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
file_id String File identifier to get info about
dir String <optional>
Directory the file to be stored (if it is not specified, no file willbe downloaded)
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

getMe(callback) → {Promise}

Returns basic information about the bot in form of a User object.
Parameters:
Name Type Description
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

getUserProfilePhotos(options, callback) → {Promise}

Use this method to get a list of profile pictures for a user.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
user_id Integer Unique identifier of the target user
offset String <optional>
Sequential number of the first photo to be returned. By default, all photos are returned.
limit Integer <optional>
Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendAudio(options, callback) → {Promise}

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
audio String Path to audio file (Library will create a stream if the path exist)
file_id String <optional>
If file_id is passed, method will use this instead
reply_to_message_id Integer <optional>
If the message is a reply, ID of the original message
reply_markup Object <optional>
Additional interface options. ReplyKeyboardMarkup
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendChatAction(options, callback) → {Promise}

Use this method when you need to tell the user that something is happening on the bot's side.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
action String Type of action to broadcast.
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendDocument(options, callback) → {Promise}

Use this method to send general files.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
document String Path to document file (Library will create a stream if the path exist)
file_id String <optional>
If file_id is passed, method will use this instead
reply_to_message_id Integer <optional>
If the message is a reply, ID of the original message
reply_markup Object <optional>
Additional interface options. ReplyKeyboardMarkup
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendLocation(options, callback) → {Promise}

Use this method to send point on the map.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
latitude Float Latitude of location
longitude Float Longitude of location
reply_to_message_id Integer <optional>
If the message is a reply, ID of the original message
reply_markup Object <optional>
Additional interface options. ReplyKeyboardMarkup
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendMessage(options, callback) → {Promise}

Use this method to send text messages.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
text String Text of the message to be sent
parse_mode String Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
disable_web_page_preview Boolean <optional>
Disables link previews for links in this message
reply_to_message_id Integer <optional>
If the message is a reply, ID of the original message
reply_markup Object <optional>
Additional interface options. ReplyKeyboardMarkup
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendPhoto(options, callback) → {Promise}

Use this method to send photos.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
photo String Path to photo file (Library will create a stream if the path exist)
file_id String <optional>
If file_id is passed, method will use this instead
caption String <optional>
Photo caption (may also be used when resending photos by file_id).
reply_to_message_id Integer <optional>
If the message is a reply, ID of the original message
reply_markup Object <optional>
Additional interface options. ReplyKeyboardMarkup
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendSticker(options, callback) → {Promise}

Use this method to send .webp stickers.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
sticker String Path to sticker file (Library will create a stream if the path exist)
file_id String <optional>
If file_id is passed, method will use this instead
reply_to_message_id Integer <optional>
If the message is a reply, ID of the original message
reply_markup Object <optional>
Additional interface options. ReplyKeyboardMarkup
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

sendVideo(options, callback) → {Promise}

Use this method to send video files, Telegram clients support mp4 video.
Parameters:
Name Type Description
options Object Options
Properties
Name Type Argument Description
chat_id Integer Unique identifier for the message recipient — User or GroupChat id
video String Path to video file (Library will create a stream if the path exist)
file_id String <optional>
If file_id is passed, method will use this instead
reply_to_message_id Integer <optional>
If the message is a reply, ID of the original message
reply_markup Object <optional>
Additional interface options. ReplyKeyboardMarkup
callback Bot~requestCallback The callback that handles the response.
Source:
See:
Returns:
Q Promise
Type
Promise

start() → {Bot}

Bot start receiving activities
Source:
Returns:
Self
Type
Bot

stop() → {Bot}

End polling for messages
Source:
Returns:
Self
Type
Bot

Type Definitions

requestCallback(Error, Response)

This callback occur after client request for a certain webservice.
Parameters:
Name Type Description
Error Error during request
Response Object from Telegram service
Source:

requestCallback(Error, Response)

To perform multipart request e.g. file upload
Parameters:
Name Type Description
Error Error during request
Response Object from Telegram service
Source: