Terminal.skills
Use Cases/Build a Telegram Bot That Runs Your Business Operations

Build a Telegram Bot That Runs Your Business Operations

Create a Telegram bot that handles customer orders, appointment booking, notifications, and team coordination — turning Telegram into a lightweight business operations platform.

Automation#telegram#bot#messaging#chatbot#coding-agent
Works with:claude-codeopenai-codexgemini-clicursor
$

The Problem

Marina runs an 8-person service agency. Customer communication is scattered across email, phone calls, and random WhatsApp messages. Appointment bookings happen over the phone — the receptionist juggles a paper calendar and Google Calendar, and double-bookings happen twice a month. Order status inquiries account for 40% of incoming calls, each taking 3-5 minutes to look up in a spreadsheet. The team coordinates through a group chat, but important messages get buried under lunch plans and memes.

The worst part: there is no single system tying customer-facing and internal operations together. A client calls about their order, the receptionist checks a spreadsheet, then messages the team chat to ask for an update, then calls the client back. Three systems, two phone calls, and fifteen minutes for a question that should take five seconds.

Marina considered building a custom web app, but the development cost and adoption friction were too high. Her clients and team already use Telegram daily. The right move is to meet them where they already are.

The Solution

Using the telegram-bot-builder, coding-agent, and data-analysis skills, the agent builds an interactive Telegram bot that handles order tracking, appointment booking, team task management, payments, and weekly analytics — all from a single chat interface. Customers interact with the business through a polished conversation flow, and the team manages everything from admin commands in the same app they already use.

Step-by-Step Walkthrough

Step 1: Build the Customer-Facing Order Tracker

Build a Telegram bot using grammY that lets customers check their order
status. When a user sends /start, show a welcome message with two inline
keyboard buttons: "Track Order" and "New Order". For order tracking: ask
for the order number, query the database, and return status with a
progress bar emoji. Include estimated delivery date and a "Notify me on
update" button that subscribes them to push notifications when status
changes. Use SQLite for the database.

The bot greets customers with inline keyboard buttons and walks them through a multi-step conversation flow. When a customer taps "Track Order," the bot asks for their order number, looks it up in SQLite, and returns a visual status line:

  • Received: [========----------] 40%
  • In Progress: [==============----] 70%
  • Shipped: [==================] 100%

Each status response includes the estimated delivery date and a "Notify me on update" button. Tapping it subscribes the customer to push notifications — when the order status changes in the database, the bot fires a message automatically. No more phone calls asking "where's my order?"

The grammY conversation plugin manages multi-step flows cleanly. If a customer sends an invalid order number, the bot explains the expected format and asks again instead of crashing. If they tap the back button mid-flow, it returns to the previous step without losing context.

Step 2: Add Appointment Booking with Calendar

Add a booking flow to the bot. When the user taps "Book Appointment":
1. Show service categories as inline keyboard buttons (Consultation, Follow-up, Review)
2. Show available dates for the next 14 days (skip weekends and fully booked days)
3. Show available time slots for the selected date (30-min intervals, 9am-5pm)
4. Confirm booking with a summary and Confirm/Cancel buttons
5. Send a confirmation message with an .ics calendar attachment
6. Send a reminder 24 hours before the appointment

Handle edge cases: slot taken between selection and confirmation,
cancellation flow, rescheduling.

The booking flow replaces the paper calendar entirely. Customers see a date picker keyboard showing day names and available slot counts — fully booked days are grayed out. Time slots update in real-time, and database-level locks prevent the double-booking problem that has been costing the agency one upset client per month.

When a booking is confirmed, the bot generates an .ics calendar file and sends it as an attachment — the customer taps it and the appointment is in their calendar. A cron job fires 24-hour reminders automatically, which turns out to be the single most effective feature for reducing no-shows.

The cancellation and rescheduling flows are just as smooth — tap a button, pick a new slot, done. The freed-up slot immediately becomes available to other customers, eliminating the manual calendar juggling that used to take the receptionist 10 minutes per reschedule.

Step 3: Build Internal Team Coordination

Create a separate bot (or admin mode in the same bot) for the team:
- /tasks — show today's tasks assigned to each team member
- /assign @person "task description" — create and assign a task
- /daily — post a daily summary: pending tasks, today's appointments,
  new orders, unread customer messages
- /broadcast "message" — send a message to all subscribed customers
  (with confirmation step before sending)

Only allow team members (list of Telegram user IDs in config) to access
admin commands. Log all actions with timestamps.

Admin commands are locked behind a middleware that checks Telegram user IDs against a config list — no one outside the team can run them. If a customer somehow discovers the /tasks command, they get a polite "I don't understand that command" instead of internal data.

The /daily digest is the real game-changer: every morning, the team gets a single message summarizing pending tasks, today's appointments, new orders, and unread customer messages. No more scrolling through hundreds of chat messages to find what matters.

The /assign command creates tasks with deadlines and sends a notification to the assigned team member. Tasks persist in SQLite and show up in the daily digest until completed. It is not Jira, but for an 8-person team, it is exactly enough.

The /broadcast command includes a preview and confirmation step before sending, and respects Telegram's 30 messages/second rate limit by batching delivery. Every admin action gets logged with a timestamp and user ID — useful for accountability and for debugging "who sent that broadcast?"

Step 4: Implement Payment Collection

Add payment integration using Telegram's built-in payments (Stripe provider).
When a customer places a new order through the bot:
1. Show order summary with itemized pricing
2. Send a Telegram invoice with the Pay button
3. Handle successful payment callback
4. Update order status to "paid" and notify the team channel
5. Send a receipt with order details

Also add a /pay command where customers can pay outstanding invoices by number.

Telegram's built-in Payments API with Stripe as the provider means customers never leave the chat to pay. The friction reduction is significant — instead of receiving an email invoice, opening a browser, entering payment details, and confirming, the customer taps a single "Pay" button inside the conversation they are already in.

The bot generates invoices with line items, validates the pre-checkout query, processes the payment, and updates the database in one flow. The team channel gets an instant notification with the payment amount and customer details. Receipts are formatted and sent automatically.

The /pay command handles outstanding invoices — a customer types /pay INV-2847 and gets a payment button right there in the conversation. Invoice follow-up time drops from days to minutes.

All payment events are logged for accounting reconciliation. The bot stores Stripe payment IDs alongside order IDs, so the monthly accounting close no longer requires manually matching bank transactions to orders.

Step 5: Generate Weekly Business Analytics

Every Monday at 8am, generate a weekly report and post it to the team group:
- Total orders: count and revenue
- Bookings: completed vs cancelled vs no-show
- Bot engagement: unique users, messages processed, most used features
- Customer satisfaction: count of users who used "Rate us" feature
- Comparison with previous week (up/down indicators)

Format as a clean Telegram message with emoji headers and percentage changes.

A node-cron job fires every Monday at 8 AM, queries SQLite for the past 7 days, calculates week-over-week changes, and posts a formatted report to the team group:

  • Orders: 127 this week ($18,400 revenue, +12% vs last week)
  • Bookings: 43 completed, 3 cancelled, 2 no-shows (93% show rate)
  • Bot engagement: 312 unique users, 2,847 messages processed
  • Top feature: Order tracking (used 847 times)
  • Satisfaction: 4.6/5.0 average rating (38 responses)

The report also highlights trends: if booking cancellations spike or order tracking usage drops, the team knows something changed without waiting for a customer complaint. Over time, these weekly snapshots build a data trail that makes business decisions evidence-based instead of anecdotal.

Real-World Example

Marina deploys the bot on a Monday. By Wednesday, customers are checking order status themselves — phone calls for "where's my order?" drop by 60% in the first week. The booking system eliminates double-bookings entirely; the database locks that handle race conditions between selection and confirmation catch every conflict.

The daily digest transforms the team's morning routine. Instead of the receptionist spending 30 minutes piecing together the day's schedule from three different sources, everyone opens Telegram and sees exactly what needs to happen today.

Payment collection through Telegram cuts invoice follow-up time dramatically. Customers who used to ignore email invoices for days now pay within minutes because the payment button is right there in the conversation they are already using.

After 3 months: phone call volume is down 70%, booking no-shows have decreased 40% thanks to automated reminders, and the team saves 15+ hours per week on coordination.

The entire system runs on a $5/month VPS with SQLite and Redis — no monthly SaaS fees, no per-message charges, no vendor lock-in. The bot handles 500+ customer interactions per week without breaking a sweat. Marina is considering adding a second bot for her partner agency down the street.