How to schedule recurring messages on Telegram (no code!)

Using Telegram API to send messages remotely

Hui Shun Chua
3 min readApr 3, 2022
Cron

Telegram doesn’t support scheduling of recurring messages at the moment. Hence, I created an app called Cron as a non-technical, no-code solution. All you need is a smartphone!

6 Steps to schedule recurring messages on Telegram

Step 1. Create Telegram channel

How to create a Telegram Channel

Step 2. Create bot via @BotFather telegram bot

How to create your new bot (using the Botfather bot)

Remember your bot token; it will be required in the API endpoint for sending messages to your channel.

Step 3. Add your Telegram Bot to the Telegram channel/group

How to add a Telegram bot to a channel

You will have to use the Telegram mobile app or Telegram Desktop to add your Telegram bot to your Telegram channel; Telegram Web does not have this feature.

Step 4. Retrieve the chat ID of the channel

If your channel is public, you can find your chat ID in the channel details:

In this case, my chat ID is @huishun

If your channel is private, retrieving your chat ID is a little more complicated. In your browser’s searchbar, or any API platform (e.g. Postman), call the following url/API endpoint:

https://api.telegram.org/bot<bot-token>/getUpdates

For example, if your bot token is ABCDE, then the endpoint is:

https://api.telegram.org/botABCDE/getUpdates

The response will look something like:

{
"ok": true,
"result": [{
"update_id": ...,
"my_chat_member": {
"chat": {
"id": ..., // THIS IS THE CHAT ID
"title": ...,
"type": "channel"
}, ...
}, ...
]
}

There, that’s your chat ID.

Step 5. Test the API endpoints

We’ve retreived our bot token in Step 2 and our chat ID in Step 4. Replace the respective placeholders in the following endpoint with the two values.

https://api.telegram.org/bot<bot-token>/sendMessage?chat_id=<chat-id>&text=<your-custom-text>&parse_mode=markdown

Replace <your-custom-text> with any message you want to send to your Telegram channel.

You can test the endpoint by entering it in your browser’s searchbar, or API platforms like Postman. The message should be sent to your Telegram channel.

The API above sends a message without photos. If you want to send a photo, call the following endpoint instead:

https://api.telegram.org/bot<bot-token>/sendPhoto?chat_id=<chat-id>&photo=<photo-url>&caption=<your-custom-text>&parse_mode=markdown

Remember to replace <> and everything in between, and include the @ in front of your chat ID for public channels/groups. Also note that Telegram API does not support file upload, so you would need to use a temporary file storage service (e.g. upload.io) if you want to send photos using the endpoint and do not already have your photo stored in a cloud service.

For more endpoints, please refer to the Telegram bot SDK documentation.

Step 6. Set up a cron job to call the API endpoint at regular intervals

In the Cron app, create a cron job and fill in the job url with the API endpoint created in Step 5.

How to use Cron

If you’re using it for business purposes, I recommend cron-job.org as it provides extra monitoring features.

If you enjoyed this article, please follow me on Medium to show your support. Thank you for reading!

--

--