How to set up daily Telegram bot alerts for new users?

Hey everyone! I’m working on a Telegram bot and I’m stuck. I want the bot to send messages to users for their first 5 days of using it. The tricky part is I need these messages to go out at the same time each day, based on when each user first started chatting with the bot.

Is there a way to keep track of when each user started and then use that info to send them personalized daily notifications? I’m not sure how to handle the timing for different users.

Any tips or code examples would be super helpful! Thanks in advance!

I’ve actually implemented something similar for a client’s Telegram bot. Here’s what worked well for us:

We used Redis to store user start times. It’s fast and handles concurrent access better than SQLite for this use case. We set up a cron job to run every hour, checking for users within their first 5 days.

The key was using a message queue (we chose RabbitMQ) to handle the actual sending. This decoupled the scheduling from message delivery, making the system more robust. If the bot went down temporarily, messages would still be sent when it came back up.

For timing, we calculated the exact second to send each message based on the user’s start time, then used the message queue’s delay feature to schedule precisely.

This approach scaled well as our user base grew. Just make sure to implement proper error handling and logging - it’ll save you headaches down the line.

I’ve tackled a similar challenge with my Telegram bot and found a straightforward approach. I rely on a simple database like SQLite to log user IDs with their initial interaction times. With this setup, a daily task checks which users are still in their first five days and computes the correct moment for sending a personalized message. The key is to synchronize the scheduled check with each user’s start time. Although the setup takes some effort initially, the system becomes very hands-off and reliable over time.

hey there! i’ve done something similar before. you could use a database (sqlite works great) to store user start times. then set up a daily cron job to check which users are in their first 5 days. calculate the right time to send messages based on their start time. it’s a bit tricky at first, but works like a charm once set up!