TelegramPHP Documentation

ReplyKeyboard
in package
implements JsonSerializable

FinalYes

Builds the `ReplyKeyboardMarkup` that replaces the user's keyboard with buttons of your own.

$telegram->sendMessage($chatId, 'Where are you?', reply_markup: ReplyKeyboard::new()
    ->requestLocation('Send my location')
    ->row()
    ->button('Skip')
    ->resize()
    ->oneTime());

remove() and forceReply() cover the other two reply markups, which carry no buttons of their own.

Tags
link
https://core.telegram.org/bots/api#replykeyboardmarkup
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Interfaces

JsonSerializable

Properties

$options  : array<string, mixed>
$rows  : array<int, array<int, array<string, mixed>>>

Methods

add()  : self
Adds a button built by hand.
button()  : self
A plain button; pressing it sends its text as a message.
forceReply()  : array<string, mixed>
The `ForceReply` markup, which puts the user straight into a reply.
jsonSerialize()  : array<string, mixed>
new()  : self
oneTime()  : self
Hides the keyboard once a button has been pressed.
persistent()  : self
Keeps the keyboard open until it is explicitly replaced or removed.
placeholder()  : self
The placeholder shown in the input field while the keyboard is up.
remove()  : array<string, mixed>
The `ReplyKeyboardRemove` markup, which takes a custom keyboard away.
requestChat()  : self
Asks the user to pick a chat to share with the bot.
requestContact()  : self
Asks the user to share their phone number. Private chats only.
requestLocation()  : self
Asks the user to share their location. Private chats only.
requestPoll()  : self
Asks the user to create a poll. Private chats only.
requestUsers()  : self
Asks the user to pick users to share with the bot.
resize()  : self
Shrinks the keyboard to fit its buttons.
row()  : self
Starts a new row. A row that would be left empty is dropped on serialisation.
selective()  : self
Shows the keyboard only to the users the message concerns.
webApp()  : self
Opens a Mini App, whose data comes back as a service message.

Properties

$rows

private array<int, array<int, array<string, mixed>>> $rows = [[]]

Methods

add()

Adds a button built by hand.

public add(array<string, mixed>|string $button) : self
Parameters
$button : array<string, mixed>|string

A KeyboardButton, or just its text.

Return values
self

button()

A plain button; pressing it sends its text as a message.

public button(string $text) : self
Parameters
$text : string
Return values
self

forceReply()

The `ForceReply` markup, which puts the user straight into a reply.

public static forceReply([?string $placeholder = null ][, bool $selective = false ]) : array<string, mixed>
Parameters
$placeholder : ?string = null
$selective : bool = false
Return values
array<string, mixed>

jsonSerialize()

public jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>

oneTime()

Hides the keyboard once a button has been pressed.

public oneTime([bool $oneTime = true ]) : self
Parameters
$oneTime : bool = true
Return values
self

persistent()

Keeps the keyboard open until it is explicitly replaced or removed.

public persistent([bool $persistent = true ]) : self
Parameters
$persistent : bool = true
Return values
self

placeholder()

The placeholder shown in the input field while the keyboard is up.

public placeholder(string $placeholder) : self
Parameters
$placeholder : string
Return values
self

remove()

The `ReplyKeyboardRemove` markup, which takes a custom keyboard away.

public static remove([bool $selective = false ]) : array<string, mixed>
Parameters
$selective : bool = false
Return values
array<string, mixed>

requestChat()

Asks the user to pick a chat to share with the bot.

public requestChat(string $text, int $requestId[, bool $chatIsChannel = false ][, array<string, mixed> $criteria = [] ]) : self
Parameters
$text : string
$requestId : int
$chatIsChannel : bool = false
$criteria : array<string, mixed> = []

Extra KeyboardButtonRequestChat fields.

Return values
self

requestContact()

Asks the user to share their phone number. Private chats only.

public requestContact(string $text) : self
Parameters
$text : string
Return values
self

requestLocation()

Asks the user to share their location. Private chats only.

public requestLocation(string $text) : self
Parameters
$text : string
Return values
self

requestPoll()

Asks the user to create a poll. Private chats only.

public requestPoll(string $text[, ?string $type = null ]) : self
Parameters
$text : string
$type : ?string = null
Return values
self

requestUsers()

Asks the user to pick users to share with the bot.

public requestUsers(string $text, int $requestId[, array<string, mixed> $criteria = [] ]) : self
Parameters
$text : string
$requestId : int
$criteria : array<string, mixed> = []

Extra KeyboardButtonRequestUsers fields.

Return values
self

resize()

Shrinks the keyboard to fit its buttons.

public resize([bool $resize = true ]) : self
Parameters
$resize : bool = true
Return values
self

row()

Starts a new row. A row that would be left empty is dropped on serialisation.

public row() : self
Return values
self

selective()

Shows the keyboard only to the users the message concerns.

public selective([bool $selective = true ]) : self
Parameters
$selective : bool = true
Return values
self

webApp()

Opens a Mini App, whose data comes back as a service message.

public webApp(string $text, string $url) : self
Parameters
$text : string
$url : string
Return values
self
On this page

Search results