How to create a Telegram bot that automatically posts daily messages without keeping computer running

I’m just starting with Python and building Telegram bots. I want to make a simple bot that automatically posts a message to a specific group every day at midnight (00:01). Here’s my current working code:

def daily_post():
    API_TOKEN = '1234567890:ABCDEF123456789'  # Example token
    CHANNEL_ID = "-1001234567890"  # Example group ID
    message_content = "Daily reminder message"
    
    api_url = f"https://api.telegram.org/bot{API_TOKEN}/sendMessage?chat_id={CHANNEL_ID}&text={message_content}"
    response = requests.get(api_url)
    print(response.json())

The function works great when I run it manually. I know I can use scheduling like this:

import schedule
schedule.every().day.at("00:01").do(daily_post)

My main question is about what happens when I shut down my laptop or computer. Will the bot continue working and send messages at the scheduled time? Or do Telegram bots need to run continuously on some device like a server or Raspberry Pi to function properly?

Yeah, your bot stops working the moment you shut down your computer. The schedule library runs locally - it needs your machine on 24/7. I learned this the hard way with my first automation scripts. You need to move your bot to a cloud service for it to work reliably. PythonAnywhere’s free tier works great for simple scheduling like this. GitHub Actions with cron jobs is another free option that’s solid for basic automation. If you want more control, grab a DigitalOcean VPS for about $5/month. Bottom line: move your script somewhere that runs 24/7, not just when your laptop’s on.

yep, when u shut down your comp, the bot stops. try using a service like Heroku or a Raspberry Pi to keep it running all the time. just make sure to set it up to post each day.

Nope, your bot dies the moment you shut down your computer. The scheduling runs locally, so when your machine’s off, nothing happens. I made this same mistake when I started automating with Python - figured it’d somehow keep running on its own. You need continuous hosting for this to work. I’ve been using a cheap $5/month Linode VPS for over a year and it’s been solid. Or if you’ve got access to a Linux server, just use cron jobs. Your code’s already good to go - just needs to live somewhere that stays online. Add some error handling though, since network hiccups can break the Telegram API calls.