DEF STUDIO srl

Need help with Laravel and web development?

Hire one of our experts for your projects.

We build tailored products, websites and platforms — with care for UX, performance and maintainability.

Booking open for Q4 — limited slots

You are seeing the documentation for version 1, but the last version for this package is v1. Click here to go to the last version.

Incoming Data

Data obtained from manual polling or webhooks is available through a set of DTO, under the DefStudio\Telegraph\DTO\ namespace:

TelegramUpdate

contains incoming data (a message or a callback query)

  • ->id() incoming update_id
  • ->message() (optional) an instance of Message
  • ->messageReaction() (optional) an instance of Reaction
  • ->poll() (optional) an instance of Poll
  • ->pollAnswer() (optional) an instance of PollAnswer
  • ->callbackQuery() (optional) an instance of CallbackQuery
  • ->preCheckoutQuery() (optional) an instance of PreCheckoutQuery
  • ->chatMemberUpdate() (optional) a chat member's status was updated in a chat. An instance of ChatMemberUpdate
  • ->botChatStatusChange() (optional) the bot's chat member status was updated in a chat. An instance of ChatMemberUpdate

Chat

  • ->id() chat_id
  • ->type() the chat's type (private, group, supergroup or channel)
  • ->title() the chat's title

Message

  • ->id() incoming message_id
  • ->businessConnectionId() unique identifier of a business connection
  • ->mediaGroupId() unique identifier of a media message group
  • ->messageThreadId() unique identifier of a message thread
  • ->date() a CarbonInterface holding the message sent date
  • ->editDate() a CarbonInterface holding the message last edit date
  • ->text() the message text
  • ->protected() a boolean flag that states the message is protected from forwarding and download
  • ->from() (optional) an instance of User holding data about the message's sender
  • ->forwardedFrom() (optional) an instance of User holding data about a forwarded message's original sender
  • ->chat() (optional) an instance of Chat holding data about the chat to which the message belongs to
  • ->keyboard() (optional) an instance of DefStudio\Telegraph\Keyboard\Keyboard holding the message inline keyboard
  • ->replyToMessage() (optional) an instance of the original Message that the current message is replying
  • ->photos() (optional) a collection of Photo holding data about the contained image resolutions
  • ->animation() (optional) an instance of Photo holding data about the contained animation
  • ->audio() (optional) an instance of Audio holding data about the contained audio
  • ->game() (optional) an instance of Game holding data about the contained game
  • ->quote() (optional) an instance of Quote holding data about the contained quote
  • ->document() (optional) an instance of Document holding data about the contained document
  • ->video() (optional) an instance of Video holding data about the contained video
  • ->videoNote() (optional) an instance of VideoNote holding data about the contained video note
  • ->location() (optional) an instance of Location holding data about the contained location
  • ->contact() (optional) an instance of Contact holding data about the contained contact data
  • ->giveaway() (optional) an instance of Giveaway holding data about the contained giveaway data
  • ->voice() (optional) an instance of Voice holding data about the contained voical message
  • ->sticker() (optional) an instance of Sticker holding data about the contained sticker
  • ->poll() (optional) an instance of Poll holding data about the contained poll
  • ->venue() (optional) an instance of Venue holding data about the contained sticker
  • ->entities() (optional) a collection of Entity holding data about the contained entity
  • ->invoice() (optional) an instance of Invoice holding data about the contained invoice
  • ->successfulPayment() (optional) an instance of SuccessfulPayment holding data about the successful payment with information about the payment
  • ->refundedPayment() (optional) an instance of RefundedPayment holding data about the refunded payment with information about the payment
  • ->newChatMembers() a collection of User holding the list of users that joined the group/supergroup
  • ->leftChatMember() (optional) an instance of User holding data about the user that left the group/supergroup
  • ->webAppData() (optional) incoming data from sendData method of telegram WebApp
  • ->writeAccessAllowed() (optional) an instance of WriteAccessAllowed holding data about the contained write access allowed data
  • ->migrateToChatId() (optional) the group has been migrated to a supergroup with the specified identifier

CallbackQuery

  • ->id() incoming callback_query_id
  • ->from() an instance of the User that triggered the callback query
  • ->message() (optional) an instance of the Message that triggered the callback query
  • ->data() an Illuminate\Support\Collection that holds the key/value pairs of the callback query data

PreCheckoutQuery

ore information on the payment page.

ChatMember

Represents a chat member that owns the chat and has all administrator privileges. For a complete list of privileges consult https://core.telegram.org/bots/api#chatmember

  • ->status() the member's status in the chat
  • ->user() an instance of the User
  • ->isAnonymous() true, if the user's presence in the chat is hidden
  • ->isMember() true, if the user is a member of the chat at the moment of the request
  • ->customTitle() (optional) custom title for this user
  • ->untilDate() (optional) date when the user's subscription will expire; OR: Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted forever

ChatMemberUpdate

The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user

  • ->chat() an instance of Chat between User and Bot
  • ->from() an instance of User performer of the action, which resulted in the change
  • ->date() date the change was done in Unix time
  • ->previous() previous information about the chat member
  • ->new() new information about the chat member

Reaction

  • ->id() incoming message_id
  • ->chat() an instance of Chat holding data about the chat to which the message belongs to
  • ->actorChat() (optional) an instance of Chat holding data about the chat to which the chat on behalf of which the reaction was changed, if the user is anonymous
  • ->from() (optional) an instance of User holding data about the message's sender
  • ->oldReaction() a collection of ReactionType holding data about the contained reaction type resolutions
  • ->newReaction() a collection of ReactionType holding data about the contained reaction type resolutions
  • ->date() a CarbonInterface holding the message sent

ReactionType

  • ->type() type of the reaction
  • ->emoji() reaction emoji
  • ->customEmojiId() (optional) custom emoji identifier

User

  • ->id() user ID
  • ->isBot() marks if the user is a bot or a real user
  • ->firstName() user's first name
  • ->lastName() user's last name
  • ->userName() user's username
  • ->languageCode() user's language code
  • ->isPremium() user's premium status

Invoice

More information on the payment page.

Game

More information on the game page.

Quote

  • ->text() text of the quoted part of a message that is replied to by the given message
  • ->entities() (optional) a collection of Entity holding data about the contained entity
  • ->position() approximate quote position in the original message
  • ->isManual() true, if the quote was chosen manually by the message sender. Otherwise by the serve

Audio

  • ->id() file ID
  • ->duration() audio duration
  • ->title() (optional) audio title
  • ->filename() (optional) audio file name
  • ->mimeType() (optional) audio MIME type
  • ->filesize() (optional) audio file size in Bytes
  • ->thumbnail() (optional) an instance of the Photo that holds data about the thumbnail

Animation

  • ->id() file ID
  • ->width() animation width
  • ->height() animation height
  • ->duration() animation duration
  • ->filename() (optional) animation file name
  • ->mimeType() (optional) animation MIME type
  • ->filesize() (optional) animation file size in Bytes
  • ->thumbnail() (optional) an instance of the Photo that holds data about the thumbnail

Document

  • ->id() file ID
  • ->filename() (optional) document file name
  • ->mimeType() (optional) document MIME type
  • ->filesize() (optional) document file size in Bytes
  • ->thumbnail() (optional) an instance of the Photo that holds data about the thumbnail

Photo

  • ->id() file ID
  • ->width() photo width
  • ->height() photo height
  • ->filesize() (optional) photo file size in Bytes

Video

  • ->id() file ID
  • ->width() video width
  • ->height() video height
  • ->duration() video duration
  • ->filename() (optional) video file name
  • ->mimeType() (optional) video MIME type
  • ->filesize() (optional) video file size in Bytes
  • ->thumbnail() (optional) an instance of the Photo that holds data about the thumbnail

VideoNote

  • ->id() file ID
  • ->length() video note width
  • ->duration() video note duration
  • ->filesize() (optional) video note file size in Bytes
  • ->thumbnail() (optional) an instance of the Photo that holds data about the thumbnail

Location

  • ->latitude() location latitude
  • ->longitude() location longitude
  • ->accuracy() (optional) location horizontal accuracy

Contact

  • ->phoneNumber() contact's phone number
  • ->firstName() contact's first name
  • ->lastName() (optional) contact's last name
  • ->userId() (optional) contact's telegram user ID
  • ->vcard() (optional) contact's vCard

Giveaway

  • ->chats() the list of chats which the user must join to participate in the giveaway
  • ->winnersSelectionDate() point in time (Unix timestamp) when winners of the giveaway will be selected
  • ->winnerCount() the number of users which are supposed to be selected as winners of the giveaway
  • ->onlyNewMembers() (optional) true, if only users who join the chats after the giveaway started should be eligible to win
  • ->hasPublicWinners() (optional) true, if the list of giveaway winners will be visible to everyone
  • ->prizeDescription() (optional) description of additional giveaway prize
  • ->countryCodes() (optional) the countries from which eligible users for the giveaway must come
  • ->prizeStarCount() (optional) the number of Telegram Stars to be split between giveaway winners
  • ->premiumSubscriptionMonthCount() (optional) the number of months the Telegram Premium subscription won from the giveaway will be active for

Voice

  • ->id() file ID
  • ->duration() audio duration
  • ->mimeType() (optional) audio MIME type
  • ->filesize() (optional) audio file size in Bytes

Sticker

  • ->id() file ID
  • ->type() sticker type (consult https://core.telegram.org/bots/api#stickers for available types)
  • ->width() sticker width
  • ->height() sticker height
  • ->isAnimated() true, if the sticker is animated
  • ->isVideo() true, if the sticker is a video sticker
  • ->emoji() (optional) emoji associated with the sticker
  • ->filesize() (optional) sticker file size in Bytes
  • ->thumbnail() (optional) an instance of the Photo that holds data about the thumbnail

Poll

  • ->id() Poll ID
  • ->question() Poll question
  • ->questionEntities() (optional) a collection of Entity holding data about the contained entity
  • ->options() a collection of PollOption holding data about the contained poll option
  • ->totalVoterCount() Total number of users that voted in the poll
  • ->isClosed() True, if the poll is closed
  • ->isAnonymous() True, if the poll is anonymous
  • ->type() Poll type
  • ->allowsMultipleAnswers() True, if the poll allows multiple answers

PollOption

  • ->text() Option text
  • ->textEntities() (optional) a collection of Entity holding data about the contained entity
  • ->voterCount() Number of users that voted for this option

Venue

  • ->location() Venue location. Can't be a live location
  • ->title() Name of the venue
  • ->address() Address of the venue
  • ->foursquareId() (optional) Foursquare identifier of the venue
  • ->foursquareType() (optional) Foursquare type of the venue
  • ->googlePlaceId() (optional) Google Places identifier of the venue
  • ->googlePlaceType() (optional) Google Places type of the venue (consult https://developers.google.com/maps/documentation/places/web-service/supported_types)

Entity

  • ->type() type of the entity
  • ->offset() offset in UTF-16 code units to the start of the entity
  • ->length() length of the entity in utf-16 code units
  • ->url() (optional) for “text_link” only, URL that will be opened after user taps on the text
  • ->user() (optional) for “text_mention” only, the mentioned User
  • ->language() (optional) for “pre” only, the programming language of the entity text
  • ->customEmojiId() (optional) for “custom_emoji” only, unique identifier of the custom emoji

WriteAccessAllowed

  • ->fromRequest() true, if the access was granted after the user accepted an explicit request from a Web App sent by the method requestWriteAccess
  • ->fromWebApp() a helper method that returns true if the access was granted when the Web App was launched from a link
  • ->webAppName() Name of the Web App, if the access was granted when the Web App was launched from a link
  • ->fromAttachmentMenu() true, if the access was granted when the bot was added to the attachment or side menu
  • ->isAllowed() true, if the user granted the bot write access to their account

InlineQuery

  • ->id() inline query id
  • ->query() the query typed by the user after the bot's name
  • ->from() an instance of User holding data about the user that started the query
  • ->offset() offset of the results to be returned, can be controlled by the bot
  • ->chat_type() type of the chat, from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat
  • ->location() (optional) an instance of Location containing sender location, only for bots that request user location.

InlineQueryResultGif

This is a DTO for outgoing data, wraps info about the Gif result returned to the user

InlineQueryResultPhoto

This is a DTO for outgoing data, wraps info about the Photo result returned to the user

InlineQueryResultContact

This is a DTO for outgoing data, wraps info about the Contact result returned to the user

InlineQueryResultArticle

This is a DTO for outgoing data, wraps info about the Article result returned to the user

InlineQueryResultMpeg4Gif

This is a DTO for outgoing data, wraps info about the Mpeg4Gif result returned to the user

InlineQueryResultVideo

This is a DTO for outgoing data, wraps info about the Video result returned to the user

InlineQueryResultAudio

This is a DTO for outgoing data, wraps info about the Audio result returned to the user

InlineQueryResultVoice

This is a DTO for outgoing data, wraps info about the Voice result returned to the user

InlineQueryResultDocument

This is a DTO for outgoing data, wraps info about the Document result returned to the user

InlineQueryResultLocation

This is a DTO for outgoing data, wraps info about the Location result returned to the user

InlineQueryResultVenue

This is a DTO for outgoing data, wraps info about the Venue result returned to the user

ChatInviteLink

represents an invite link for a chat.

  • ->inviteLink() the invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with “…”
  • ->creator() an instance of User represents a creator of the link
  • ->createsJoinRequest() true, if users joining the chat via the link need to be approved by chat administrators
  • ->isPrimary() true, if the link is primary
  • ->isRevoked() true, if the link is revoked
  • ->name() (optional) invite link name
  • ->expireDate() (optional) point in time (Unix timestamp) when the link will expire or has been expired
  • ->memberLimit() (optional) The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
  • ->pendingJoinRequestsCount() (optional) number of pending join requests created using this link
  • ->subscriptionPeriod() (optional) the number of seconds the subscription will be active for before the next payment
  • ->subscriptionPrice() (optional) the amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link

ChatJoinRequest

represents a join request sent to a chat.

  • ->chat() an instance of Chat to which the request was sent
  • ->from() an instance of User that sent the join request
  • ->userChatId() identifier of a private chat with the user who sent the join request. 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 64-bit integer or double-precision float type are safe for storing this identifier. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user.
  • ->date() date the request was sent in Unix time
  • ->bio() (optional) bio of the user
  • ->inviteLink() (optional) an instance of ChatInviteLink that was used by the user to send the join request

PollAnswer

represents an answer of a user in a non-anonymous poll.

  • ->pollId() poll identifier
  • ->voterChat() an instance of Chat that changed the answer to the poll, if the voter is anonymous
  • ->user() an instance of User that changed the answer to the poll, if the voter isn't anonymous
  • ->optionIds() 0-based identifiers of chosen answer options. May be empty if the vote was retracted.

OrderInfo

represents information about an order. More information on the payment page.

ShippingAddress

represents a shipping address. More information on the payment page.

SuccessfulPayment

represents a successful payment. More information on the payment page.

RefundedPayment

represents a refunded payment. More information on the payment page.

Suggest a change
Last updated 29 May 2026