\n\n\n\n My Telegram Bot Saved Me Hours Every Week - AI7Bot \n

My Telegram Bot Saved Me Hours Every Week

📖 14 min read2,660 wordsUpdated Mar 28, 2026

Hey everyone, Marcus here from ai7bot.com. Hope you’re all having a productive week!

Today, I want to dive into something that’s been a real time-saver and, frankly, a bit of a sanity-saver for me lately: using Telegram bots to automate those annoying, repetitive tasks that pop up in personal projects or even small team setups. We’ve all got them, right? The little things that take 30 seconds here, a minute there, but add up to a frustrating chunk of your day. For me, it was always keeping track of my daily coding challenges and making sure my development server was actually humming along when I expected it to.

A while back, I was juggling a few side projects – a new bot for tracking my daily push-ups (don’t ask), a simple web app for managing my ever-growing list of tech articles to read, and of course, keeping ai7bot.com updated. I found myself constantly checking logs, pinging servers, and manually updating a spreadsheet with my daily progress on the push-up bot. It wasn’t hard work, but it was *interruptive* work. Every time I switched context, even for a minute, it cost me more time getting back into the flow. I knew there had to be a better way than having 17 tabs open or constantly refreshing my terminal.

That’s when I remembered the power of Telegram bots. I’ve built a few for simple interactions before, mostly for fun, but I hadn’t really thought about them as serious automation tools for *my own* workflow. Most people think of chatbots as customer service agents or marketing tools, but their real magic, especially for us builders, is in personal automation. They’re like having a tiny, dedicated assistant living in your chat app.

So, today, I want to walk you through how I’ve been using Telegram bots to automate server status checks and personal task logging, and how you can apply similar principles to your own repetitive headaches. We’re going to focus on building a simple Python-based bot that sends you notifications directly to your Telegram chat. No fancy UIs, no complex dashboards – just quick, actionable info where you already spend your time.

Why Telegram Bots for Personal Automation?

Before we get into the nitty-gritty, let’s talk about why Telegram is such a good fit for this kind of automation:

  • Ubiquity: Chances are, you already have Telegram open on your phone or desktop. Notifications land right where you see them.
  • Simplicity: The Telegram Bot API is incredibly straightforward. You can get a basic bot up and running in minutes.
  • Rich Features: Beyond simple text, you can send images, files, inline keyboards, and even custom buttons. This opens up a lot of possibilities for interactive automation.
  • Free and Reliable: Telegram’s infrastructure is solid, and creating bots is free.
  • Private: For personal automation, you’re usually the only one interacting with the bot. This keeps things secure and clutter-free.

I considered Discord for a minute, but for quick, personal notifications and simple interactions, Telegram felt lighter and more direct. Plus, the BotFather process is a breeze.

Getting Started: Your First Telegram Bot

If you’ve never made a Telegram bot before, don’t sweat it. It’s super easy. Here’s the quick rundown:

  1. Open Telegram and search for @BotFather.
  2. Start a chat with BotFather and type /newbot.
  3. Follow the prompts: give your bot a name (e.g., “MarcusDevMonitorBot”) and a username (e.g., “MarcusDevMonitor_bot”).
  4. BotFather will give you an API Token. This is crucial! Keep it safe; it’s like the password for your bot.

Once you have that token, you’re halfway there!

Sending Your First Message

To send a message, your bot needs to know who to send it to. This is your chat_id. The easiest way to get it is to start a conversation with your new bot, then go to this URL in your browser, replacing YOUR_BOT_TOKEN with your actual token:

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

You’ll see a JSON response. Look for the "chat" object, and inside it, the "id" field. That’s your chat_id. It’ll be a long number.

Now, let’s write a tiny Python script to send a message:

import requests

BOT_TOKEN = "YOUR_BOT_TOKEN_HERE" # Replace with your bot's token
CHAT_ID = "YOUR_CHAT_ID_HERE" # Replace with your chat_id

def send_telegram_message(message):
 url = f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage"
 payload = {
 "chat_id": CHAT_ID,
 "text": message,
 "parse_mode": "Markdown" # Allows bold, italics, etc.
 }
 try:
 response = requests.post(url, json=payload)
 response.raise_for_status() # Raise an exception for HTTP errors
 print("Message sent successfully!")
 except requests.exceptions.RequestException as e:
 print(f"Error sending message: {e}")

if __name__ == "__main__":
 send_telegram_message("Hello from your new automation bot! 👋")

Run that script, and you should see a message pop up in your Telegram chat. Pretty cool, right? This simple function is the core of all our automation.

Practical Example 1: Server Uptime Monitoring

My biggest pain point was always wondering if my dev server was still running, especially for those longer-running tasks or scheduled jobs. I didn’t need real-time, millisecond-by-millisecond monitoring, just a heads-up if something went wrong.

Here’s how I tackled it: a simple Python script that pings a URL or a specific port and sends a Telegram message if it detects an issue. I then set this script up to run every 15 minutes via a cron job on my server.

The Uptime Check Script

import requests
import socket
import time
from datetime import datetime

# --- Telegram Bot Configuration ---
BOT_TOKEN = "YOUR_BOT_TOKEN_HERE"
CHAT_ID = "YOUR_CHAT_ID_HERE"

def send_telegram_message(message):
 url = f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage"
 payload = {
 "chat_id": CHAT_ID,
 "text": message,
 "parse_mode": "Markdown"
 }
 try:
 response = requests.post(url, json=payload)
 response.raise_for_status()
 # print("Notification sent.") # Only uncomment for debugging
 except requests.exceptions.RequestException as e:
 print(f"Error sending Telegram message: {e}")

# --- Monitoring Logic ---
def check_website(url):
 try:
 response = requests.get(url, timeout=10) # 10-second timeout
 response.raise_for_status() # Raise for 4xx/5xx errors
 return True, f"Website *{url}* is UP! (Status: {response.status_code})"
 except requests.exceptions.RequestException as e:
 return False, f"Website *{url}* is DOWN! Error: `{e}`"

def check_port(host, port):
 try:
 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 sock.settimeout(5) # 5-second timeout
 result = sock.connect_ex((host, port))
 if result == 0:
 return True, f"Port *{port}* on *{host}* is OPEN."
 else:
 return False, f"Port *{port}* on *{host}* is CLOSED. Error code: {result}"
 except socket.error as e:
 return False, f"Error checking port *{port}* on *{host}*: `{e}`"

def main():
 now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
 
 # Monitor a website
 website_url = "https://ai7bot.com" # Replace with your URL
 is_up, message = check_website(website_url)
 if not is_up:
 send_telegram_message(f"🚨 *URGENT ALERT ({now})* 🚨\n{message}")
 # else:
 # send_telegram_message(f"✅ Website Check: {message}") # Uncomment for success notifications

 # Monitor a specific port (e.g., SSH or a custom app port)
 server_host = "127.0.0.1" # Or your server's public IP/hostname
 server_port = 22 # Example: SSH port
 is_open, port_message = check_port(server_host, server_port)
 if not is_open:
 send_telegram_message(f"🚨 *URGENT ALERT ({now})* 🚨\n{port_message}")
 # else:
 # send_telegram_message(f"✅ Port Check: {port_message}") # Uncomment for success notifications

if __name__ == "__main__":
 main()

A few things to note here:

  • I’m using requests for HTTP checks and socket for port checks. Simple, standard libraries.
  • Error handling is key. We want to catch network issues and timeouts.
  • I added a parse_mode="Markdown" to the sendMessage payload, which allows for bold text (*text*) and code blocks (`code`) in the messages, making alerts much easier to read.
  • I only send a notification if something is *down*. Getting a “everything is fine” message every 15 minutes would be annoying. However, I’ve left the commented-out lines there if you *do* want success notifications for debugging or specific scenarios.

Setting up the Cron Job

Once you have this script (let’s call it monitor_bot.py) on your server, you need to schedule it. For Linux servers, cron is your friend:

  1. Save the script (e.g., in /home/youruser/bots/monitor_bot.py).
  2. Open your crontab for editing: crontab -e
  3. Add a line like this to run it every 15 minutes:
    */15 * * * * /usr/bin/python3 /home/youruser/bots/monitor_bot.py >> /home/youruser/bots/monitor_log.txt 2>&1

    This tells cron to execute your script using python3 every 15 minutes and direct all output (including errors) to a log file, which is super helpful for debugging.

Now, if my website or a critical port goes down, I get an immediate alert on my phone. No more manually checking, no more “did I forget to restart that service?” panic.

Practical Example 2: Simple Daily Task Logger

Beyond server monitoring, I also use a bot for a very simple personal logging system. Remember that daily push-up tracking? Or keeping tabs on how many articles I’ve written for ai7bot.com this week?

I built a bot that lets me send a quick command like /log article_written or /log 50_pushups, and it appends that to a simple text file or a Google Sheet. For simplicity, let’s stick to a text file for this example, but expanding to a Google Sheet API is definitely doable.

For this, we’ll need a more robust bot framework than just sending messages. I usually lean on python-telegram-bot for anything interactive. It handles incoming messages, commands, and replies much more elegantly.

Installing python-telegram-bot

pip install python-telegram-bot --pre

The --pre is important because the library is currently in a pre-release state for version 20, which has some breaking changes but is generally better.

The Task Logger Bot Script

import logging
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters
from datetime import datetime
import os

# --- Configuration ---
BOT_TOKEN = "YOUR_BOT_TOKEN_HERE"
CHAT_ID = int("YOUR_CHAT_ID_HERE") # Ensure this is an integer for comparison
LOG_FILE = "daily_tasks.log"

# Set up logging
logging.basicConfig(
 format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
logger = logging.getLogger(__name__)

# --- Bot Commands ---
async def start(update: Update, context):
 """Sends a greeting message when the /start command is issued."""
 user = update.effective_user
 await update.message.reply_html(
 f"Hi {user.mention_html()}! Send me /log followed by your task (e.g., `/log wrote_blog_post`)."
 )

async def log_task(update: Update, context):
 """Logs a task to a file."""
 # Ensure only the authorized user can log tasks
 if update.effective_chat.id != CHAT_ID:
 logger.warning(f"Unauthorized access attempt from chat_id: {update.effective_chat.id}")
 await update.message.reply_text("Sorry, I'm a private bot for Marcus only! 🤫")
 return

 if not context.args:
 await update.message.reply_text("Usage: `/log your_task_description`")
 return

 task_description = " ".join(context.args)
 timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

 try:
 with open(LOG_FILE, "a") as f:
 f.write(f"{timestamp} | {task_description}\n")
 await update.message.reply_text(f"Task logged: `{task_description}`")
 logger.info(f"Logged task for {update.effective_user.first_name}: {task_description}")
 except IOError as e:
 await update.message.reply_text(f"Error logging task: `{e}`")
 logger.error(f"Error writing to log file: {e}")

async def echo(update: Update, context):
 """Echoes any text message not recognized as a command."""
 # Only echo for the authorized user
 if update.effective_chat.id == CHAT_ID:
 await update.message.reply_text(f"Did you mean to use /log? I received: `{update.message.text}`")
 else:
 await update.message.reply_text("I only respond to commands from my owner.")


async def error_handler(update: Update, context):
 """Log the error and send a message to the user."""
 logger.error(f"Update {update} caused error {context.error}")
 if update.effective_chat:
 await update.effective_chat.send_message(
 f"An error occurred: `{context.error}`. Please try again or check the logs."
 )

def main():
 """Start the bot."""
 application = Application.builder().token(BOT_TOKEN).build()

 # Register handlers
 application.add_handler(CommandHandler("start", start))
 application.add_handler(CommandHandler("log", log_task))

 # Log all errors
 application.add_error_handler(error_handler)

 # On non-command messages, echo the message (only for authorized chat)
 application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo))

 # Run the bot until the user presses Ctrl-C
 logger.info("Bot started. Press Ctrl-C to stop.")
 application.run_polling(allowed_updates=Update.ALL_TYPES)

if __name__ == "__main__":
 main()

Let’s break down some key parts of this logger bot:

  • Application.builder().token(BOT_TOKEN).build(): This is how you initialize the bot using python-telegram-bot.
  • CommandHandler("start", start): This tells the bot to call the start function when someone sends the /start command.
  • log_task function: This is the core. It takes whatever follows /log, joins it into a single string, adds a timestamp, and appends it to daily_tasks.log.
  • CHAT_ID Authorization: Crucially, I’ve added a check if update.effective_chat.id != CHAT_ID:. This makes sure *only my specific chat* can interact with the logging features. You don’t want random people logging tasks to your personal file!
  • MessageHandler(filters.TEXT & ~filters.COMMAND, echo): This is a catch-all for any text messages that aren’t commands. I use it to gently remind myself (or warn others) about correct usage.

To run this bot, simply execute the Python script: python3 logger_bot.py. It will stay running and listen for your messages. For a more robust setup, you’d run this using a process manager like systemd or supervisor on your server, ensuring it restarts if it crashes.

Now, when I finish writing an article, I just type /log finished_ai7bot_article_telegram_automation into my Telegram chat, and it’s recorded. Later, I can just cat daily_tasks.log on my server to see a summary. It’s so much less friction than opening a spreadsheet or a separate app.

Actionable Takeaways for Your Own Bot Automation

I hope these examples spark some ideas for you. The beauty of personal automation with bots is that it doesn’t have to be complex or enterprise-grade. Here’s what I recommend:

  1. Identify Your Personal “Papercuts”

    What are those small, repetitive tasks that drain your focus? Logging hours, checking specific API endpoints, getting notified when a scheduled script finishes, tracking small metrics? Make a list.

  2. Start Small and Simple

    Don’t try to build a full-fledged AI assistant on day one. Begin with sending a single message when a specific event occurs. My server monitor started as just sending “Server is down!” when a ping failed. Expand from there.

  3. Leverage Existing Libraries

    Python with requests and python-telegram-bot covers a huge range of possibilities. Don’t reinvent the wheel for API interactions or bot handling.

  4. Prioritize Security and Privacy

    Especially for personal bots, make sure your API token is not exposed. For bots that handle sensitive info or control actions, implement chat ID checks to ensure only *you* can interact with it, as shown in the logger example.

  5. Think Beyond Notifications

    While notifications are great, consider how you could add simple interactions. Could your bot trigger a server restart? Fetch a quick report? Toggle a setting? The python-telegram-bot library makes adding commands quite easy.

  6. Use a Process Manager for Longevity

    If your bot is running continuously (like the logger bot), use systemd (on Linux) or a tool like supervisor to ensure it restarts if it crashes and runs reliably in the background.

Building these little bots has genuinely made my development workflow smoother and less distracting. It’s a testament to how even simple automation can free up mental space for the more interesting, creative work. So, grab your BotFather token, identify a tiny annoyance, and start building!

Let me know in the comments what kind of personal automation you’ve built or are planning to build with Telegram bots. I’m always looking for new ideas!

Happy bot building!

Marcus Rivera

ai7bot.com

🕒 Published:

💬
Written by Jake Chen

Bot developer who has built 50+ chatbots across Discord, Telegram, Slack, and WhatsApp. Specializes in conversational AI and NLP.

Learn more →
Browse Topics: Best Practices | Bot Building | Bot Development | Business | Operations
Scroll to Top