Markup~ Markup

Class for building keyboard / HTML / Markdown / MarkdownV2 markup

Constructor

new Markup()

Methods

botRequest(text, requestId, hideopt) → {BotRequestButton}

Button will open a list of suitable bots. Tapping on any bot will send their identifier to the your bot in a user_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
BotRequestButton

button(text, hideopt) → {Object}

Adds a new text button. This button will simply send the given text as a text message back to your bot if a user clicks on it. Available for non-inline keyboard only.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display and send

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

callbackButton(text, data, hideopt) → {Object}

Adds a new callback query button. The button contains a text and a custom payload. This payload will be sent back to your bot when the button is pressed. If you omit the payload, the display text will be sent back to your bot.

Your bot will receive an update every time a user presses any of the text buttons. You can listen to these updates like this:

// Specific buttons:
bot.action('some-payload', ctx => { ... })

// Any button of any inline keyboard:
bot.on('callback_query', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

datastring

Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

channelRequest(text, requestId, extra, hideopt) → {ChannelRequestButton}

Button will open a list of suitable channels. Tapping on any group will send their identifier to the your bot in a chat_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message

extraChannelRequestButtonExtra

Extra parameters

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
ChannelRequestButton

contactRequestButton(text, hideopt) → {Object}

Adds a new contact request button. The user's phone number will be sent as a contact when the button is pressed. Available in private chats only.

Your bot will in turn receive location updates. You can listen to contact updates like this:

bot.on('contact', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

extra(optionsopt) → {object}

Returns a ready object for extra parameters with given additional options, equals result to Extra.markup(markupObj)

ctx.reply('<i>Banana</i>', Markup.inlineKeyboard([
  Markup.callbackButton('Yes', 'yes'),
  Markup.callbackButton('No', 'no')
]).extra({ parse_mode: 'HTML' }))
Parameters:
NameTypeAttributesDescription
optionsobject<optional>

Additional options which should be passed into extra

Returns:
Type: 
object

forceReply(valueopt) → {Markup}

Adding force reply option to markup

Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

gameButton(text, hideopt) → {Object}

Adds a new game query button

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

groupRequest(text, requestId, extraopt, hideopt) → {GroupRequestButton}

Button will open a list of suitable groups. Tapping on any group will send their identifier to the your bot in a chat_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message

extraGroupRequestButtonExtra<optional>

Extra parameters

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
GroupRequestButton

inlineKeyboard(buttons, options) → {Markup}

Build inline keyboard with given buttons

// Make one-line inline keyboard
Markup.inlineKeyboard([
  Markup.urlButton('one', 'https://example.com'),
  Markup.urlButton('two', 'https://example.com'),
  Markup.urlButton('three', 'https://example.com'),
  Markup.urlButton('four', 'https://example.com')
])

// Make two columns inline keyboard with custom function
Markup.inlineKeyboard([
  Markup.urlButton('one', 'https://example.com'),
  Markup.urlButton('two', 'https://example.com'),
  Markup.urlButton('three', 'https://example.com'),
  Markup.urlButton('four', 'https://example.com')
  ], {
    wrap: (btn, index, currentRow) => index % 2 !== 0
  }
)

// Make fixed two columns inline keyboard with columns option
Markup.inlineKeyboard([
  Markup.urlButton('one', 'https://example.com'),
  Markup.urlButton('two', 'https://example.com'),
  Markup.urlButton('three', 'https://example.com'),
  Markup.urlButton('four', 'https://example.com')
], { columns: 2 })
Parameters:
NameTypeDescription
buttonsArray.<InlineKeyboardButton> | Array.<Array.<InlineKeyboardButton>>

Array of buttons

optionsInlineKeyboardOptions

You can pass here columns count or wrap function for slice buttons to columns

Returns:
Type: 
Markup

inputFieldPlaceholder(placeholder) → {Markup}

The placeholder to be shown in the input field when the reply is active; 1-64 characters

Parameters:
NameTypeDescription
placeholderstring

Placeholder text

Returns:
Type: 
Markup

keyboard(buttons, optionsopt) → {Markup}

Build keyboard with given buttons

// Make one-line keyboard with resize
Markup.keyboard(['one', 'two', 'three', 'four']).resize()

// Make two columns keyboard with custom function
Markup.keyboard(['one', 'two', 'three', 'four'], {
  wrap: (btn, index, currentRow) => index % 2 !== 0
}).resize()

// Make fixed two columns keyboard with columns option
Markup.keyboard(['one', 'two', 'three', 'four'], { columns: 2 }).resize()
Parameters:
NameTypeAttributesDescription
buttonsArray.<KeyboardButton> | Array.<Array.<KeyboardButton>>

Array of buttons

optionsKeyboardOptions<optional>

You can pass here columns count or wrap function for slice buttons to columns

Returns:
Type: 
Markup

locationRequestButton(text, hideopt) → {Object}

Adds a new location request button. The user's current location will be sent when the button is pressed. Available in private chats only.

Your bot will in turn receive location updates. You can listen to inline query updates like this:

bot.on('location', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

loginButton(text, url, optsopt, hideopt) → {Object}

Adds a new login button. This can be used as a replacement for the Telegram Login Widget. You must specify an HTTPS URL used to automatically authorize the user.

Parameters:
NameTypeAttributesDefaultDescription
textstring

Message text

urlstring

An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data.

optsLoginButtonOptions<optional>

Login options

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

oneTime(valueopt) → {Markup}

Enable / Disable hiding keyboard after click

Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat - the user can press a special button in the input field to see the custom keyboard again.

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

payButton(text, hideopt) → {Object}

Adds a new payment button

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

persistent(valueopt) → {Markup}

Requests clients to always show the keyboard when the regular keyboard is hidden.

Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon.

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

pollRequestButton(text, typeopt, hideopt) → {Object}

Adds a new poll request button. The user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

type'quiz' | 'regular'<optional>

The type of permitted polls to create, omit if the user may send a poll of any type

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

removeKeyboard(valueopt) → {Markup}

Enable / Disable keyboard removing

Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup).

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

resize(valueopt) → {Markup}

Enable / Disable resize for keyboard.

Keyboards are non-resized by default, use this function to enable it (without any parameters or pass true). Pass false to force the keyboard to be non-resized.

Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

selective(valueopt) → {Markup}

Enable / Disable selective for force reply / remove keyboard

Use this parameter if you want to force reply from specific users only. Targets:

  1. users that are @mentioned in the text of the Message object;
  2. if the bot's message is a reply (has reply_to_message_id), sender of the original message.
Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

switchToChatButton(text, value, hideopt) → {Object}

Adds a new inline query button. Telegram clients will let the user pick a chat when this button is pressed. This will start an inline query. The selected chat will be prefilled with the name of your bot. You may provide a text that is specified along with it.

Your bot will in turn receive updates for inline queries. You can listen to inline query updates like this:

bot.on('inline_query', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

valuestring

Value

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

switchToChosenChatButton(text, value, allowList, hideopt) → {Object}

Returns inline button that switches the current user to inline mode in a chosen chat with an optional default inline query.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

valuestring

Query value

allowListSwitchInlineQueryChosenChatAllowList

Object contains the list of allowed chat types to choose

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

switchToCurrentChatButton(text, value, hideopt) → {Object}

Adds a new inline query button that act on the current chat. The selected chat will be prefilled with the name of your bot. You may provide a text that is specified along with it. This will start an inline query.

Your bot will in turn receive updates for inline queries. You can listen to inline query updates like this:

bot.on('inline_query', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

valuestring

Value

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

urlButton(text, url, hideopt) → {Object}

Adds a new URL button. Telegram clients will open the provided URL when the button is pressed.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

urlstring

HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

userRequest(text, requestId, userIsPremiumopt, hideopt) → {UserRequestButton}

Button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a user_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message

userIsPremiumboolean<optional>

Optional. Pass True to request a bot, pass False to request a regular user. If not specified, no additional restrictions are applied.

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
UserRequestButton

webApp(text, url, hideopt) → {Object}

Adds a new web app button. The Web App that will be launched when the user presses the button. The Web App will be able to send a web_app_data service message. Available in private chats only.

Parameters:
NameTypeAttributesDefaultDescription
textstring

text to display

urlstring

An HTTPS URL of a Web App to be opened with additional data

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) botRequest(text, requestId, hideopt) → {BotRequestButton}

Button will open a list of suitable bots. Tapping on any bot will send their identifier to the your bot in a user_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
BotRequestButton

(static) button(text, hideopt) → {Object}

Adds a new text button. This button will simply send the given text as a text message back to your bot if a user clicks on it. Available for non-inline keyboard only.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display and send

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) callbackButton(text, data, hideopt) → {Object}

Adds a new callback query button. The button contains a text and a custom payload. This payload will be sent back to your bot when the button is pressed. If you omit the payload, the display text will be sent back to your bot.

Your bot will receive an update every time a user presses any of the text buttons. You can listen to these updates like this:

// Specific buttons:
bot.action('some-payload', ctx => { ... })

// Any button of any inline keyboard:
bot.on('callback_query', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

datastring

Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) channelRequest(text, requestId, extra, hideopt) → {ChannelRequestButton}

Button will open a list of suitable channels. Tapping on any group will send their identifier to the your bot in a chat_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message

extraChannelRequestButtonExtra

Extra parameters

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
ChannelRequestButton

(static) contactRequestButton(text, hideopt) → {Object}

Adds a new contact request button. The user's phone number will be sent as a contact when the button is pressed. Available in private chats only.

Your bot will in turn receive location updates. You can listen to contact updates like this:

bot.on('contact', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) escapeHTML(text) → {string}

Escape string for HTML

Parameters:
NameTypeDescription
textstring

String to escape

Returns:
Type: 
string

(static) escapeMarkdown(text) → {string}

Escape string for Markdown

Parameters:
NameTypeDescription
textstring

String to escape

Returns:
Type: 
string

(static) escapeMarkdownV2(text) → {string}

Escape string for Markdown V2

Parameters:
NameTypeDescription
textstring

String to escape

Returns:
Type: 
string

(static) forceReply(valueopt) → {Markup}

Adding force reply option to markup

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

(static) formatHTML(text, entities) → {string}

Returns build HTML given text and entities object

Parameters:
NameTypeDescription
textstring

Message text

entitiesArray.<MessageEntity>

Array of message entities

Returns:
Type: 
string

(static) gameButton(text, hideopt) → {Object}

Adds a new game query button

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) groupRequest(text, requestId, extraopt, hideopt) → {GroupRequestButton}

Button will open a list of suitable groups. Tapping on any group will send their identifier to the your bot in a chat_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message

extraGroupRequestButtonExtra<optional>

Extra parameters

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
GroupRequestButton

(static) inlineKeyboard(buttons, optionsopt) → {Markup}

Build inline keyboard with given buttons

// Make one-line inline keyboard
Markup.inlineKeyboard([
  Markup.urlButton('one', 'https://example.com'),
  Markup.urlButton('two', 'https://example.com'),
  Markup.urlButton('three', 'https://example.com'),
  Markup.urlButton('four', 'https://example.com')
])

// Make two columns inline keyboard with custom function
Markup.inlineKeyboard([
  Markup.urlButton('one', 'https://example.com'),
  Markup.urlButton('two', 'https://example.com'),
  Markup.urlButton('three', 'https://example.com'),
  Markup.urlButton('four', 'https://example.com')
  ], {
    wrap: (btn, index, currentRow) => index % 2 !== 0
  }
)

// Make fixed two columns inline keyboard with columns option
Markup.inlineKeyboard([
  Markup.urlButton('one', 'https://example.com'),
  Markup.urlButton('two', 'https://example.com'),
  Markup.urlButton('three', 'https://example.com'),
  Markup.urlButton('four', 'https://example.com')
], { columns: 2 })
Parameters:
NameTypeAttributesDescription
buttonsArray.<InlineKeyboardButton> | Array.<Array.<InlineKeyboardButton>> | Array.<string> | Array.<Array.<string>>

Array of buttons

optionsInlineKeyboardOptions<optional>

You can pass here columns count or wrap function for slice buttons to columns

Returns:
Type: 
Markup

(static) inputFieldPlaceholder(placeholder) → {Markup}

Changing input field placeholder when reply is active, used with forceReply

Parameters:
NameTypeDescription
placeholderstring

Placeholder text

Returns:
Type: 
Markup

(static) keyboard(buttons, optionsopt) → {Markup}

Build keyboard with given buttons

// Make one-line keyboard with resize
Markup.keyboard(['one', 'two', 'three', 'four']).resize()

// Make two columns keyboard with custom function
Markup.keyboard(['one', 'two', 'three', 'four'], {
  wrap: (btn, index, currentRow) => index % 2 !== 0
}).resize()

// Make fixed two columns keyboard with columns option
Markup.keyboard(['one', 'two', 'three', 'four'], { columns: 2 }).resize()
Parameters:
NameTypeAttributesDescription
buttonsArray.<KeyboardButton> | Array.<Array.<KeyboardButton>> | Array.<string> | Array.<Array.<string>>

Array of buttons

optionsKeyboardOptions<optional>

You can pass here columns count or wrap function for slice buttons to columns

Returns:
Type: 
Markup

(static) locationRequestButton(text, hideopt) → {Object}

Adds a new location request button. The user's current location will be sent when the button is pressed. Available in private chats only.

Your bot will in turn receive location updates. You can listen to inline query updates like this:

bot.on('location', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) loginButton(text, url, optsopt, hideopt) → {Object}

Adds a new login button. This can be used as a replacement for the Telegram Login Widget. You must specify an HTTPS URL used to automatically authorize the user.

Parameters:
NameTypeAttributesDefaultDescription
textstring

Button text

urlstring

An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data.

optsLoginButtonOptions<optional>

Options

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) oneTime(valueopt) → {Markup}

Enable / Disable hiding keyboard after click

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

(static) payButton(text, hideopt) → {Object}

Adds a new payment button

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) pollRequestButton(text, typeopt, hideopt) → {Object}

Adds a new poll request button. The user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

type'quiz' | 'regular'<optional>

The type of permitted polls to create, omit if the user may send a poll of any type

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) removeKeyboard(valueopt) → {Markup}

Enable / Disable keyboard removing

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

(static) resize(valueopt) → {Markup}

Enable / Disable resize for keyboard.

Keyboards are non-resized by default, use this function to enable it (without any parameters or pass true). Pass false to force the keyboard to be non-resized.

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

(static) selective(valueopt) → {Markup}

Enable / Disable selective for force reply / remove keyboard

Keyboards are non-selective by default, use this function to enable it (without any parameters or pass true). Pass false to force the keyboard to be non-selective.

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Markup

(static) switchToChatButton(text, value, hideopt) → {Object}

Adds a new inline query button. Telegram clients will let the user pick a chat when this button is pressed. This will start an inline query. The selected chat will be prefilled with the name of your bot. You may provide a text that is specified along with it.

Your bot will in turn receive updates for inline queries. You can listen to inline query updates like this:

bot.on('inline_query', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

valuestring

Value

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) switchToChosenChatButton(text, value, allowList, hideopt) → {Object}

Returns inline button that switches the current user to inline mode in a chosen chat with an optional default inline query.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

valuestring

Query value

allowListSwitchInlineQueryChosenChatAllowList

Object contains the list of allowed chat types to choose

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) switchToCurrentChatButton(text, value, hideopt) → {Object}

Adds a new inline query button that act on the current chat. The selected chat will be prefilled with the name of your bot. You may provide a text that is specified along with it. This will start an inline query.

Your bot will in turn receive updates for inline queries. You can listen to inline query updates like this:

bot.on('inline_query', ctx => { ... })
Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

valuestring

Value

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) urlButton(text, url, hideopt) → {Object}

Adds a new URL button. Telegram clients will open the provided URL when the button is pressed.

Parameters:
NameTypeAttributesDefaultDescription
textstring

The text to display

urlstring

HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings.

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object

(static) userRequest(text, requestId, userIsPremiumopt, hideopt) → {UserRequestButton}

Button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a user_shared service message. Available in private chats only & non-inline keyboards

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text of the button.

requestIdnumber

Signed 32-bit identifier of the request, which will be received back in the UserShared object. Must be unique within the message

userIsPremiumboolean<optional>

Optional. Pass True to request a bot, pass False to request a regular user. If not specified, no additional restrictions are applied.

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
UserRequestButton

(static) webApp(text, url, hideopt) → {Object}

Adds a new web app button. The Web App that will be launched when the user presses the button. The Web App will be able to send a web_app_data service message. Available in private chats only.

Parameters:
NameTypeAttributesDefaultDescription
textstring

Text to display

urlstring

An HTTPS URL of a Web App to be opened with additional data

hideboolean<optional>
false

Used by Markup.inlineKeyboard / Markup.keyboard / Markup.buildKeyboard() for hide button when build keyboard

Returns:
Type: 
Object