TelegramPHP Documentation

BusinessApi

This file is generated from spec/openapi.json (Bot API 10.3) by tools/generate.php.

Do not edit it by hand - run composer spec:build instead.

Telegram Business accounts a bot manages on a user's behalf, and the stories it posts for them.

Mixed into Telegram through Methods. Every method is named exactly as the Bot API names it, takes exactly the fields the Bot API documents (use named arguments for the optional ones), and resolves with the hydrated result.

Tags
link
https://core.telegram.org/bots/api
since

v10.3

Table of Contents

Methods

deleteBusinessMessages()  : PromiseInterface<string|int, bool>
Delete messages on behalf of a business account. Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success.
deleteStory()  : PromiseInterface<string|int, bool>
Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success.
editStory()  : PromiseInterface<string|int, Story>
Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.
getBusinessAccountStarBalance()  : PromiseInterface<string|int, StarAmount>
Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success.
getBusinessConnection()  : PromiseInterface<string|int, BusinessConnection>
Use this method to get information about the connection of the bot with a business account.
postStory()  : PromiseInterface<string|int, Story>
Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.
readBusinessMessage()  : PromiseInterface<string|int, bool>
Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.
removeBusinessAccountProfilePhoto()  : PromiseInterface<string|int, bool>
Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.
repostStory()  : PromiseInterface<string|int, Story>
Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success.
setBusinessAccountBio()  : PromiseInterface<string|int, bool>
Changes the bio of a managed business account. Requires the can_change_bio business bot right.
setBusinessAccountName()  : PromiseInterface<string|int, bool>
Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success.
setBusinessAccountProfilePhoto()  : PromiseInterface<string|int, bool>
Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.
setBusinessAccountUsername()  : PromiseInterface<string|int, bool>
Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success.
transferBusinessAccountStars()  : PromiseInterface<string|int, bool>
Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success.

Methods

deleteBusinessMessages()

Delete messages on behalf of a business account. Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success.

public deleteBusinessMessages(string $business_connection_id, array<int, int> $message_ids) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection on behalf of which to delete the messages

$message_ids : array<int, int>

A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted.

Tags
link
https://core.telegram.org/bots/api#deletebusinessmessages
Return values
PromiseInterface<string|int, bool>

deleteStory()

Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success.

public deleteStory(string $business_connection_id, int $story_id) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$story_id : int

Unique identifier of the story to delete

Tags
link
https://core.telegram.org/bots/api#deletestory
Return values
PromiseInterface<string|int, bool>

editStory()

Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.

public editStory(string $business_connection_id, int $story_id, InputStoryContent|array<string|int, mixed> $content[, string|null $caption = null ][, string|null $parse_mode = null ][, array<int, MessageEntity|array<string|int, mixed>>|null $caption_entities = null ][, array<int, StoryArea|array<string|int, mixed>>|null $areas = null ]) : PromiseInterface<string|int, Story>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$story_id : int

Unique identifier of the story to edit

$content : InputStoryContent|array<string|int, mixed>

Content of the story

$caption : string|null = null

Optional. Caption of the story, 0-2048 characters after entities parsing

$parse_mode : string|null = null

Optional. Mode for parsing entities in the story caption. See formatting options for more details.

$caption_entities : array<int, MessageEntity|array<string|int, mixed>>|null = null

Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

$areas : array<int, StoryArea|array<string|int, mixed>>|null = null

Optional. A JSON-serialized list of clickable areas to be shown on the story

Tags
link
https://core.telegram.org/bots/api#editstory
Return values
PromiseInterface<string|int, Story>

getBusinessAccountStarBalance()

Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success.

public getBusinessAccountStarBalance(string $business_connection_id) : PromiseInterface<string|int, StarAmount>
Parameters
$business_connection_id : string

Unique identifier of the business connection

Tags
link
https://core.telegram.org/bots/api#getbusinessaccountstarbalance
Return values
PromiseInterface<string|int, StarAmount>

getBusinessConnection()

Use this method to get information about the connection of the bot with a business account.

public getBusinessConnection(string $business_connection_id) : PromiseInterface<string|int, BusinessConnection>

Returns a BusinessConnection object on success.

Parameters
$business_connection_id : string

Unique identifier of the business connection

Tags
link
https://core.telegram.org/bots/api#getbusinessconnection
Return values
PromiseInterface<string|int, BusinessConnection>

postStory()

Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.

public postStory(string $business_connection_id, InputStoryContent|array<string|int, mixed> $content, int $active_period[, string|null $caption = null ][, string|null $parse_mode = null ][, array<int, MessageEntity|array<string|int, mixed>>|null $caption_entities = null ][, array<int, StoryArea|array<string|int, mixed>>|null $areas = null ][, bool|null $post_to_chat_page = null ][, bool|null $protect_content = null ]) : PromiseInterface<string|int, Story>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$content : InputStoryContent|array<string|int, mixed>

Content of the story

$active_period : int

Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400

$caption : string|null = null

Optional. Caption of the story, 0-2048 characters after entities parsing

$parse_mode : string|null = null

Optional. Mode for parsing entities in the story caption. See formatting options for more details.

$caption_entities : array<int, MessageEntity|array<string|int, mixed>>|null = null

Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

$areas : array<int, StoryArea|array<string|int, mixed>>|null = null

Optional. A JSON-serialized list of clickable areas to be shown on the story

$post_to_chat_page : bool|null = null

Optional. Pass True to keep the story accessible after it expires

$protect_content : bool|null = null

Optional. Pass True if the content of the story must be protected from forwarding and screenshotting

Tags
link
https://core.telegram.org/bots/api#poststory
Return values
PromiseInterface<string|int, Story>

readBusinessMessage()

Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.

public readBusinessMessage(string $business_connection_id, int $chat_id, int $message_id) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection on behalf of which to read the message

$chat_id : int

Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.

$message_id : int

Unique identifier of the message to mark as read

Tags
link
https://core.telegram.org/bots/api#readbusinessmessage
Return values
PromiseInterface<string|int, bool>

removeBusinessAccountProfilePhoto()

Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.

public removeBusinessAccountProfilePhoto(string $business_connection_id[, bool|null $is_public = null ]) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$is_public : bool|null = null

Optional. Pass True to remove the public photo, which is visible even if the main photo is hidden by the business account's privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo.

Tags
link
https://core.telegram.org/bots/api#removebusinessaccountprofilephoto
Return values
PromiseInterface<string|int, bool>

repostStory()

Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success.

public repostStory(string $business_connection_id, int $from_chat_id, int $from_story_id, int $active_period[, bool|null $post_to_chat_page = null ][, bool|null $protect_content = null ]) : PromiseInterface<string|int, Story>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$from_chat_id : int

Unique identifier of the chat which posted the story that should be reposted

$from_story_id : int

Unique identifier of the story that should be reposted

$active_period : int

Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400

$post_to_chat_page : bool|null = null

Optional. Pass True to keep the story accessible after it expires

$protect_content : bool|null = null

Optional. Pass True if the content of the story must be protected from forwarding and screenshotting

Tags
link
https://core.telegram.org/bots/api#repoststory
Return values
PromiseInterface<string|int, Story>

setBusinessAccountBio()

Changes the bio of a managed business account. Requires the can_change_bio business bot right.

public setBusinessAccountBio(string $business_connection_id[, string|null $bio = null ]) : PromiseInterface<string|int, bool>

Returns True on success.

Parameters
$business_connection_id : string

Unique identifier of the business connection

$bio : string|null = null

Optional. The new value of the bio for the business account; 0-140 characters

Tags
link
https://core.telegram.org/bots/api#setbusinessaccountbio
Return values
PromiseInterface<string|int, bool>

setBusinessAccountName()

Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success.

public setBusinessAccountName(string $business_connection_id, string $first_name[, string|null $last_name = null ]) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$first_name : string

The new value of the first name for the business account; 1-64 characters

$last_name : string|null = null

Optional. The new value of the last name for the business account; 0-64 characters

Tags
link
https://core.telegram.org/bots/api#setbusinessaccountname
Return values
PromiseInterface<string|int, bool>

setBusinessAccountProfilePhoto()

Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.

public setBusinessAccountProfilePhoto(string $business_connection_id, InputProfilePhoto|array<string|int, mixed> $photo[, bool|null $is_public = null ]) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$photo : InputProfilePhoto|array<string|int, mixed>

The new profile photo to set

$is_public : bool|null = null

Optional. Pass True to set the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. An account can have only one public photo.

Tags
link
https://core.telegram.org/bots/api#setbusinessaccountprofilephoto
Return values
PromiseInterface<string|int, bool>

setBusinessAccountUsername()

Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success.

public setBusinessAccountUsername(string $business_connection_id[, string|null $username = null ]) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$username : string|null = null

Optional. The new value of the username for the business account; 0-32 characters

Tags
link
https://core.telegram.org/bots/api#setbusinessaccountusername
Return values
PromiseInterface<string|int, bool>

transferBusinessAccountStars()

Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success.

public transferBusinessAccountStars(string $business_connection_id, int $star_count) : PromiseInterface<string|int, bool>
Parameters
$business_connection_id : string

Unique identifier of the business connection

$star_count : int

Number of Telegram Stars to transfer; 1-10000

Tags
link
https://core.telegram.org/bots/api#transferbusinessaccountstars
Return values
PromiseInterface<string|int, bool>
On this page

Search results