Telegram Integration With MuleSoft — Apisero

5 min readAug 16, 2022

Telegram is a globally accessible freemium, cross-platform, cloud-based instant messaging (IM) service. The service also provides optional end-to-end encrypted chats and video calling.

Telegram provides optional end-to-end encrypted chats. Cloud chats and groups are encrypted between the app and the server, so that ISPs and other third-parties on the network can’t access data. Users can send text and voice messages, make voice and video calls, and share an unlimited number of images, documents (2 GB per file), user locations, animated stickers, contacts, and audio files. Users can also follow channels.

Telegram’s default messages are cloud-based and can be accessed on any of the user’s connected devices. Users can share photos, videos, audio messages and other files (up to 2 gigabytes per file). Users can send messages to other users individually or in groups of up to 200,000 members.]Sent messages can be edited up to 48 hours after they have been sent and can be deleted at any time on both sides. Messages in all chats, including groups and channels, can be set to auto-delete after 24 hours, 7 days or a month, although this will only apply to messages sent after the auto-delete timer is enabled. People can react to messages, choosing from a range of emoji.

Steps of Integration

Step 1Creating a bot in Telegram.

Go to telegration → Search for BotFather → Type following commands to create a bot →

1. /newbot — This command will start creating a bot for you.

2. Provide the name for your bot. After that, provide username for bot.

Note → The username must end with “bot”.

3. Save the token that is received in the congratulations message as it will be used for integration.

4. /mybots — This command will give you a list of your created bots. You can select your bot name and edit the about, description, botpic etc.

5. Now to provide your bot the access to read group messages you need to disable the privacy-

/setprivacy — It will ask for the name of your bot. Enter your bot name. After that type Disable.

6. Add the bot to your group.

Step 2 Integration with mulesoft.

1. Create a mule application → Mule Palette → Search in Exchange → Telegram connector.

2. Create configuration for Telegram Connector.

Base uri:

Secure Token: <<Token saved in Step1 (3rd part)>>

Step 3Telegram Operations

1. Get Updates — Getting the messages from telegram group chat.

In Get Updates you need to configure following fields -

Offset — Identifier of the first update to be returned.

Limit — Limits the number of updates to be retrieved. Default 100

Object store’s Store operation is used to store the chat id for future operations. This is a compulsory field required in all other operations.

On hitting the request you will get a result like →

2. Send message — This is used to send the message in telegram chat.

Retrieve the chat id and append in incoming payload. Substitute the default chat id with your chat id.

Body to be passed in request . Change your message accordingly→

{ "text": "new message from bot" }

The request is Post and like this →

In Telegram →

3. Edit Message — Used to edit your message by passing its message id.

Body of request -

{ "text": "i edited this message from mule app", "message_id": "4" }

You will get this message id in response to the send message.

Request is Post and like this -

In Telegram -

4. Send Photo message — This is used to send photos in telegram chat.

Request body →

{ "photo": "", "caption": "photo from file_url" }

The url inside the photo is the download url of the image.

Request is Post and like this -

In Telegram -

These are some operations which I included in this Document.

You can explore other operations also. The Body and Request is Similar to these operations.

For Further information on them and structure of Body, You can refer to the references section of this document.


Youtube link —

Originally published at on August 16, 2022.