Platform Integrations
communication platforms
How to Create a Telegram Bot for Business Notifications
Build a Telegram bot that sends automated business notifications.
Jay Banlasan
The AI Systems Guy
I build telegram bot business notification automation systems that delivers real-time alerts to any team member's phone. This runs as a background service that handles communication without manual intervention.
What You Need
- Python 3.9+
- API credentials for the messaging platform
- A server or VPS for hosting
Step 1: Set Up the Connection
pip install requests flask python-dotenv
import requests
import os
from dotenv import load_dotenv
load_dotenv()
API_TOKEN = os.getenv("BOT_TOKEN")
Step 2: Send Messages
def send_message(recipient, text):
# Platform-specific sending logic
print(f"Sending to {recipient}: {text}")
return True
def send_template(recipient, template_name, params=None):
print(f"Sending template '{template_name}' to {recipient}")
return True
Step 3: Handle Incoming Messages
from flask import Flask, request
app = Flask(__name__)
@app.route("/webhook", methods=["POST"])
def handle_webhook():
data = request.json
sender = data.get("from", "")
text = data.get("text", data.get("body", ""))
response = process_message(sender, text)
if response:
send_message(sender, response)
return "OK", 200
def process_message(sender, text):
text_lower = text.lower().strip()
if text_lower in ("status", "report"):
return format_status_report()
elif text_lower == "help":
return "Commands: status, report, help"
return None
Step 4: Build Notification Templates
def notify_new_lead(name, email, source):
msg = f"New Lead: {name} ({email}) from {source}"
send_message(os.getenv("ADMIN_CHAT_ID"), msg)
def notify_system_alert(service, status):
msg = f"ALERT: {service} is {status}"
send_message(os.getenv("ALERT_CHAT_ID"), msg)
def notify_daily_summary(metrics):
msg = f"Daily: {metrics['leads']} leads, ${metrics['spend']} spend, ${metrics['cpl']:.2f} CPL"
send_message(os.getenv("REPORT_CHAT_ID"), msg)
Step 5: Schedule Automated Messages
import schedule
import time
def daily_report():
metrics = {"leads": 15, "spend": 500, "cpl": 33.33}
notify_daily_summary(metrics)
schedule.every().day.at("09:00").do(daily_report)
# Run scheduler in background
while True:
schedule.run_pending()
time.sleep(60)
What to Build Next
Add two-way conversation handling so the bot can answer questions and take actions based on replies. Start with the five most common questions your team or customers ask.
Related Reading
- Setting Up Slack Notifications for Key Business Events - getting the right alerts to the right people
- Identifying Your Biggest Bottleneck - building bots that solve real business problems
- Building Your First Automation: A Complete Guide - how to pick the right automation approach for your business
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment