Skip to content
What Bots Solve
step 1/5

Reading — step 1 of 5

Read

~1 min readBot Architecture

What Bots Solve

A bot is an automated user that interacts via a chat platform's API:

  • Reply to commands.
  • Send notifications.
  • Run mini-games.
  • Moderate channels.
  • Provide information (weather, news, definitions).
  • Bridge services (GitHub PR notifications in Slack).

Real platforms:

  • Discord: gaming, communities. Bots run via discord.py / discord.js.
  • Slack: enterprise. Bots via Bolt SDK.
  • Telegram: messaging. Bots via Telegram Bot API.
  • WhatsApp Business API: customer service.
  • Microsoft Teams: enterprise.
  • IRC: classic.
  • Twitter/X, Mastodon, Bluesky: social.

Bot capabilities:

  • Receive messages.
  • Send messages.
  • Edit/delete messages.
  • React with emoji.
  • Manage roles, channels, members.
  • Voice (Discord).

Common bot architectures:

Polling:

loop:
    response = api.get_updates()
    for update in response.updates:
        handle(update)
    sleep(1)

Simple. High latency. API rate limits matter.

Webhooks:

1. Register webhook URL.
2. Platform POSTs new events to your URL.
3. Server handles, replies if needed.

Lower latency, more efficient. Need public HTTP endpoint.

Long polling:

GET /updates?timeout=30   ← server waits up to 30s for new updates

Telegram's getUpdates with timeout is long-polling. Combine simple + low latency.

WebSocket (Discord):

  • Persistent connection.
  • Real-time events streamed.
  • Two-way: send + receive.

We'll build a Discord/Telegram-style bot framework. Includes:

  • Event dispatching.
  • Command parsing.
  • Permission checks.
  • State persistence.
  • Rate limit handling.

By the end: a small bot framework you could ship.

Reference: discord.py source, Bolt SDK docs, Telegram Bot API.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…