telegram
Module telegram
API
Definitions
ballerinax/telegram Ballerina library
Ballerina Telegram connector
The Telegram Bot API lets bots send and receive messages, manage chats, answer inline/callback queries, and more, over a simple HTTPS REST API.
The ballerinax/telegram package provides both:
- A client (
telegram:Client) covering chat management, callback/inline query answers, file metadata/download, messaging (text, photos, videos, documents, audio, animations, stickers, locations, media groups, message/rich-message drafts), and webhook management. - A webhook listener (
telegram:Listener) for the 9 update types Telegram delivers most commonly (message,edited_message,channel_post,edited_channel_post,callback_query,inline_query,poll,pre_checkout_query,shipping_query), authenticated via theX-Telegram-Bot-Api-Secret-Tokenheader. Each handler is optional — implement only the ones your bot needs.
The client and listener are hand-written directly against the official Bot API reference — not generated from an OpenAPI spec (Telegram publishes none). The client covers 27 messaging/chat/callback/file actions plus 3 webhook-management calls (setWebhook/deleteWebhook/getWebhookInfo), and the listener handles 9 update types.
Setup guide
Step 1: Create a bot and get a token
- Open a chat with @BotFather on Telegram.
- Send
/newbotand follow the prompts to choose a display name and a unique@username(must end inbot). - BotFather replies with a bot token (e.g.
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11) — use this astokenintelegram:ConnectionConfig.
Unlike most APIs, Telegram doesn't use a header or query parameter for auth — the token is embedded directly in every request's URL path (https://api.telegram.org/bot<token>/<method>); the client and listener handle this automatically.
Treat the token like a password: anyone who has it can control the bot. Regenerate it via BotFather's /revoke command if it leaks.
Step 2: Get a chat ID (client)
Most Client operations need a chatId — the numeric ID of the chat/group/channel to act on:
- Private chat: message your bot from your own account, then call
getUpdates(https://api.telegram.org/bot<token>/getUpdates) and readmessage.chat.idfrom the response. Forwarding a message to @get_id_bot also works. - Group/supergroup: add the bot to the group, send any message, then use the same
getUpdatesapproach — group chat IDs are negative numbers. - Channel: add the bot as an administrator, then use the channel's
@username(e.g."@my_channel") directly aschatIdinstead of a numeric ID.
Step 3: Configure a webhook (listener)
The telegram:Listener needs updates pushed to it — Telegram supports only one webhook URL per bot, and it must be reachable over HTTPS.
Expose the listener's port publicly first (a tunnel such as ngrok http 8090 is the usual approach during development), then start the listener with the bot token and that public URL — it registers its own webhook automatically:
listener telegram:Listener telegramListener = new (8090, token = "<BOT_TOKEN>", publicUrl = "https://<TUNNEL_HOST>/");
No separate Client->setWebhook call, and no secretToken/secret_token anywhere — the listener derives the secret token from <BOT_TOKEN> via deriveSecretToken and registers publicUrl as the webhook itself as soon as it starts. By default, allowed_updates is set to exactly the 9 update types this connector's Listener supports (message, edited_message, channel_post, edited_channel_post, callback_query, inline_query, poll, pre_checkout_query, shipping_query) — anything else Telegram would otherwise deliver is outside this connector's TelegramService interface and would be logged and dropped anyway.
If you'd rather register the webhook yourself (e.g. from a separate process, or to control exactly when it happens), omit publicUrl and call Client->setWebhook explicitly instead:
listener telegram:Listener telegramListener = new (8090, token = "<BOT_TOKEN>"); ... telegram:Client telegramClient = check new ({token: "<BOT_TOKEN>"}); _ = check telegramClient->setWebhook("https://<TUNNEL_HOST>/");
Both still independently derive the same secret token from <BOT_TOKEN>, so they agree with no coordination. And if you'd rather manage the secret token yourself entirely (e.g. to rotate it independently of the bot token), pass secretToken/secret_token explicitly instead of token — any string matching [A-Za-z0-9_-]{1,256} — it takes precedence over the derived default on both the listener and setWebhook.
Telegram then POSTs each update to your URL, carrying header X-Telegram-Bot-Api-Secret-Token: <SECRET_TOKEN> — the listener rejects (401) any request where this doesn't match exactly, so ListenerConfig always requires one of secretToken/token, with no bypass.
To stop receiving updates, call Client->deleteWebhook(). To check what's currently registered (e.g. to debug a webhook that isn't firing), call Client->getWebhookInfo().
Quickstart
The connector has two independent entry points — a client for calling the Bot API and a listener for handling webhook updates. Follow the track that matches your use case.
Client
Use this if your app only needs to send messages or manage chats/files (no update handling).
Step 1: Import the module
import ballerina/io; import ballerinax/telegram;
Step 2: Initialize a Telegram client
configurable string token = ?; configurable string chatId = ?; telegram:Client telegramClient = check new ({token});
Step 3: Invoke connector operations
telegram:Message sent = check telegramClient->sendMessage(chatId, "Hello from Ballerina!"); io:println(sent.message_id);
Send a photo, get chat info, or answer a callback query the same way:
telegram:Message photo = check telegramClient->sendPhoto(chatId, "https://example.com/photo.jpg"); telegram:ChatFullInfo chat = check telegramClient->getChat(chatId); _ = check telegramClient->answerCallbackQuery(callbackQueryId, text = "Got it!");
Step 4: Run the Ballerina application
bal run
Listener
Use this if your app needs to handle incoming messages, callback/inline queries, or other webhook updates.
Step 1: Import the module
import ballerinax/telegram;
Step 2: Initialize a Telegram listener
listener telegram:Listener telegramListener = new (8090, secretToken = "my-secret-token");
Step 3: Implement the service
telegram:TelegramService has nine possible handlers, one per supported update type, and all of them are optional — implement only the ones you need. An update outside this set (or routed to a handler you didn't declare) is logged and dropped, not delivered anywhere. Declaring a handler under any other name, with the wrong parameter type, or without the remote qualifier is a compile error, caught by this connector's compiler plugin.
service telegram:TelegramService on telegramListener { remote function onMessage(telegram:Message message) returns error? { // handle an incoming message: message.text } }
The other eight handlers — onEditedMessage, onChannelPost, onEditedChannelPost, onCallbackQuery, onInlineQuery, onPoll, onPreCheckoutQuery, onShippingQuery — each take the corresponding Telegram Bot API type directly (Message, CallbackQuery, InlineQuery, Poll, PreCheckoutQuery, or ShippingQuery), matching the field types on Telegram's own Update object; add whichever ones your bot needs. See examples/approval-bot for a complete implementation of all nine, including an approve/decline flow built on sendApprovalMessage.
Step 4: Run the Ballerina application
bal run
Register the listener's public URL as the webhook (see the setup guide above) to start receiving updates.
Examples
The telegram connector provides practical examples illustrating usage in various scenarios. Explore these examples.
- Send a Telegram message — send a text message, a photo by URL, and an uploaded document via the client.
- Run a Telegram approval bot — handle all nine update types over the listener, including an approve/decline flow.
Issues and projects
The Issues and Projects tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library parent repository.
This repository only contains the source code for the package.
Build from the source
Prerequisites
-
Download and install Java SE Development Kit (JDK) version 21. You can download it from either of the following sources:
Note: After installation, remember to set the
JAVA_HOMEenvironment variable to the directory where JDK was installed. -
Download and install Ballerina Swan Lake 2201.12.x.
-
Generate a GitHub access token with read package permissions, then configure these environment variables:
export packageUser=<Your GitHub Username> export packagePAT=<GitHub Personal Access Token>
Build options
Execute the following commands to build from the source:
-
To build the package:
./gradlew clean build -
To run the tests:
./gradlew clean test -
To run a group of tests:
./gradlew clean test -Pgroups=<test_group_names> -
To build the package without tests:
./gradlew clean build -x test -
To debug the package with a remote debugger:
./gradlew clean build -Pdebug=<port> -
To debug with the Ballerina language:
./gradlew clean build -PbalJavaDebug=<port> -
Publish the generated artifacts to the local Ballerina central repository:
./gradlew clean build -PpublishToLocalCentral=true -
Publish the generated artifacts to the Ballerina central repository:
./gradlew clean build -PpublishToCentral=true
Repository structure
| Directory | Contents |
|---|---|
ballerina/ | The Ballerina connector + webhook listener source and tests |
native/ | Java runtime support for dispatching optional TelegramService handlers |
compiler-plugin/ | Compile-time validation of TelegramService handler declarations |
examples/ | Runnable usage examples |
build-config/ | Build resources (the Ballerina.toml/CompilerPlugin.toml version templates) |
Contribute to Ballerina
As an open-source project, Ballerina welcomes contributions from the community.
For more information, go to the contribution guidelines.
Code of conduct
All the contributors are encouraged to read the Ballerina Code of Conduct.
Useful links
- For more information go to the
telegrampackage. - For example demonstrations of the usage, go to Ballerina By Examples.
- Chat live with us via our Discord server.
- Post all technical questions on Stack Overflow with the #ballerina tag.
Functions
deriveSecretToken
Deterministically derives a webhook secret token from a bot token, suitable for both
ListenerConfig.secretToken and Client->setWebhook's secret_token option — an alternative to
inventing and threading a random secret through both sides of a webhook setup by hand.
The same token always derives the same secret token, so the Listener (verifying inbound
updates) and the Client (registering the webhook) can each compute it independently, and it
stays stable across restarts — unlike a freshly-generated random secret, which would desync from
whatever Telegram already has registered the moment the process restarts.
string secretToken = check telegram:deriveSecretToken(token); listener telegram:Listener telegramListener = new (8090, secretToken = secretToken); _ = check telegramClient->setWebhook(webhookUrl, secret_token = secretToken);
Parameters
- token string - The bot token to derive the secret from, e.g.
ConnectionConfig.token
Clients
telegram: Client
Client for the Telegram Bot API, covering chat management, callback/inline query answers, file metadata/download, messaging (text, media, locations, drafts, and rich messages), and webhook management.
Constructor
Initializes the connector.
init (ConnectionConfig config, string serviceUrl)- config ConnectionConfig - The connection configuration, including the bot token
- serviceUrl string DEFAULT_BASE_URL - The Telegram Bot API base URL
getChat
function getChat(int|string chatId) returns ChatFullInfo|ErrorGets up-to-date information about a chat.
Parameters
Return Type
- ChatFullInfo|Error - The chat's full details, or an
Error
getChatAdministrators
function getChatAdministrators(int|string chatId) returns ChatMember[]|ErrorGets the administrators of a chat.
Parameters
Return Type
- ChatMember[]|Error - The chat's administrators, or an
Error
getChatMember
function getChatMember(int|string chatId, int userId) returns ChatMember|ErrorGets information about one member of a chat.
Parameters
- userId int - The target user's ID
Return Type
- ChatMember|Error - The chat member's details, or an
Error
leaveChat
Makes the bot leave a chat.
Parameters
Return Type
- Error? - An
Errorif the request failed, otherwise()
setChatDescription
Sets a group, supergroup, or channel's description.
Parameters
- description string - The new description, 0-255 characters
Return Type
- Error? - An
Errorif the request failed, otherwise()
setChatTitle
Sets a chat's title.
Parameters
- title string - The new title, 1-255 characters
Return Type
- Error? - An
Errorif the request failed, otherwise()
answerCallbackQuery
function answerCallbackQuery(string callbackQueryId, *AnswerCallbackQueryOptions options) returns Error?Answers a callback query sent from an inline keyboard button press.
Parameters
- callbackQueryId string - The callback query's ID, from
CallbackQuery.id
- options *AnswerCallbackQueryOptions - Additional fields, e.g.
text/show_alertto show the user a notification
Return Type
- Error? - An
Errorif the request failed, otherwise()
answerInlineQuery
function answerInlineQuery(string inlineQueryId, InlineQueryResult[] results, *AnswerInlineQueryOptions options) returns Error?Answers an inline query.
Parameters
- inlineQueryId string - The inline query's ID, from
InlineQuery.id
- results InlineQueryResult[] - The results to show, up to 50
- options *AnswerInlineQueryOptions - Additional fields
Return Type
- Error? - An
Errorif the request failed, otherwise()
getFile
Gets a file's metadata, including the path used to download its bytes.
Parameters
- fileId string - The file's identifier
downloadFile
Downloads a file's raw bytes. Resolves the file's file_path (via getFile) and then fetches
it from the same host the Bot API is served from.
Parameters
- fileId string - The file's identifier
Return Type
- byte[]|Error - The file's raw bytes, or an
Error
setWebhook
function setWebhook(string url, *SetWebhookOptions options) returns Error?Registers a webhook URL for Telegram to push updates to.
Parameters
- url string - The HTTPS URL to deliver updates to
- options *SetWebhookOptions - Additional fields;
allowed_updatesdefaults to exactly the 9 update types this connector'sListenersupports.secret_tokendefaults toderiveSecretToken(token)(the same bot token thisClientwas created with), so aListenercreated withtokenset instead ofsecretTokenlands on the same value automatically — passsecret_tokenexplicitly to opt out
Return Type
- Error? - An
Errorif the request failed, otherwise()
deleteWebhook
Removes the currently registered webhook.
Parameters
- dropPendingUpdates boolean (default false) - Whether to discard any updates that were queued for delivery
Return Type
- Error? - An
Errorif the request failed, otherwise()
getWebhookInfo
function getWebhookInfo() returns WebhookInfo|ErrorGets the currently registered webhook's status.
Return Type
- WebhookInfo|Error - The webhook's status, or an
Error
deleteMessage
Deletes a message.
Parameters
- messageId int - The message's ID
Return Type
- Error? - An
Errorif the request failed, otherwise()
editMessageText
function editMessageText(string text, int|string? chatId, int? messageId, string? inlineMessageId, *EditMessageTextOptions options) returns Message|Error?Edits a text message the bot previously sent, or the text of an inline message.
Parameters
- text string - The new message text
- messageId int? (default ()) - The message's ID; required together with
chatId
- inlineMessageId string? (default ()) - An inline message's ID; mutually exclusive with
chatId/messageId
- options *EditMessageTextOptions - Additional fields
Return Type
pinChatMessage
function pinChatMessage(int|string chatId, int messageId, boolean disableNotification) returns Error?Pins a message in a chat.
Parameters
- messageId int - The message's ID
- disableNotification boolean (default false) - Whether to pin silently, without notifying chat members
Return Type
- Error? - An
Errorif the request failed, otherwise()
unpinChatMessage
Unpins a message in a chat.
Parameters
- messageId int? (default ()) - The pinned message's ID; unpins the most recent pinned message if omitted
Return Type
- Error? - An
Errorif the request failed, otherwise()
sendChatAction
function sendChatAction(int|string chatId, ChatAction action) returns Error?Shows a short-lived chat action indicator (e.g. "typing...") to chat members.
Parameters
- action ChatAction - The action to show; expires after ~5 seconds, or on the next sent message
Return Type
- Error? - An
Errorif the request failed, otherwise()
sendLocation
function sendLocation(int|string chatId, decimal latitude, decimal longitude, *SendLocationOptions options) returns Message|ErrorSends a point on the map.
Parameters
- latitude decimal - The location's latitude
- longitude decimal - The location's longitude
- options *SendLocationOptions - Additional fields
sendAnimation
function sendAnimation(int|string chatId, string|byte[] animation, *SendAnimationOptions options) returns Message|ErrorSends an animation (GIF or soundless MP4).
Parameters
- animation string|byte[] - A
file_id, an HTTP URL, or the raw file bytes to upload
- options *SendAnimationOptions - Additional fields
sendAudio
function sendAudio(int|string chatId, string|byte[] audio, *SendAudioOptions options) returns Message|ErrorSends an audio file.
Parameters
- audio string|byte[] - A
file_id, an HTTP URL, or the raw file bytes to upload
- options *SendAudioOptions - Additional fields
sendDocument
function sendDocument(int|string chatId, string|byte[] document, *SendDocumentOptions options) returns Message|ErrorSends a general file.
Parameters
- document string|byte[] - A
file_id, an HTTP URL, or the raw file bytes to upload
- options *SendDocumentOptions - Additional fields
sendPhoto
function sendPhoto(int|string chatId, string|byte[] photo, *SendPhotoOptions options) returns Message|ErrorSends a photo.
Parameters
- photo string|byte[] - A
file_id, an HTTP URL, or the raw file bytes to upload
- options *SendPhotoOptions - Additional fields
sendSticker
function sendSticker(int|string chatId, string|byte[] sticker, *SendStickerOptions options) returns Message|ErrorSends a sticker. Telegram stickers have no caption.
Parameters
- sticker string|byte[] - A
file_id, an HTTP URL, or the raw file bytes to upload
- options *SendStickerOptions - Additional fields
sendVideo
function sendVideo(int|string chatId, string|byte[] video, *SendVideoOptions options) returns Message|ErrorSends a video.
Parameters
- video string|byte[] - A
file_id, an HTTP URL, or the raw file bytes to upload
- options *SendVideoOptions - Additional fields
sendMessage
function sendMessage(int|string chatId, string text, *SendMessageOptions options) returns Message|ErrorSends a text message.
sendMediaGroup
function sendMediaGroup(int|string chatId, InputMedia[] media, *SendMediaGroupOptions options) returns Message[]|ErrorSends a group of photos, videos, documents, or audio files as an album.
Parameters
- media InputMedia[] - The media items to send, 2-10 items;
file_id/URL strings only (raw-byte uploads via Telegram'sattach://convention are not yet supported)
- options *SendMediaGroupOptions - Additional fields
sendMessageDraft
function sendMessageDraft(int|string chatId, int draftId, *SendMessageDraftOptions options) returns Message|ErrorStreams a partial message to the same message bubble, identified by draftId. Introduced in
Bot API 9.3 (Dec 2025); see the connector's flagged risks before relying on this in production.
Parameters
- draftId int - A non-zero ID; successive calls with the same ID update the same message bubble
- options *SendMessageDraftOptions - Additional fields
sendRichMessage
function sendRichMessage(int|string chatId, RichMessage richMessage, *SendRichMessageOptions options) returns Message|ErrorSends a message with structured rich-text formatting. Introduced in Bot API 10.1 (June 2026); see the connector's flagged risks before relying on this in production.
Parameters
- richMessage RichMessage - The rich message content, in Markdown or HTML
- options *SendRichMessageOptions - Additional fields
sendRichMessageDraft
function sendRichMessageDraft(int|string chatId, int draftId, RichMessage richMessage, int? messageThreadId) returns Message|ErrorStreams a partial rich message to the same message bubble, identified by draftId.
Introduced in Bot API 10.1 (June 2026); see the connector's flagged risks before relying on
this in production.
Parameters
- draftId int - A non-zero ID; successive calls with the same ID update the same message bubble
- richMessage RichMessage - The rich message content, in Markdown or HTML
- messageThreadId int? (default ()) - The forum topic to post the draft in, if any
sendApprovalMessage
function sendApprovalMessage(int|string chatId, string text, ApprovalButton approve, ApprovalButton? decline, *ApprovalMessageOptions options) returns Message|ErrorSends a prompt with approve/decline inline-keyboard buttons. This is a client-side
convenience wrapper around sendMessage; the caller observes which button was pressed via the
Listener's onCallbackQuery handler, matching on approve.callback_data/
decline.callback_data.
Parameters
- text string - The prompt text
- approve ApprovalButton - The approve button's label and
callback_data
- decline ApprovalButton? (default ()) - The decline button's label and
callback_data, if a decline option is wanted
- options *ApprovalMessageOptions - Additional fields
Service types
telegram: TelegramService
The service object a consumer implements to handle Telegram webhook updates. Attach an
implementation to a Listener to receive updates.
TelegramService declares no remote methods of its own — implement only the handlers you need;
an unimplemented handler is simply not invoked. Declaring a remote function under any other
name, with the wrong parameter type, or without the remote qualifier is a compile error (see
this connector's compiler plugin). There are nine supported handlers, one per supported update
type:
remote function onMessage(Message message) returns error?;— a new incoming message.remote function onEditedMessage(Message editedMessage) returns error?;— a message the bot knows about was edited.remote function onChannelPost(Message channelPost) returns error?;— a new channel post.remote function onEditedChannelPost(Message editedChannelPost) returns error?;— a channel post the bot knows about was edited.remote function onCallbackQuery(CallbackQuery callbackQuery) returns error?;— an inline keyboard button press.remote function onInlineQuery(InlineQuery inlineQuery) returns error?;— a new inline query.remote function onPoll(Poll poll) returns error?;— a poll's state changed.remote function onPreCheckoutQuery(PreCheckoutQuery preCheckoutQuery) returns error?;— a new pre-checkout query.remote function onShippingQuery(ShippingQuery shippingQuery) returns error?;— a new shipping query.
An update outside this set (e.g. poll_answer, my_chat_member, chat_member,
chat_join_request, business-account events) is logged and dropped rather than delivered to a
handler.
Listeners
telegram: Listener
Listener for Telegram Bot API webhook updates. It wraps an http:Listener, authenticates each
update against a caller-chosen secret token (X-Telegram-Bot-Api-Secret-Token), and dispatches
the 9 supported update types to an attached TelegramService.
listener telegram:Listener telegramListener = new (8090, token = "<BOT_TOKEN>", publicUrl = "https://<PUBLIC_HOST>/"); service telegram:TelegramService on telegramListener { remote function onMessage(telegram:Message message) returns error? { // handle an incoming message: message.text } // ... plus any of the other eight (optional) handlers this bot needs }
Passing publicUrl (alongside token) registers this listener's webhook automatically when it
starts — no separate Client->setWebhook call needed.
Constructor
Initializes the webhook listener.
init (int|Listener listenTo, *ListenerConfig config)- config *ListenerConfig - The listener configuration; requires either
secretTokenortoken
attach
function attach(TelegramService telegramService, string[]|string? name) returns Error?Attaches a TelegramService implementation to the listener.
Parameters
- telegramService TelegramService - The service that handles webhook updates
Return Type
- Error? - An
Errorif attaching failed, otherwise()
detach
function detach(TelegramService telegramService) returns Error?Detaches the attached TelegramService from the listener.
Parameters
- telegramService TelegramService - The service to detach
Return Type
- Error? - An
Errorif detaching failed, otherwise()
'start
function 'start() returns Error?Starts the listener. If publicUrl was set on ListenerConfig, also registers it as the
webhook via Client->setWebhook.
Return Type
- Error? - An
Errorif the listener, or the webhook registration, could not be started
gracefulStop
function gracefulStop() returns Error?Gracefully stops the listener, allowing in-flight requests to complete.
Return Type
- Error? - An
Errorif the listener could not be stopped, otherwise()
immediateStop
function immediateStop() returns Error?Immediately stops the listener.
Return Type
- Error? - An
Errorif the listener could not be stopped, otherwise()
Records
telegram: Animation
An animation (GIF or H.264/MPEG-4 AVC video without sound).
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- width int - The animation's width, in pixels
- height int - The animation's height, in pixels
- duration int - The animation's duration, in seconds
- thumbnail? PhotoSize - The animation's thumbnail, as predicted by the sender
- file_name? string - The animation's original filename, as defined by the sender
- mime_type? string - The animation's MIME type, as defined by the sender
- file_size? int - The file's size, in bytes, if known
telegram: AnswerCallbackQueryOptions
Optional fields for answerCallbackQuery.
Fields
- text? string - The notification text to show the user, 0-200 characters
- show_alert boolean(default false) - Whether to show an alert instead of a notification at the top of the chat screen
- url? string - The URL the client should open, for games launched via
@BotFather
- cache_time int(default 0) - The maximum time, in seconds, that the callback query result may be cached client-side
telegram: AnswerInlineQueryOptions
Optional fields for answerInlineQuery.
Fields
- cache_time? int - The maximum time, in seconds, that the results may be cached on the server
- is_personal? boolean - Whether the results may be cached on the server only for the user that sent the query
- next_offset? string - The offset the client should send in the next query with the same text, to fetch more results
- button? InlineQueryResultsButton - A button to show above the results
telegram: ApprovalButton
One button on a sendApprovalMessage prompt.
Fields
- text string - The button's label
- callback_data string - The data delivered back on
CallbackQuery.datawhen pressed
telegram: ApprovalMessageOptions
Optional fields for sendApprovalMessage. Deliberately excludes reply_markup — the inline
keyboard is always derived from the approve/decline buttons.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- parse_mode? string - The formatting mode used to parse the prompt text
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
telegram: Audio
An audio file.
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- duration int - The audio's duration, in seconds
- performer? string - The audio's performer, as defined by the sender or embedded audio tags
- title? string - The audio's title, as defined by the sender or embedded audio tags
- file_name? string - The audio's original filename, as defined by the sender
- mime_type? string - The audio's MIME type, as defined by the sender
- file_size? int - The file's size, in bytes, if known
- thumbnail? PhotoSize - The album cover thumbnail, as predicted by the sender
telegram: CallbackQuery
An incoming callback query from an inline keyboard button press.
Fields
- id string - The query's unique identifier
- 'from User - The user who triggered the callback query
- message? Message - The message with the button that was pressed, if it was sent by the bot
- inline_message_id? string - The identifier of the inline message the button belongs to, if the button belongs to a message sent via the bot in inline mode
- chat_instance string - An identifier, unique to the chat, tying the callback query to the message it originated from
- data? string - The data associated with the button that was pressed
- game_short_name? string - The short name of a
Gameto be returned, for games started via@BotFather
telegram: Chat
A chat: a private chat, group, supergroup, or channel.
Fields
- id int - The chat's unique identifier
- 'type string -
- title? string - The chat's title, for groups/supergroups/channels
- username? string - The chat's username, for private chats/supergroups/channels
- first_name? string - The other party's first name, for private chats
- last_name? string - The other party's last name, for private chats
- is_forum? boolean - Whether the supergroup has forum topics enabled
telegram: ChatFullInfo
The full chat details returned by getChat.
Fields
- Fields Included from *Chat
- bio? string - The other party's bio, for private chats
- description? string - The chat's description, for groups/supergroups/channels
- invite_link? string - The chat's primary invite link
- pinned_message? Message - The chat's currently pinned message
- permissions? ChatPermissions - The default member permissions, for groups/supergroups
- slow_mode_delay? int - The minimum seconds between consecutive messages a non-admin can send
- message_auto_delete_time? int - The auto-delete timer setting, in seconds
- sticker_set_name? string - The chat's assigned sticker set name, for supergroups
- can_set_sticker_set? boolean - Whether the bot can change the chat's sticker set
- linked_chat_id? int - The linked discussion group/channel ID
telegram: ChatMemberAdministrator
A chat member with administrator privileges.
Fields
- status CHAT_MEMBER_STATUS_ADMINISTRATOR(default CHAT_MEMBER_STATUS_ADMINISTRATOR) - The member's status in the chat; always
administrator
- user User - Information about the user
- can_be_edited boolean - Whether the bot can edit the administrator's privileges
- is_anonymous boolean - Whether the administrator's presence in the chat is hidden
- can_manage_chat boolean - Whether the administrator has full access to all chat management features
- can_delete_messages boolean - Whether the administrator can delete messages from other users
- can_manage_video_chats boolean - Whether the administrator can manage video chats
- can_restrict_members boolean - Whether the administrator can restrict, ban, or unban chat members
- can_promote_members boolean - Whether the administrator can add new administrators or demote existing ones
- can_change_info boolean - Whether the administrator can change the chat title, photo, and other settings
- can_invite_users boolean - Whether the administrator can invite new users to the chat
- can_post_messages? boolean - Whether the administrator can post messages in the channel
- can_edit_messages? boolean - Whether the administrator can edit messages of other users, for channels
- can_pin_messages? boolean - Whether the administrator can pin messages, for groups and supergroups
- can_manage_topics? boolean - Whether the administrator can create, rename, close, and reopen forum topics
- custom_title? string - The administrator's custom title
telegram: ChatMemberBanned
A former chat member who was banned.
Fields
- status CHAT_MEMBER_STATUS_KICKED(default CHAT_MEMBER_STATUS_KICKED) - The member's status in the chat; always
kicked
- user User - Information about the user
- until_date int - The Unix timestamp until which the ban is in place;
0means the ban is permanent
telegram: ChatMemberLeft
A former chat member who left on their own.
Fields
- status CHAT_MEMBER_STATUS_LEFT(default CHAT_MEMBER_STATUS_LEFT) - The member's status in the chat; always
left
- user User - Information about the user
telegram: ChatMemberMember
A chat member with no special privileges or restrictions.
Fields
- status CHAT_MEMBER_STATUS_MEMBER(default CHAT_MEMBER_STATUS_MEMBER) - The member's status in the chat; always
member
- user User - Information about the user
- until_date? int - The Unix timestamp until which the subscription to the chat is active, for subscribers
telegram: ChatMemberOwner
A chat member who owns the chat.
Fields
- status CHAT_MEMBER_STATUS_CREATOR(default CHAT_MEMBER_STATUS_CREATOR) - The member's status in the chat; always
creator
- user User - Information about the user
- is_anonymous boolean - Whether the user's presence in the chat is hidden
- custom_title? string - The owner's custom title
telegram: ChatMemberRestricted
A chat member restricted by some chat-permission limits.
Fields
- status CHAT_MEMBER_STATUS_RESTRICTED(default CHAT_MEMBER_STATUS_RESTRICTED) - The member's status in the chat; always
restricted
- user User - Information about the user
- is_member boolean - Whether the user is a member of the chat at the moment of the request
- can_send_messages? boolean - Whether the user can send text messages, contacts, invoices, locations, and venues
- can_send_audios? boolean - Whether the user can send audio files
- can_send_documents? boolean - Whether the user can send documents
- can_send_photos? boolean - Whether the user can send photos
- can_send_videos? boolean - Whether the user can send videos
- can_send_video_notes? boolean - Whether the user can send video notes
- can_send_voice_notes? boolean - Whether the user can send voice notes
- can_send_polls? boolean - Whether the user can send polls
- can_send_other_messages? boolean - Whether the user can send animations, games, stickers, and use inline bots
- can_add_web_page_previews? boolean - Whether the user can add web page previews to their messages
- can_change_info? boolean - Whether the user can change the chat title, photo, and other settings
- can_invite_users? boolean - Whether the user can invite new users to the chat
- can_pin_messages? boolean - Whether the user can pin messages
- can_manage_topics? boolean - Whether the user can create forum topics
- until_date int - The Unix timestamp until which the restrictions are in place
telegram: ChatPermissions
The set of actions a restricted chat member is or is not allowed to take.
Fields
- can_send_messages? boolean - Whether the user can send text messages, contacts, invoices, locations, and venues
- can_send_audios? boolean - Whether the user can send audio files
- can_send_documents? boolean - Whether the user can send documents
- can_send_photos? boolean - Whether the user can send photos
- can_send_videos? boolean - Whether the user can send videos
- can_send_video_notes? boolean - Whether the user can send video notes
- can_send_voice_notes? boolean - Whether the user can send voice notes
- can_send_polls? boolean - Whether the user can send polls
- can_send_other_messages? boolean - Whether the user can send animations, games, stickers, and use inline bots
- can_add_web_page_previews? boolean - Whether the user can add web page previews to their messages
- can_change_info? boolean - Whether the user can change the chat title, photo, and other settings
- can_invite_users? boolean - Whether the user can invite new users to the chat
- can_pin_messages? boolean - Whether the user can pin messages
- can_manage_topics? boolean - Whether the user can create forum topics
telegram: ConnectionConfig
Configuration for the Telegram Bot API Client.
Fields
- token string - The bot token issued by @BotFather; embedded in every request's resource path
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings(default {}) - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings(default {}) - Configurations related to HTTP/2 protocol
- timeout decimal(default 30) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default FORWARDED_DISABLE) - The choice of setting
forwarded/x-forwardedheader
- followRedirects? FollowRedirects - Configurations associated with redirection
- poolConfig? PoolConfiguration - Configurations associated with request pooling
- cache CacheConfig(default {}) - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding) header
- circuitBreaker? CircuitBreakerConfig - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig? RetryConfig - Configurations associated with retrying
- cookieConfig? CookieConfig - Configurations associated with cookies
- responseLimits ResponseLimitConfigs(default {}) - Configurations associated with inbound response size limits
- secureSocket? ClientSecureSocket - SSL/TLS-related options
- proxy? ProxyConfig - Proxy server related options
- socketConfig ClientSocketConfig(default {}) - Provides settings related to client socket configuration
- validation boolean(default true) - Enables the inbound payload validation functionality provided by the constraint package
- laxDataBinding boolean(default true) - Enables relaxed data binding on the client side
telegram: Contact
A shared contact card.
Fields
- phone_number string - The contact's phone number
- first_name string - The contact's first name
- last_name? string - The contact's last name
- user_id? int - The contact's user identifier in Telegram, if the contact has a Telegram account
- vcard? string - Additional data about the contact, in vCard format
telegram: Document
A general file sent as a document.
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- thumbnail? PhotoSize - The document's thumbnail, as predicted by the sender
- file_name? string - The document's original filename, as defined by the sender
- mime_type? string - The document's MIME type, as defined by the sender
- file_size? int - The file's size, in bytes, if known
telegram: EditMessageTextOptions
Optional fields for editMessageText.
Fields
- parse_mode? string - The formatting mode used to parse the new message text
- entities? MessageEntity[] - Special entities within the new message text, as an alternative to
parse_mode
- disable_web_page_preview? boolean - Whether to disable a link preview for links in the message
- reply_markup? InlineKeyboardMarkup - The new inline keyboard attached to the message
telegram: File
A file's metadata, as returned by getFile.
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- file_size? int - The file's size, in bytes, if known
- file_path? string - The path to fetch the file's bytes from, valid for at least 1 hour
telegram: ForceReply
An instruction to show a "reply" input prompt to selected users.
Fields
- force_reply true (default true) - Always
true; instructs clients to show a reply interface to the user
- input_field_placeholder? string - The placeholder text shown in the message input field when the reply interface is active
- selective? boolean - Whether the reply interface is shown only to specific users
telegram: HtmlRichMessage
Rich message content authored in HTML.
Fields
- html string - The rich message content, formatted as HTML
telegram: InlineKeyboardButton
One button on an inline keyboard.
Fields
- text string - The label text on the button
- url? string - The HTTP or
tg://URL to open when the button is pressed
- callback_data? string - The data sent back to the bot in a
CallbackQuerywhen the button is pressed
- web_app? WebAppInfo - The Web App to launch when the button is pressed
- switch_inline_query? string - The inline query inserted into the input field when the user picks a chat to switch to
- switch_inline_query_current_chat? string - The inline query inserted into the input field of the current chat when the button is pressed
- pay? boolean - Whether this is a
Paybutton, for invoice messages only
telegram: InlineKeyboardMarkup
An inline keyboard, shown attached to the message it belongs to.
Fields
- inline_keyboard InlineKeyboardButton[][] - The array of button rows, each an array of
InlineKeyboardButtonobjects
telegram: InlineQuery
An incoming inline query.
Fields
- id string - The query's unique identifier
- 'from User - The user who sent the query
- query string - The text of the query, up to 256 characters
- offset string - The offset of the results to return, controlled by the bot
- chat_type? string - The type of chat from which the inline query was sent
- location? Location - The sender's location, present if enabled and requested by the bot
telegram: InlineQueryResultArticle
A link to an article or web page, as an inline query result.
Fields
- 'type INLINE_QUERY_RESULT_TYPE_ARTICLE(default INLINE_QUERY_RESULT_TYPE_ARTICLE) -
- id string - The result's unique identifier, 1-64 bytes
- title string - The title shown for the result
- input_message_content InputTextMessageContent - The content of the message to be sent
- reply_markup? InlineKeyboardMarkup - The inline keyboard attached to the message
- url? string - The URL of the article, shown as a link beneath the result
- description? string - A short description of the result
- thumbnail_url? string - The URL of the result's thumbnail
- thumbnail_width? int - The thumbnail's width, in pixels
- thumbnail_height? int - The thumbnail's height, in pixels
telegram: InlineQueryResultPhoto
A link to a photo, as an inline query result.
Fields
- 'type INLINE_QUERY_RESULT_TYPE_PHOTO(default INLINE_QUERY_RESULT_TYPE_PHOTO) -
- id string - The result's unique identifier, 1-64 bytes
- photo_url string - The URL of the photo, which must be in JPEG format and not exceed 5MB
- thumbnail_url string - The URL of the photo's thumbnail
- photo_width? int - The photo's width, in pixels
- photo_height? int - The photo's height, in pixels
- title? string - The title shown for the result
- description? string - A short description of the result
- caption? string - The caption to show with the photo
- parse_mode? string - The formatting mode used to parse
caption
- reply_markup? InlineKeyboardMarkup - The inline keyboard attached to the message
- input_message_content? InputTextMessageContent - The content to send instead of the photo itself
telegram: InlineQueryResultsButton
A button shown above inline query results.
Fields
- text string - The label text on the button
- web_app? WebAppInfo - The Web App to launch when the button is pressed
- start_parameter? string - The deep-linking parameter for the
/startmessage sent to the bot when the user presses the button and switches to a private chat with it
telegram: InputMediaAudio
An audio file, as one item of a sendMediaGroup batch.
Fields
- 'type INPUT_MEDIA_TYPE_AUDIO(default INPUT_MEDIA_TYPE_AUDIO) -
- media string - A
file_idor an HTTP(S) URL identifying the audio file to send
- caption? string - The caption to show with the audio
- parse_mode? string - The formatting mode used to parse
caption
- duration? int - The audio's duration, in seconds
- performer? string - The audio's performer
- title? string - The audio's title
telegram: InputMediaDocument
A general file, as one item of a sendMediaGroup batch.
Fields
- 'type INPUT_MEDIA_TYPE_DOCUMENT(default INPUT_MEDIA_TYPE_DOCUMENT) -
- media string - A
file_idor an HTTP(S) URL identifying the document to send
- caption? string - The caption to show with the document
- parse_mode? string - The formatting mode used to parse
caption
- disable_content_type_detection? boolean - Whether to disable automatic server-side content type detection
telegram: InputMediaPhoto
A photo, as one item of a sendMediaGroup batch.
Fields
- 'type INPUT_MEDIA_TYPE_PHOTO(default INPUT_MEDIA_TYPE_PHOTO) -
- media string - A
file_idor an HTTP(S) URL identifying the photo to send
- caption? string - The caption to show with the photo
- parse_mode? string - The formatting mode used to parse
caption
- has_spoiler? boolean - Whether the photo needs to be covered with a spoiler animation
telegram: InputMediaVideo
A video, as one item of a sendMediaGroup batch.
Fields
- 'type INPUT_MEDIA_TYPE_VIDEO(default INPUT_MEDIA_TYPE_VIDEO) -
- media string - A
file_idor an HTTP(S) URL identifying the video to send
- caption? string - The caption to show with the video
- parse_mode? string - The formatting mode used to parse
caption
- width? int - The video's width, in pixels
- height? int - The video's height, in pixels
- duration? int - The video's duration, in seconds
- supports_streaming? boolean - Whether the uploaded video is suitable for streaming
- has_spoiler? boolean - Whether the video needs to be covered with a spoiler animation
telegram: InputTextMessageContent
Text content sent in place of the inline query result content, when the result itself has none.
Fields
- message_text string - The text of the message to be sent, 1-4096 characters
- parse_mode? string - The formatting mode used to parse
message_text
- entities? MessageEntity[] - Special entities within
message_text, as an alternative toparse_mode
telegram: KeyboardButton
One button on a custom reply keyboard.
Fields
- text string - The button's label text, sent as a message when pressed unless another option below is set
- request_contact? boolean - Whether pressing the button requests the user's phone number and sends it as a contact
- request_location? boolean - Whether pressing the button requests the user's current location and sends it
- web_app? WebAppInfo - The Web App to launch when the button is pressed
telegram: ListenerConfig
Configuration for the Telegram webhook Listener. Provide exactly one of secretToken or
token.
Fields
- secretToken? string - Use this secret token directly. Every inbound update is authenticated by comparing it
against the
X-Telegram-Bot-Api-Secret-Tokenheader.
- token? string - Derive the secret token from this bot token via
deriveSecretToken— the same derivationClient->setWebhookfalls back to when its ownsecret_tokenoption is omitted, so neither side needs a separately invented/threaded secret. Also required (alongsidepublicUrl) for the listener to register its own webhook automatically when it starts.
- publicUrl? string - This listener's public HTTPS URL. When set together with
token, starting the listener automatically registers it as the webhook viaClient->setWebhook, so no separatesetWebhookcall is needed.
- serviceUrl string(default DEFAULT_BASE_URL) - The Telegram Bot API base URL used for the automatic
setWebhookcall whenpublicUrlis set. Only useful to override in tests or when routing through a proxy.
telegram: Location
A point on the map.
Fields
- longitude decimal - The location's longitude, as defined by the sender
- latitude decimal - The location's latitude, as defined by the sender
- horizontal_accuracy? decimal - The radius of uncertainty for the location, measured in meters
- live_period? int - The time, in seconds, for which the location will keep being updated, for live locations
- heading? int - The direction in which the user is moving, in degrees, for live locations
- proximity_alert_radius? int - The maximum distance, in meters, for proximity alerts about approaching another chat member, for live locations
telegram: MarkdownRichMessage
Rich message content authored in Markdown.
Fields
- markdown string - The rich message content, formatted as Markdown
telegram: Message
A message. Mirrors a v1 subset of Telegram's own Message object
Fields
- message_id int - The message's unique identifier within the chat
- message_thread_id? int - The forum topic the message belongs to, if any
- date int - The message's send date, as a Unix timestamp
- chat Chat - The chat the message belongs to
- 'from? User - The message's sender; absent for messages sent to channels
- text? string - The message's text, for text messages
- entities? MessageEntity[] - Special entities (mentions, URLs, formatting, ...) within
text
- caption? string - The media caption, for media messages
- caption_entities? MessageEntity[] - Special entities within
caption
- reply_to_message? Message - The message being replied to, if any
- photo? PhotoSize[] - The message's photo, in up to 4 resolutions
- document? Document - The message's general file, if any
- video? Video - The message's video, if any
- audio? Audio - The message's audio file, if any
- voice? Voice - The message's voice note, if any
- animation? Animation - The message's animation, if any
- sticker? Sticker - The message's sticker, if any
- contact? Contact - The message's shared contact, if any
- location? Location - The message's shared location, if any
- venue? Venue - The message's shared venue, if any
- poll? Poll - The message's native poll, if any
- reply_markup? InlineKeyboardMarkup - The inline keyboard attached to the message, if any
telegram: MessageEntity
One special entity (mention, URL, bold text, etc.) within message text.
Fields
- 'type string -
- offset int - The entity's start position, in UTF-16 code units
- length int - The entity's length, in UTF-16 code units
- url? string - The linked URL, present only when
typeistext_link
- user? User - The mentioned user, present only when
typeistext_mention
- language? string - The code block's programming language, present only when
typeispre
- custom_emoji_id? string - The custom emoji's identifier, present only when
typeiscustom_emoji
telegram: OrderInfo
Order information, as supplied by the user on an invoice.
Fields
- name? string - The user's full name
- phone_number? string - The user's phone number
- email? string - The user's email address
- shipping_address? ShippingAddress - The user's shipping address, for flexible-price invoices that require one
telegram: PhotoSize
One resolution of a photo.
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- width int - The photo's width, in pixels
- height int - The photo's height, in pixels
- file_size? int - The file's size, in bytes, if known
telegram: Poll
A native poll.
Fields
- id string - The poll's unique identifier
- question string - The poll question
- options PollOption[] - The list of poll answer options
- total_voter_count int - The total number of users who voted in the poll
- is_closed boolean - Whether the poll is closed and no longer accepts new votes
- is_anonymous boolean - Whether the poll is anonymous
- 'type string -
- allows_multiple_answers boolean - Whether the poll allows multiple answers
- correct_option_ids? int[] - The 0-based identifiers of the correct answer option(s), for quiz-type polls
- explanation? string - Text shown when a user chooses an incorrect answer or taps the lamp icon, for quiz-type polls
- open_period? int - The amount of time the poll is active, in seconds
- close_date? int - The point in time (Unix timestamp) when the poll is scheduled to close automatically
telegram: PollOption
One answer option on a poll.
Fields
- text string - The option's text
- voter_count int - The number of users who voted for this option
telegram: PreCheckoutQuery
An incoming pre-checkout query.
Fields
- id string - The query's unique identifier
- 'from User - The user who sent the query
- currency string - The three-letter ISO 4217 currency code
- total_amount int - The total price, in the smallest units of the currency
- invoice_payload string - The bot-specified invoice payload
- shipping_option_id? string - The identifier of the shipping option chosen by the user
- order_info? OrderInfo - The order information provided by the user
telegram: ReplyKeyboardMarkup
A custom keyboard shown in place of the user's regular keyboard.
Fields
- keyboard KeyboardButton[][] - The array of button rows that make up the custom keyboard
- is_persistent? boolean - Whether the keyboard is always shown, even when a regular keyboard is available
- resize_keyboard? boolean - Whether the keyboard should be resized vertically to fit only the buttons shown
- one_time_keyboard? boolean - Whether the keyboard should be hidden as soon as it is used
- input_field_placeholder? string - The placeholder text shown in the message input field when the keyboard is active
- selective? boolean - Whether the keyboard is shown only to specific users
telegram: ReplyKeyboardRemove
An instruction to remove any active custom reply keyboard.
Fields
- remove_keyboard true (default true) - Always
true; instructs clients to remove the custom keyboard
- selective? boolean - Whether the keyboard is removed only for specific users
telegram: ResponseParameters
Extra data Telegram attaches to some error responses to help automatic handling.
Fields
- migrateToChatId? int - The group's new chat ID, if it was migrated to a supergroup
- retryAfter? int - The number of seconds to wait before retrying, present on
429responses
telegram: SendAnimationOptions
Optional fields for sendAnimation.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- duration? int - The animation's duration, in seconds
- width? int - The animation's width, in pixels
- height? int - The animation's height, in pixels
- caption? string - The caption to show with the animation
- parse_mode? string - The formatting mode used to parse
caption
- caption_entities? MessageEntity[] - Special entities within
caption, as an alternative toparse_mode
- has_spoiler? boolean - Whether the animation needs to be covered with a spoiler animation
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
- fileName? string - The multipart filename to use, when
animationis raw bytes
- mimeType? string - The multipart content type to use, when
animationis raw bytes
telegram: SendAudioOptions
Optional fields for sendAudio.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- caption? string - The caption to show with the audio
- parse_mode? string - The formatting mode used to parse
caption
- caption_entities? MessageEntity[] - Special entities within
caption, as an alternative toparse_mode
- duration? int - The audio's duration, in seconds
- performer? string - The audio's performer
- title? string - The audio's title
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
- fileName? string - The multipart filename to use, when
audiois raw bytes
- mimeType? string - The multipart content type to use, when
audiois raw bytes
telegram: SendDocumentOptions
Optional fields for sendDocument.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- caption? string - The caption to show with the document
- parse_mode? string - The formatting mode used to parse
caption
- caption_entities? MessageEntity[] - Special entities within
caption, as an alternative toparse_mode
- disable_content_type_detection? boolean - Whether to disable automatic server-side content type detection
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
- fileName? string - The multipart filename to use, when
documentis raw bytes
- mimeType? string - The multipart content type to use, when
documentis raw bytes
telegram: SendLocationOptions
Optional fields for sendLocation.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- horizontal_accuracy? decimal - The radius of uncertainty for the location, measured in meters
- live_period? int - The time, in seconds, for which the location will keep being updated, for live locations
- heading? int - The direction in which the user is moving, in degrees, for live locations
- proximity_alert_radius? int - The maximum distance, in meters, for proximity alerts about approaching another chat member, for live locations
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
telegram: SendMediaGroupOptions
Optional fields for sendMediaGroup.
Fields
- message_thread_id? int - The forum topic to post the messages in, if any
- disable_notification? boolean - Whether to send the messages silently, without a notification sound
- protect_content? boolean - Whether to protect the sent messages' contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this batch is a reply
telegram: SendMessageDraftOptions
Optional fields for sendMessageDraft.
Fields
- message_thread_id? int - The forum topic to post the draft in, if any
- text? string - The draft message's text
- parse_mode? string - The formatting mode used to parse
text
telegram: SendMessageOptions
Optional fields for sendMessage.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- parse_mode? string - The formatting mode used to parse the message text
- entities? MessageEntity[] - Special entities within the message text, as an alternative to
parse_mode
- disable_web_page_preview? boolean - Whether to disable a link preview for links in the message
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- allow_sending_without_reply? boolean - Whether to send the message even if the replied-to message is not found
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
telegram: SendPhotoOptions
Optional fields for sendPhoto.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- caption? string - The caption to show with the photo
- parse_mode? string - The formatting mode used to parse
caption
- caption_entities? MessageEntity[] - Special entities within
caption, as an alternative toparse_mode
- has_spoiler? boolean - Whether the photo needs to be covered with a spoiler animation
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
- fileName? string - The multipart filename to use, when
photois raw bytes
- mimeType? string - The multipart content type to use, when
photois raw bytes
telegram: SendRichMessageOptions
Optional fields for sendRichMessage.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- message_effect_id? string - The identifier of the message effect to add to the message; private chats only
- is_rtl? boolean - Whether the rich message content should be rendered right-to-left
- skip_entity_detection? boolean - Whether to skip automatic detection of entities (links, mentions, formatting) in the rich message content
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
telegram: SendStickerOptions
Optional fields for sendSticker (Telegram stickers have no caption).
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- emoji? string - The emoji associated with the sticker, only for uploads
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
- fileName? string - The multipart filename to use, when
stickeris raw bytes
- mimeType? string - The multipart content type to use, when
stickeris raw bytes
telegram: SendVideoOptions
Optional fields for sendVideo.
Fields
- message_thread_id? int - The forum topic to post the message in, if any
- duration? int - The video's duration, in seconds
- width? int - The video's width, in pixels
- height? int - The video's height, in pixels
- caption? string - The caption to show with the video
- parse_mode? string - The formatting mode used to parse
caption
- caption_entities? MessageEntity[] - Special entities within
caption, as an alternative toparse_mode
- has_spoiler? boolean - Whether the video needs to be covered with a spoiler animation
- supports_streaming? boolean - Whether the uploaded video is suitable for streaming
- disable_notification? boolean - Whether to send the message silently, without a notification sound
- protect_content? boolean - Whether to protect the sent message's contents from forwarding and saving
- reply_to_message_id? int - The identifier of the original message, if this message is a reply
- reply_markup? ReplyMarkup - The inline keyboard/prompt attached to the message
- fileName? string - The multipart filename to use, when
videois raw bytes
- mimeType? string - The multipart content type to use, when
videois raw bytes
telegram: SetWebhookOptions
Optional fields for setWebhook.
Fields
- allowed_updates string[]|"*" (default "*") - The update types to subscribe to;
"*"(the default) means all 9 update types this connector'sListenersupports
- drop_pending_updates boolean(default false) - Whether to drop all pending updates before setting the new webhook
- secret_token? string - A secret token sent in the
X-Telegram-Bot-Api-Secret-Tokenheader of every webhook request, used to verify the request came from Telegram. Defaults toderiveSecretToken(token)if omitted; seeClient->setWebhook's doc comment
- max_connections? int - The maximum allowed number of simultaneous HTTPS connections to the webhook, 1-100
- ip_address? string - The fixed IP address to use for webhook requests, instead of one resolved via DNS
telegram: ShippingAddress
A shipping address, as supplied by the user on a flexible-price invoice.
Fields
- country_code string - The two-letter ISO 3166-1 alpha-2 country code
- state string - The state, if applicable
- city string - The city
- street_line1 string - The first line of the address
- street_line2 string - The second line of the address
- post_code string - The post code
telegram: ShippingQuery
An incoming shipping query, for a flexible-price invoice.
Fields
- id string - The query's unique identifier
- 'from User - The user who sent the query
- invoice_payload string - The bot-specified invoice payload
- shipping_address ShippingAddress - The user's specified shipping address
telegram: Sticker
A sticker.
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- 'type string -
- width int - The sticker's width, in pixels
- height int - The sticker's height, in pixels
- is_animated boolean - Whether the sticker is animated
- is_video boolean - Whether the sticker is a video sticker
- thumbnail? PhotoSize - The sticker's thumbnail, in
.webpor.jpgformat
- emoji? string - The emoji associated with the sticker
- set_name? string - The name of the sticker set the sticker belongs to
- file_size? int - The file's size, in bytes, if known
telegram: TelegramErrorDetail
Structured detail attached to a TelegramError.
Fields
- errorCode int? - Telegram's
error_codefor the failed call; not guaranteed stable across calls
- parameters ResponseParameters? - Extra data to help automatic handling (e.g.
retryAfteron flood-control errors)
telegram: User
A Telegram user or bot.
Fields
- id int - The user's unique identifier
- is_bot boolean - Whether this user is a bot
- first_name string - The user's first name
- last_name? string - The user's last name
- username? string - The user's username
- language_code? string - The user's IETF language tag
- is_premium? boolean - Whether the user has Telegram Premium
telegram: Venue
A venue.
Fields
- location Location - The venue's location
- title string - The venue's name
- address string - The venue's address
- foursquare_id? string - The venue's Foursquare identifier
- foursquare_type? string - The venue's Foursquare type (e.g.
arts_entertainment/default)
- google_place_id? string - The venue's Google Places identifier
- google_place_type? string - The venue's Google Places type
telegram: Video
A video file.
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- width int - The video's width, in pixels
- height int - The video's height, in pixels
- duration int - The video's duration, in seconds
- thumbnail? PhotoSize - The video's thumbnail
- file_name? string - The video's original filename, as defined by the sender
- mime_type? string - The video's MIME type, as defined by the sender
- file_size? int - The file's size, in bytes, if known
telegram: Voice
A voice note.
Fields
- file_id string - An identifier for reusing this file in future requests
- file_unique_id string - An identifier that is the same regardless of which bot requested the file
- duration int - The voice note's duration, in seconds
- mime_type? string - The voice note's MIME type, as defined by the sender
- file_size? int - The file's size, in bytes, if known
telegram: WebAppInfo
A web_app button's launch target.
Fields
- url string - The HTTPS URL of the Web App to open when the button is pressed
telegram: WebhookInfo
The webhook status returned by getWebhookInfo.
Fields
- url string - The webhook URL currently set; empty if no webhook is set
- has_custom_certificate boolean - Whether a custom certificate was provided for webhook certificate checks
- pending_update_count int - The number of updates awaiting delivery
- ip_address? string - The current IP address resolved for the webhook URL
- last_error_date? int - The Unix timestamp of the most recent error, if any, delivering an update via webhook
- last_error_message? string - The error message for the most recent error, if any, delivering an update via webhook
- max_connections? int - The maximum allowed number of simultaneous HTTPS connections to the webhook
- allowed_updates? string[] - The update types the bot is subscribed to
Errors
telegram: ClientError
An error raised by the Client/Listener before (or instead of) a call reaching the Telegram
Bot API — e.g. invalid arguments, a failed HTTP/data-binding operation, or a file download that
failed after the HTTP call succeeded. Distinguishes these from a TelegramError (which the Bot
API itself returned).
telegram: Error
The common error type for this connector: every error the Client/Listener raises is a
TelegramError or a ClientError. Use this in signatures/documentation when the distinction
doesn't matter to the caller; narrow with is TelegramError/is ClientError when it does.
Union types
telegram: ReplyMarkup
ReplyMarkup
Any keyboard/prompt attachable to an outbound message via reply_markup.
telegram: ChatMember
ChatMember
Any chat member, narrowed by its status field.
telegram: InputMedia
InputMedia
Any media item attachable to a sendMediaGroup batch.
telegram: InlineQueryResult
InlineQueryResult
Any result attachable to an answerInlineQuery batch.
telegram: RichMessage
RichMessage
Rich message content, in either supported format.
telegram: ChatAction
ChatAction
The chat action shown via sendChatAction (e.g. the "typing..." indicator).
Import
import ballerinax/telegram;Other versions
0.9.0
Metadata
Released date: 7 days ago
Version: 0.9.0
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.12.0
GraalVM compatible: Yes
Pull count
Total: 2
Current verison: 0
Weekly downloads
Keywords
Communication/Telegram
Cost/Free
Vendor/Telegram
Area/Communication
Type/Connector
Type/Trigger
Contributors