· Jun 21, 2023 3m read

Telegram Adapter for InterSystems IRIS

The Telegram Adapter for InterSystems IRIS serves as a bridge between the popular Telegram messaging platform and InterSystems IRIS, facilitating seamless communication and data exchange. By leveraging the capabilities of the Telegram API, the adapter allows developers to build robust chatbots, automate tasks, and integrate Telegram with InterSystems IRIS applications.

The most common scenarios where the Telegram Adapter can be used include:

  1. Real-Time System Notifications: Sending immediate notifications about specific events occurring in the system. This can include alerts, updates, or important system information delivered to users or administrators via Telegram.
  2. Customer Interaction and chatbot Applications: This can involve various activities such as appointment scheduling, appointment reminders, and conducting NPS (Net Promoter Score) surveys to gather customer feedback. Intelligent chatbots can be created that integrate with existing systems, have access to extensive knowledge bases, and are capable of answering user questions.
  3. Training and Testing: It can be used to deliver training materials, interactive quizzes, or conduct assessments through Telegram.

Key Features and Functionality

  1. Bi-Directional Communication
  2. All features of the Telegram Bot API are supported (
  3. Out-of-the-box business services, business operations, and messages

Adapter Technical Details.

The telegram-adapter package includes not only the adapter itself but also ready-to-use business services (Telegram.LongPollingService.cls and Telegram.WebHookService.cls), a business operation (Telegram.BusinessOperation), and the Telegram.Request message class.

It is assumed that you will not need to create your own business services or business operations.

Each of these business services will create and send a message containing all the raw data (received from telegram) to the designated production component as specified in the settings. Additionally, you have the option to configure automatic file (document) saving from incoming messages.

To send a message, you need to create a Telegram.Request message, specifying which API method to invoke, and in the Data field, include the JSON with all the required fields for the Telegram API. For example, let's send a text message:

Set msg = ##class(Telegram.Request).%New()
Set msg.Method = "sendMessage"
// All possible fields are described here
Set msg.Data = {
    "chat_id" : (..ChatId),
    "text": ("*bold text*" _$$$NL_ "_italic text_ " _$$$NL_ "```"_$$$NL_"pre-formatted fixed-width "_$$$NL_"code block```"),
    "parse_mode": "MarkdownV2",
    "disable_notification": "true"
Return ..SendRequestAsync("Telegram.BusinessOperation", msg)

To send files such as images, videos, audio, and other types of files, you need to add the full file name (including the path) to the Files collection of the Telegram.Request object and use the same path in the corresponding fields of the JSON message. Here's an example:

Set filePath = "/path/to/photo.jpg"
Set msg = ##class(Telegram.Request).%New()
Set msg.Method = "sendPhoto"
Do msg.Files.Insert(filePath)
// All possible fields are described here
Set msg.Data = {
    "chat_id": (..ChatId),
    "photo": (filePath),
    "caption": ("IRIS Telegram Adapter Demo")
Return ..SendRequestAsync("Telegram.BusinessOperation", msg)

Telegram Adapter Demo

The telegram-adapter-demo package includes an example of an Echo chatbot implementation.

The bot responds to any text message sent to it. If you send a .png file, it will also reply with a thumbnail of that image, automatically generated by Telegram.

To run this example, follow all the installation steps outlined in the documentation provided at

By completing the installation process, you will be able to launch and experience this Echo chatbot example.


Discussion (0)1
Log in or sign up to continue