How to create an automated Telegram bot for daily group messages without keeping computer on

I’m just getting started with Python and building Telegram bots. I want to make a basic bot that automatically posts a message to a specific group every day at midnight (00:01). Here’s what I have so far:

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

The function works great when I test it manually. For scheduling, I’m thinking about using:

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

My main question is about what happens when my computer shuts down. If I close my laptop or turn off my PC, will the bot continue working? Will it still send the scheduled messages? I’m confused about whether Telegram bots can run independently or if they need to be hosted somewhere that stays online 24/7. Do I need a server or Raspberry Pi to keep this running?

Nope, the bot dies as soon as you shut down your computer. The schedule library runs locally, so when Python stops, everything stops. I made the same mistake with my first bot - figured it’d magically keep running somehow. You need always-on hosting for continuous operation. AWS EC2 or Google Cloud have free tiers that work great for lightweight bots. GitHub Actions is another option - you can set up scheduled workflows to trigger your bot daily without a dedicated server. It’s basically cost vs complexity. Free solutions need more setup but work fine for simple daily messages. Just test the scheduling thoroughly since timezone differences between your machine and the host can mess up timing.

yeah, your bot needs to run somewhere online. shutting down your pc stops it. get a VPS for 24/7 uptime or use a raspberry pi if u have it. also, pythonanywhere’s free plan is good for keeping tasks on schedul.

Yes, your computer must remain on for the bot to function. If you shut down your laptop, the Python script will terminate, and no messages will be sent. The schedule library operates only while your program is running; I learned this the hard way with my first bot. There are several hosting options available. Heroku’s free tier is effective for simple scheduling needs, while Digital Ocean droplets are also reliable if you’re open to a monthly fee. For a completely free solution, consider repurposing an old computer or using a Raspberry Pi to run it continuously as your own server. Just ensure your chosen hosting solution supports persistent scheduling, as some free services may put applications to sleep during periods of inactivity, which can interrupt your midnight messages.