Skip to main content

Chat

This object represents a chat.

πŸ“ Schema​

FieldTypeDescription
idintUnique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
typestringType of the chat, can be either β€œprivate”, β€œgroup” or β€œchannel”
titlestringOptional. Title, for channels and group chats
usernamestringOptional. Username, for private chats and channels if available
first_namestringOptional. First name of the other party in a private chat
last_namestringOptional. Last name of the other party in a private chat
photoChatPhotoOptional. Chat photo. Returned only in getChat.
NOTE

While the official Bale documentation mentions that the photo field is returned only by getChat, it is also possible to receive the photo field in webhook updates. This means that even when the official docs state otherwise, the API can return the photo in certain events.

βš™οΈ Get methods​

getId()​

Retrieves the ID of the chat.

$chatId = $chatObject->getId();

getType()​

Retrieves the type of the chat (e.g., "private", "group", "channel").

$chatType = $chatObject->getType();

getTitle()​

Retrieves the title of the chat (if available, typically for groups and channels).

$chatTitle = $chatObject->getTitle();

getUsername()​

Retrieves the username associated with the chat (if available, typically for private chats and channels).

$chatUsername = $chatObject->getUsername();

getFirstName()​

Retrieves the first name of the other party in the chat (if available, typically for private chats).

$userFirstName = $userObject->getFirstName();

getLastName()​

Retrieves the last name of the other party in the chat (if available).

$userLastName = $userObject->getLastName();

getPhoto()​

Retrieves the photo of the chat (if available). This can be accessed only for certain types of chats (e.g., group, channel).

$chatPhoto = $chatObject->getPhoto();

βž• More​

tip

For further information, refer to the official Bale documentation for more details.