Telegram Bot

Estimated reading time: 12 min
Telegram banner with paper plan Telegram logo on a blue background.

Telegram is a versatile messaging app with a focus on speed and security. It allows users to exchange messages, photos, videos, and files of any type. Users can create channels or groups. It is popular among individuals and businesses. 

By using Wiresk to connect Telegram with other applications, you can automate various workflows with flexibility. 

With Telegram connected to Wiresk, you can send messages, media and manage users, or groups to public or private channel/group.

To use Telegram Bot with Wiresk, you must have a Telegram account.
You can download the Telegram Desktop app at desktop.telegram.org or use Telegram web https://web.telegram.org.
We recommend utilizing Telegram web since it provides easier access to your telegram settings information.
A screenshot of the group management page in the Wiresk platform. It shows a list of groups with their name, key, flow count, and flow execution status. There is a search bar and a button to create a new group.

The group system in Wiresk is a way to organize and manage your users and Flows.

When you start with Wiresk(Admin account), you are automatically assigned to the default group. This default group can be renamed.

for users with Pro plan or higher, you can:

  • Assign users to specific Flows: Control who has access to and can edit different Flows.
  • Organize Flows: Group related Flows together for better management and visibility.
  • Manage permissions: Set permissions for different groups, determining who can create, edit, and view Flows.
  • Collaborate effectively: Facilitate collaboration among team members by assigning them to appropriate groups.
For more details about Group and Users, refer to Group system.

A connection to your Telegram Bot is needed so we can sync it with our platform.

There is two ways to connect your app to Wiresk:

  • In “My apps” section, where you can manage your connections (select or create your group first to get access to this section, refer to the Group system ).
  • While building your Flow, you can easily establish a connection to your app directly within the Flow builder. This can be done during the setup of either a Trigger or a Method.

In this documentation, we will explain how to create a connection in “My apps” section, it is essentially the same as when creating it on-the-go.

On the left panel of Wiresk user interface, go to “My apps” then search “Telegram Bot” in the search field or scroll down the list of apps and choose the Telegram icon.

Screenshot of Wiresk "my apps" tab, showing where to search telegram app.

In the new screen, give a name to your connection, here we will name it “Telegram Bot”.

In the field named “Bot Token”, you need to enter the token from your Telegram Bot. Let’s go to your Telegram account to get this information. Follow the next step “B – Create a Bot in Telegram”.

Screenshot 2024 10 09 at 1.45.54 in the afternoon 1 Telegram Bot

Let’s go to your telegram account, then search for BotFather or follow this link https://telegram.me/BotFather

then in the new chat enter the command “/newbot” or click on “/newbot”.

Screenshot 2024 10 09 at 1.52.09 in the afternoon Telegram Bot

BotFather will ask you to name your bot, here we will name it “Wiresk_test” then just send the message.  

After that, give a username to your bot, here we use “Wiresktest_bot”. 

You get a message that your bot has been created successfully and you are given the needed Token. 

image 3 Telegram Bot

Now, copy the token and let’s go back to the connection window.

Past it in the field “bot token” then just click on the button “create app” and voila! It’s done, your Telegram app has been added to Wiresk. 

Screenshot 2024 10 09 at 1.59.01 in the afternoon Telegram Bot
In Wiresk, the Chat ID will be use in Methods settings to identify your Telegram bot/channel/group.
To use the Telegram Bot Methods:
– First add the Telegram Bot to your Telegram Group/Channel where you want to send the message or interact with
– Promote the bot to admin using either the Telegram Mobile Application or the Telegram Desktop Application.

Open your channel or group then go to info settings by clicking on its name > Pen icon to edit.

Screenshot 2024 11 07 at 10.42.26 in the morning Telegram Bot

Scroll down and select “Members”, then click “add members” button > search your telegram bot in “add people” field.

Screenshot 2024 11 07 at 10.46.39 in the morning Telegram Bot

Search your Telegram bot in “add people” field.

Screenshot 2024 11 07 at 3.52.36 in the afternoon Telegram Bot

Select your bot and click on the “next” button, then click on “ADD” button. Voila, you have added your bot to your telegram Channel or group.

Screenshot 2024 11 07 at 4.00.06 in the afternoon Telegram Bot

Like in the previous step “how to add members”, open your channel or group then go to info settings by clicking on its name > Pen icon to edit.

Now, scroll down and select “Administrators”, then click “add Administrators” button > select your bot member you previously added.

In this step you can check the admin permission given to your bot, keep the default permission then click on the “go back” button. Here, you can notice that your bot has been promoted.

Gerry CD53AECE Telegram Bot
a screenshot of a chat
  • Click here: userinfobot or go to your Telegram desktop app then search @userinfobot.
  • In the chat, click on Start or send any message.
  • Userinfobot will send back a message with your Telegram bot Chat ID.
  • Keep it for later use in your Flows.

Log in to Telegram Web in your browser( To log in using the Telegram Mobile App, go to Settings > Devices > Link Desktop Device and scan the QR code).

Click on the chat of your Telegram Public Channel where you intend to send the message and have included your Telegram bot. Look at the browser URL, you can see your Public channel or group name with “@”,the Chat ID of your Public Channel or Group will be “@name”, in our case it’s “@wiresk”.

Screenshot 2024 11 07 at 2.45.43 in the afternoon Telegram Bot

Log in to Telegram Web in your browser( To log in using the Telegram Mobile App, go to Settings > Devices > Link Desktop Device and scan the QR code).

Open the chat of the Telegram Group/Channel where you want to send the message and have added your Telegram bot.

When you click on chat of the Telegram Group/Channel, you can find the Chat ID in the URL. For example, if the URL is  web.telegram.org/k/#- 2466415175, then “-2466415175” is the Chat ID of the Telegram Group/Channel.

Enter this Chat ID in the Chat ID field of your Telegram Bot Method settings with the prefix “-100”. For example, if your channel ID is – 2466415175, then the chat ID will be -1002347553969.
Screenshot 2024 11 07 at 2.57.40 in the afternoon Telegram Bot

Go to your Telegram Web in your browser (To connect using the Telegram Mobile App, go to Settings > Devices > Link Desktop Device and scan the QR code). 

Open a chat from a channel or a group, click right on the message you wish to reply to then select “copy message link”. 

If it a public group or channel, you will get a link in this format: https://t.me/Wiresk_public/33 

If it’s a private group or channel, you will get this format: https://t.me/c/2466415175/33 

 In our example, the number “33” is your message ID

a screenshot of a chat

You can Map your Message ID or Other fields from a Step response within your Flow. 

Add a Method in your Flow, in the configuration screen, click on the message ID input field, then select the Responses tab. 

Uncheck “Show recommended” case, then just select the message ID shown by the red arrow. You can repeat these steps to map the other fields. 

Screenshot 2024 11 08 at 11.45.09 in the morning Telegram Bot

Messages and files are kept in different locations. A file on the Telegram servers is identified by a file_id, consisting of a lengthy string of characters like this: AgADBAADZRAxGyhM3FKSE4qKa-RODckQHxsoABDHe0BDC1GzpGACAAEC.

In your Flow, add the Method ” Forward Message“, then forward the message that contain your media, for example, an image.

When you do a Run of your Flow, if succeed, you can notice a green tick icon over your Method icon.

Click on that green icon then find the File ID.

You can use the same file_id multiple times, so you can send the same file to different chats with the same file_id. You need to ensure you use the appropriate method; for instance, you can’t use a file_id meant for a photo when using Send Video Method.
  • Open the chat with the user you want to get the user ID from.
  • Forward a message of that user to userinfobot (search @userinfobot)
  • Userinfobot will send back a message with the user ID.
  • Keep it for later use in your Flows.

What your automation will do…

The Methods are like mini programs, it will perform a specific task on a particular app or service you’ve connected to Wiresk like get info or send emails.

You can add multiple Methods for complex Flows.

On the Flow builder screen, click on the plus button (+) next to your Trigger, then search or scroll down to select your apps Methods

If you want to build a complex Flow, Wiresk offers a selection of tools at your disposal. Refer to Wiresk’s Tools

To add Tools in your Flow, Follow the same step as adding the Methods. On the Flow builder screen, click on the plus button (+) then just click on the “Tool” tab and select the Tool that you want to add.

Telegram bots are capable of not only exchanging plain text messages, but also various other types of messages like images and videos. This includes managing files in the messages.
 
Sending files
There are three ways to send files (photos, stickers, audio, media, etc.):
If the file is already stored somewhere on the Telegram servers, you don’t need to reupload it: each file object has a file_id field, simply pass this file_id as a parameter instead of uploading. There are no limits for files sent this way.
Provide Telegram with an HTTP URL for the file to be sent. Telegram will download and send the file. 5 MB max size for photos and 20 MB max for other types of content.
Via uploading your own file. 10 MB max size for photos, 50 MB for other files.

Sending by file_id
It is not possible to change the file type when resending by file_id. I.e. a video can’t be sent as a photo, a photo can’t be sent as a document, etc.
It is not possible to resend thumbnails.
Resending a photo by file_id will send all of its sizes.
file_id is unique for each individual bot and can’t be transferred from one bot to another.
file_id uniquely identifies a file, but a file can have different valid file_ids even for the same bot.
 
Sending by URL
When sending by URL the target file must have the correct MIME type (e.g., audio/mpeg for sendAudio, etc.).
In sendDocument, sending by URL will currently only work for GIFPDF and ZIP files.
To use sendVoice, the file must have the type audio/ogg and be no more than 1MB in size. 1-20MB voice notes will be sent as files.
 
Upload local file
Wiresk use Base64 encoding format to transfer files from your computer.
Choose the method send by “File Data” to send files via Base64.
For more details Refer to Base64 encoding documentation.

By default, bots are able to message their users at no cost – but have limitations on the number of messages they can broadcast in a single interval:

  • In a single chat, avoid sending more than one message per second. We may allow short bursts that go over this limit, but eventually you’ll begin receiving 429 errors.
  • In a group, bots are not be able to send more than 20 messages per minute.
  • For bulk notifications, bots are not able to broadcast more than about 30 messages per second, unless they enable paid broadcasts to increase the limit.

5 – Test run or automate your Flow Copy Link


After setting up your Flow, you can choose to:

  • Run once”, your Flow will run only a single time. You can use this function to test your Flow. Refer to how to set up an HTTP Trigger, in the Trigger setting step.
  • Run Scheduler” will automate your Flows with the recurrence rule you previously defined.


For more details, refer to How to run a Flow tutorial in our Help Center.
 
If you are using a Webhook Triggers, the Flow will initiate automatically when a webhook is received from your connected apps. This means that the Flow is automated without a scheduler and will run until you deactivate the Flow manually. Refer to Webhook documentation in our Help Center.

Wiresk makes things easier for you! Check our Templates Gallery to discover various ready to use cases.
If you need an integration that you cannot find in Wiresk, you can make a request to our team, and we will try our best to satisfy your needs.