Sitemap
Better Programming

Advice for programmers.

I Built a Telegram Bot To Schedule Recurring Messages on Telegram

Here’s a brief guide so you can easily schedule your messages

3 min readMay 18, 2022

--

Press enter or click to view image in full size
Recurring messages (@cron_telebot)

In my previous article, How to schedule recurring messages on Telegram (no code!), I shared how we can schedule recurring messages on Telegram using Cron.

While that was cool, I wanted to make the process simpler for users by automating all the processes I could automate and keeping the entire process in-app. Users can now schedule recurring messages in the Telegram app itself. No more third-party applications!

Recurring messages (@cron_telebot) is a Telegram bot I built specifically to schedule recurring messages on Telegram.

Here’s how you can create a recurring message using the bot:

Press enter or click to view image in full size
Adding a new job

You may add/delete/view the details of multiple recurring jobs and set advanced options for them. You may also request a new feature or report a bug by opening an issue here.

How To Add a Bot to Your Group

Recurring messages can be set up for individual use—start a conversation with the bot here—and for groups. This is how you can add recurring messages to your group:

Press enter or click to view image in full size
How to add a Telegram bot to a group

To add the bot to the group, you will have to use the Telegram mobile app or Telegram desktop; Telegram web does not support this.

The rest of the article will be about how the bot is designed, so feel free to skip it if you’re not interested in the technical details. Nonetheless, do check out the bot at this link!

How the bot works

In my quest to simplify processes for end users, the bot design got more complex as more components got involved.

Press enter or click to view image in full size
Bot design

When a user interacts with the bot, the bot webhook will pick up the messages, filter useful information, and write relevant data to the database. Every minute, an app will go through the database to find messages that need to be sent and send them to their respective chats.

I know Google Sheets is not meant to work as a database and cannot scale properly, especially since it doesn’t allow data querying, so every time I need to get a specific document/row by a certain key, I must read the entire table (lol). However, it’s free and easy to implement as a proof of concept, so I used it for this project. I might consider changing the database to a more scalable one in the unlikely case of hitting 1,000 users.

This project is open source, so feel free to contribute! Find out more about how you can contribute here.

Thanks for reading. I appreciate your time and support.

--

--

Responses (2)