DEV Community

FermainPariz
FermainPariz

Posted on

Build a Telegram Bot for Business Automation (Step-by-Step Guide 2026)

Build a Telegram Bot for Business Automation (Step-by-Step Guide 2026)

Telegram has 950 million monthly active users in 2026. Its Bot API is one of the most powerful and underused automation tools available — completely free, with no rate-limit headaches, and capable of handling everything from customer notifications to full conversational commerce.

This guide walks you through building a Telegram bot for business automation from scratch. No prior bot experience needed. By the end, you'll have a working bot connected to n8n that can handle notifications, customer inquiries, and workflow triggers.

Why Telegram Bots Beat Email and SMS for Business Automation

Before we build anything, here's why Telegram deserves your attention:

  • 98% open rate — compared to 20% for email. Messages are read within minutes, not hours.
  • Zero cost — no per-message fees like SMS (Twilio charges $0.0079 per message). Telegram's Bot API is free forever.
  • Rich media support — send images, documents, buttons, inline keyboards, locations, and polls. Not just text.
  • Two-way communication — users can reply, tap buttons, and trigger workflows. It's interactive, not broadcast-only.
  • No app approval process — unlike building a WhatsApp Business bot (which requires Meta business verification), Telegram bots are instant.

The trade-off: your audience needs to be on Telegram. For tech-savvy audiences, B2B, crypto, developer communities, and European/Asian markets, this is a non-issue. For US consumer brands targeting boomers, maybe stick with SMS.

Step 1: Create Your Bot With BotFather

Every Telegram bot starts with @botfather, Telegram's official bot for creating bots (yes, it's meta).

  1. Open Telegram and search for @BotFather
  2. Send /newbot
  3. Choose a display name (e.g., "Acme Notifications")
  4. Choose a username — must end in bot (e.g., acme_notify_bot)
  5. BotFather replies with your HTTP API token. It looks like this: 7123456789:AAHxYz-abc123def456ghi789jkl

Save this token securely. Anyone with this token can control your bot. Store it in a password manager or your n8n credentials — never in code or git repos.

Configure Your Bot's Profile

While you're in BotFather, set these up:

/setdescription — What users see before starting the bot
/setabouttext — Short bio shown in the bot's profile
/setuserpic — Upload a logo (recommend 512x512px)
/setcommands — Define the command menu
Enter fullscreen mode Exit fullscreen mode

For /setcommands, send a list like:

start - Start the bot and get welcome message
help - Show available commands
status - Check system status
subscribe - Subscribe to notifications
unsubscribe - Stop notifications
Enter fullscreen mode Exit fullscreen mode

This creates the command menu that appears when users type / in the chat.

Step 2: Understand the Bot API Basics

Telegram's Bot API works over HTTPS. Every action is an API call to:

https://api.telegram.org/bot{YOUR_TOKEN}/{METHOD}
Enter fullscreen mode Exit fullscreen mode

The methods you'll use most:

Method What It Does
getUpdates Poll for new messages (for testing)
setWebhook Register a URL to receive updates in real-time
sendMessage Send a text message
sendPhoto Send an image
sendDocument Send a file
editMessageText Edit a previously sent message
answerCallbackQuery Respond to button clicks

Quick Test: Send Your First Message

Find your bot on Telegram and send it /start. Then find your chat ID by calling:

curl https://api.telegram.org/bot{TOKEN}/getUpdates
Enter fullscreen mode Exit fullscreen mode

Look for "chat":{"id":123456789} in the response. Now send a message:

curl -X POST https://api.telegram.org/bot{TOKEN}/sendMessage \
  -H "Content-Type: application/json" \
  -d '{"chat_id": 123456789, "text": "Hello from the API!", "parse_mode": "Markdown"}'
Enter fullscreen mode Exit fullscreen mode

If you see the message in Telegram, your bot is working.

Step 3: Set Up Webhooks for Real-Time Updates

Polling with getUpdates works for testing, but for production you want webhooks. When a user sends a message, Telegram pushes the update to your URL instantly.

You need an HTTPS endpoint. Options:

  • n8n webhook node — the easiest if you're already using n8n
  • Cloudflare Workers — free tier, globally distributed
  • Any VPS with nginx + SSL — full control

Setting the Webhook

curl -X POST https://api.telegram.org/bot{TOKEN}/setWebhook \
  -H "Content-Type: application/json" \
  -d '{"url": "https://your-n8n-instance.com/webhook/telegram-bot"}'
Enter fullscreen mode Exit fullscreen mode

Verify it's set:

curl https://api.telegram.org/bot{TOKEN}/getWebhookInfo
Enter fullscreen mode Exit fullscreen mode

You should see "url": "https://your-n8n-instance.com/webhook/telegram-bot" and "has_custom_certificate": false.

Step 4: Build Business Automation Workflows With n8n

Now the interesting part. Here are four practical business automation workflows you can build with your Telegram bot and n8n.

Workflow 1: Order Status Notifications

Trigger: New order or order status change in your e-commerce platform (Shopify, WooCommerce, or custom).

Flow:

Shopify Webhook (new order)
    ↓
n8n: Extract order details
    ↓
n8n: Format message with order ID, items, total
    ↓
Telegram: Send to customer (if they've opted in)
    ↓
Telegram: Send to internal #orders channel
Enter fullscreen mode Exit fullscreen mode

n8n Implementation:

  1. Create a Webhook node to receive Shopify order webhooks
  2. Add a Function node to format the message:
const order = $input.first().json;
const items = order.line_items.map(i => `• ${i.title} x${i.quantity}`).join('\n');

return [{
  json: {
    chatId: order.customer.telegram_chat_id, // stored in customer meta
    message: `🛒 *New Order #${order.order_number}*\n\n${items}\n\n*Total:* €${order.total_price}\n*Status:* ${order.fulfillment_status || 'Processing'}`
  }
}];
Enter fullscreen mode Exit fullscreen mode
  1. Add a Telegram node with sendMessage operation, chat ID from the previous node, and Markdown parse mode.

Workflow 2: Daily Business Reports

Trigger: Cron schedule — every day at 9:00 AM.

Flow:

Cron (9:00 AM)
    ↓
n8n: Query analytics API / database
    ↓
n8n: Calculate KPIs (revenue, signups, churn)
    ↓
n8n: Format as Telegram message with inline buttons
    ↓
Telegram: Send to founder/team group
Enter fullscreen mode Exit fullscreen mode

Message template:

📊 *Daily Report — March 14, 2026*

*Revenue:* €2,340 (+12% vs yesterday)
*New Signups:* 47
*Active Users:* 1,203
*Churn:* 2 accounts
*Support Tickets:* 8 open, 3 resolved

[View Dashboard](https://your-app.com/dashboard)
Enter fullscreen mode Exit fullscreen mode

This replaces the "check five different dashboards every morning" routine with a single glanceable Telegram message.

Workflow 3: Customer Support Bot

Trigger: User sends a message to your bot.

Flow:

Telegram Webhook (incoming message)
    ↓
n8n: Route based on message content
    ├── /start → Welcome message + menu
    ├── /status → Query order API → send status
    ├── /faq → Send FAQ with inline keyboard
    └── Free text → Forward to AI (Claude) → send response
Enter fullscreen mode Exit fullscreen mode

Building the router in n8n:

Use a Switch node after the Telegram Trigger:

{
  "conditions": [
    {
      "value1": "={{ $json.message.text }}",
      "operation": "startsWith",
      "value2": "/start"
    },
    {
      "value1": "={{ $json.message.text }}",
      "operation": "startsWith",
      "value2": "/status"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

For the AI fallback branch, add an HTTP Request node calling the Anthropic API:

{
  "url": "https://api.anthropic.com/v1/messages",
  "method": "POST",
  "headers": {
    "x-api-key": "{{ $credentials.anthropicApi.apiKey }}",
    "anthropic-version": "2023-06-01"
  },
  "body": {
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 500,
    "system": "You are a helpful customer support agent for [Your Company]. Answer based on the FAQ document. If you don't know, say you'll escalate to a human.",
    "messages": [{"role": "user", "content": "{{ $json.message.text }}"}]
  }
}
Enter fullscreen mode Exit fullscreen mode

Send the AI response back to the user via the Telegram node.

Workflow 4: Content Approval Pipeline

Trigger: New content item added to Notion or Google Sheets.

Flow:

Notion Trigger (new item in Content Queue)
    ↓
n8n: Format preview message with image + caption
    ↓
Telegram: Send to approver with Approve/Reject buttons
    ↓
Wait for callback
    ├── Approve → Publish to Instagram/LinkedIn/Twitter
    └── Reject → Update Notion status, notify content creator
Enter fullscreen mode Exit fullscreen mode

Inline keyboard for approval:

const keyboard = {
  inline_keyboard: [
    [
      { text: "Approve", callback_data: `approve_${contentId}` },
      { text: "Reject", callback_data: `reject_${contentId}` },
      { text: "Edit", callback_data: `edit_${contentId}` }
    ]
  ]
};
Enter fullscreen mode Exit fullscreen mode

When the approver taps a button, Telegram sends a callback query to your webhook. Route it in n8n based on the callback_data prefix.

Step 5: Handle Groups and Channels

Bots work differently in groups and channels:

Groups

  • Add your bot to a group to use it for team notifications
  • The bot needs to be added as an admin to read all messages (otherwise it only sees commands and direct mentions)
  • Use chat_id of the group (negative number, e.g., -1001234567890)

Channels

  • Add your bot as a channel admin to post to channels
  • Channels are broadcast-only — users can't interact with bot commands there
  • Use channels for announcements, daily reports, or content distribution

Getting the Group/Channel Chat ID

Add @RawDataBot to your group temporarily. It will print the chat ID. Then remove it.

Or use your bot's getUpdates endpoint after sending a message in the group.

Step 6: Security and Production Hardening

Before you point real customer data at your bot:

Validate Webhook Source

Add a secret token when setting your webhook:

curl -X POST https://api.telegram.org/bot{TOKEN}/setWebhook \
  -d '{"url": "https://your-url.com/webhook", "secret_token": "your-random-secret"}'
Enter fullscreen mode Exit fullscreen mode

Telegram sends this in the X-Telegram-Bot-Api-Secret-Token header. Verify it in your n8n workflow with an IF node.

Restrict Bot Access

If your bot handles sensitive data, whitelist allowed users:

const allowedUsers = [123456789, 987654321]; // Telegram user IDs
const userId = $json.message.from.id;

if (!allowedUsers.includes(userId)) {
  // Send "unauthorized" message and stop
  return [];
}
Enter fullscreen mode Exit fullscreen mode

Rate Limiting

Telegram allows bots to send:

  • 30 messages per second to different chats
  • 1 message per second to the same chat
  • 20 messages per minute to the same group

If you're sending bulk notifications, add delays between messages in your n8n workflow.

Error Handling

Always add an error branch in n8n that sends failures to your personal Telegram chat:

// Error handler node
const error = $json.error || 'Unknown error';
const workflow = $workflow.name;

return [{
  json: {
    chatId: YOUR_ADMIN_CHAT_ID,
    message: `*Workflow Error*\n\nWorkflow: ${workflow}\nError: ${error}\nTime: ${new Date().toISOString()}`
  }
}];
Enter fullscreen mode Exit fullscreen mode

Step 7: Advanced Features Worth Implementing

Inline Keyboards for Interactive Menus

Instead of forcing users to type commands, send buttons:

{
  "chat_id": 123456789,
  "text": "What would you like to do?",
  "reply_markup": {
    "inline_keyboard": [
      [{"text": "Check Order Status", "callback_data": "check_order"}],
      [{"text": "Contact Support", "callback_data": "contact_support"}],
      [{"text": "View Pricing", "url": "https://your-site.com/pricing"}]
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

Scheduled Messages

Use n8n's Cron node to send scheduled messages — reminders, weekly summaries, or expiration warnings. Store subscriber chat IDs in a database (Supabase, Postgres, or even a Google Sheet for small scale).

File and Document Handling

Bots can receive and send files up to 50 MB. Use this for:

  • Invoice delivery
  • Report PDFs
  • Image processing workflows (user sends image, bot processes and returns result)

Payments

Telegram supports native payments through the Bot API. Users can pay directly in the chat using Apple Pay, Google Pay, or credit cards. Useful for simple product sales without needing a full checkout flow.

Real-World Use Cases

Here's how businesses are using Telegram bots in 2026:

E-commerce: Order confirmations, shipping updates, abandoned cart reminders, and restock notifications. A Shopify store owner reported 3x higher engagement compared to email for shipping updates.

SaaS: Uptime monitoring alerts, usage threshold warnings, weekly metrics reports, and feature request collection.

Freelancers: Client project updates, invoice reminders, time tracking (send "/track 2h design work" and it logs to a spreadsheet), and new lead notifications from web forms.

Content Creators: New subscriber alerts, content performance reports, audience polls, and community engagement.

Cost Comparison: Telegram Bot vs Alternatives

Solution Monthly Cost (1000 messages/day) Setup Complexity
Telegram Bot + n8n (self-hosted) $5 (VPS only) Medium
Telegram Bot + n8n Cloud $24 Low
Twilio SMS $237 Low
SendGrid Email $15 Low (but 20% open rate)
WhatsApp Business API $50-200 High
Custom Push Notifications $25-100 High

Telegram wins on cost and engagement rate. The only downside is platform dependency — your users need Telegram installed.

Next Steps

You now have everything to build a production-ready Telegram bot for business automation. Start with one workflow — the daily report is the easiest win — and expand from there.

The real power comes from chaining multiple workflows together: a customer support bot that escalates to humans, triggers order lookups, sends satisfaction surveys after resolution, and feeds everything into your analytics pipeline. All running on a single n8n instance.


If you found this useful:


If you found this useful, check out my toolkits for social media professionals:

Top comments (0)