Building a Telegram Bot for Business Automation in a Day
How to ship a Telegram bot that actually solves a real business problem in one day — order notifications, customer Q&A, internal team alerts. With working code.
Telegram bots are one of the highest-ROI things you can ship for a small business. Everyone has Telegram. Push notifications are free. A well-built bot feels human. This post walks through three bots I shipped last month — the code, the use case, and what they actually changed.
Bot 1: Order notifications
A small online shop owner asked for help. Every order sent an email, but he never opened them. Customers would call two hours later asking where their order was, and he had no idea it had even been placed. Fix: every new order drops into a Telegram group with inline buttons for 'Received', 'Preparing', 'Shipped' status updates.
from aiogram import Bot, Dispatcher, types
from aiogram.utils import executor
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
bot = Bot(token="YOUR_BOT_TOKEN")
dp = Dispatcher(bot)
# E-commerce webhook çağırır
async def send_new_order(order):
kb = InlineKeyboardMarkup(row_width=3).add(
InlineKeyboardButton("✅ Qəbul", callback_data=f"ack:{order['id']}"),
InlineKeyboardButton("📦 Hazırlanır", callback_data=f"prep:{order['id']}"),
InlineKeyboardButton("🚚 Yola düşdü", callback_data=f"ship:{order['id']}"),
)
text = (
f"🛍 <b>Yeni sifariş #{order['id']}</b>\n"
f"👤 {order['customer_name']} — {order['phone']}\n"
f"💰 {order['total']} AZN\n"
f"📍 {order['address']}\n\n"
f"<b>Məhsullar:</b>\n" + "\n".join(f"• {p['name']} ×{p['qty']}" for p in order['items'])
)
await bot.send_message(GROUP_CHAT_ID, text, reply_markup=kb, parse_mode="HTML")
@dp.callback_query_handler(lambda c: c.data.startswith("ship:"))
async def mark_shipped(call: types.CallbackQuery):
order_id = call.data.split(":")[1]
# CRM-də status update
await update_order_status(order_id, "shipped")
await call.message.edit_text(call.message.text + "\n\n✅ <i>Yola düşdü</i>", parse_mode="HTML")
# Müştəriyə SMS göndər
await send_sms(order_id, "Sifarişiniz yola düşdü!")Outcome: he now runs orders without ever opening his inbox. Status changes trigger automatic SMS to the customer. After a month he told me 'customer calls dropped 70%'. Build time: 4 hours. Monthly cost: $0 (runs on the existing server).
Bot 2: Customer questions — FAQ + AI
A dental clinic wanted a 24/7 question bot. Their receptionist works 9-6, the rest of the day customers messaged on WhatsApp and got nothing back. The bot has two layers: first check a hand-written FAQ of 50+ common questions, fall back to GPT-4o-mini grounded on the clinic's service list and prices.
from openai import OpenAI
from aiogram import types
client = OpenAI()
SYSTEM_PROMPT = """Sən Astoria Dental klinikasının köməkçisisən.
Yalnız aşağıdakı xidmət siyahısı və qiymət cədvəli əsasında cavab ver.
Sual siyahıdan kənardırsa, 'Operator sizə əlaqə saxlayacaq' yaz.
Xidmətlər və qiymətlər:
- İlkin müayinə: pulsuz
- Diş təmizliyi: 80 AZN
- Plomb (1 diş): 60-120 AZN materialdan asılı
- Diş çəkmək: 50 AZN
- İmplant: 1200 AZN-dən başlayır
..."""
@dp.message_handler()
async def handle_question(msg: types.Message):
# 1. FAQ-də axtar
faq_answer = find_in_faq(msg.text)
if faq_answer:
return await msg.reply(faq_answer)
# 2. AI cavablandırsın
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": msg.text}
],
max_tokens=300,
)
await msg.reply(response.choices[0].message.content)First month: 312 questions answered. 184 by the FAQ layer (free), 128 by the AI ($0.40 total in API costs). The receptionist told me later, 'we should have shipped this last winter, I was spending half an hour every morning typing the same answers'.
Bot 3: Internal team alerts
This one's for my own infrastructure. I maintain 12+ client servers and I need to know immediately when one falls over. UptimeRobot emails me, but I check email twice a day. Telegram vibrates instantly.
# webhook endpoint UptimeRobot-dan gələn alert-ləri qəbul edir
from fastapi import FastAPI, Request
import httpx, os
app = FastAPI()
TG_TOKEN = os.environ["TG_TOKEN"]
CHAT_ID = os.environ["TG_CHAT_ID"]
@app.post("/uptime-webhook")
async def uptime(req: Request):
data = await req.json()
icon = "🔴" if data["alertType"] == "1" else "🟢"
text = (
f"{icon} <b>{data['monitorFriendlyName']}</b>\n"
f"Status: {data['alertTypeFriendlyName']}\n"
f"URL: {data['monitorURL']}\n"
f"Müddət: {data['alertDuration']}s"
)
async with httpx.AsyncClient() as c:
await c.post(
f"https://api.telegram.org/bot{TG_TOKEN}/sendMessage",
json={"chat_id": CHAT_ID, "text": text, "parse_mode": "HTML"},
)
return {"ok": True}Things to watch in production
- Don't push the bot token to GitHub — keep it in
.env - Webhook URLs must be HTTPS (Telegram won't accept anything else)
- Rate limits: 30 messages per second globally, 20 per second per group
- Long-running tasks (PDF generation, slow AI calls) — acknowledge first, work in the background
- Pipe error logs somewhere (Sentry, Better Stack) — otherwise bots fail silently
Critical: each bot should solve one clear problem. Don't build the 'do everything' bot. Ship one job perfectly, then add the second. The bots I've built that succeeded all started with one or two features done really well.
If you have a bot idea but don't know where to start, book a discovery call — we'll map the use case, sketch the infrastructure, and you'll walk away with a clear estimate.
Need help on a project?
If something in this post hits close to a project you're working on, let's hop on a 30-minute call — I'll come back with concrete advice.