Skip to main content

Overview

The Telegram Bot API lets bots send and receive messages, manage chats, and answer inline or callback queries over a simple HTTPS REST API. The Ballerina ballerinax/telegram connector provides both a client covering chat management, messaging, and file operations, and a webhook listener for the update types Telegram delivers.

Key features​

  • Send text messages, photos, videos, documents, audio, animations, stickers, locations, and media groups
  • Manage chats: get chat info, get or list administrators, leave a chat, update the chat title or description
  • Answer callback and inline queries
  • Retrieve file metadata and download files
  • Register, remove, and inspect webhooks (setWebhook, deleteWebhook, getWebhookInfo)
  • Receive the nine most common Telegram update types over a webhook listener
  • Secret-token authentication of inbound webhook requests via X-Telegram-Bot-Api-Secret-Token

Actions​

Actions are operations you invoke on the Telegram Bot API from your integration: sending messages, managing chats, and answering queries. The connector exposes actions through a single client:

ClientActions
ClientMessaging, chat management, callback/inline query answers, file metadata/download, webhook management

See the Action Reference for the full list of operations, parameters, and sample code.

Triggers​

Triggers allow your integration to react to Telegram Bot API updates in real time. The connector provides a webhook listener that receives Telegram's updates and invokes your service callbacks automatically.

Supported trigger events (telegram:TelegramService callbacks):

CallbackDescription
onMessageA new incoming message arrives.
onEditedMessageAn existing message is edited.
onChannelPostA new channel post is published.
onEditedChannelPostAn existing channel post is edited.
onCallbackQueryA user presses an inline keyboard button.
onInlineQueryA user sends a new inline query.
onPollA poll's state changes.
onPreCheckoutQueryA user confirms a payment, just before it's charged.
onShippingQueryA user provides a shipping address for an invoice with flexible pricing.

See the Trigger Reference for listener configuration, service callbacks, and the event payload structure.

Documentation​

  • Setup Guide: Create a bot with BotFather and obtain a bot token.
  • Action Reference: Full reference for the client: operations, parameters, return types, and sample code.
  • Trigger Reference: Reference for event-driven integration using the webhook listener and service model.
  • Example: Learn how to build and configure an integration using the Telegram connector, including connection setup and event-driven trigger setup.

How to contribute​

As an open source project, WSO2 welcomes contributions from the community.

To contribute to the code for this connector, please create a pull request in the following repository.

Check the issue tracker for open issues that interest you. We look forward to receiving your contributions.