Tutorials

Step-by-step tutorials

Follow along from an empty folder to a bot running 24/7. Each tutorial links a downloadable starter template.

Telegram

Telegram bot in 10 minutes with grammY

From BotFather to a working bot with commands, echo replies and error handling, using grammY and Node.js.

Discord

Discord bot with discord.js

Create the application, invite the bot, register slash commands and answer them, without privileged intents.

Railway

Deploy a bot to Railway

Push a bot to GitHub, deploy it on Railway with variables, read the logs, switch to webhooks and keep costs under control.

VPS

Bot on a Vultr VPS with systemd

Create a small VPS, harden SSH and the firewall, install Node.js, and run the bot as a restricted systemd service with logs and auto-restart.

Telegram

Telegram webhook + Caddy

Point a domain at a small Node or Python webhook and let Caddy obtain certificates.

Discord

Register guild slash commands

Use guild command registration while developing, then promote to global.

DevOps

/healthz + uptime ping

Expose a liveness route and point any uptime checker at it.

Slack

Slack Bolt locally

Develop slash commands without exposing a public URL.

Telegram

Node http Telegram webhook

Secret token check, fast 200 and async sendMessage.

Telegram

Telegraf first bot

Install, long poll, /start and clean shutdown.

Discord

Least-privilege Discord invite

Build the URL with the permissions calculator.

Security

Debug HMAC mismatch

Raw body, encoding and constant-time compare.

DevOps

systemd bot service

Unit file, env file, restart and logs.

DevOps

Healthz + monitor

Liveness route and alerts you will actually see.

DevOps

.env.example in CI

Fail builds when required keys are missing from the example.

Reliability

Webhook fixtures in CI

Replay anonymized payloads without live tokens.

Telegram

Rotate Telegram secret_token

Dual-support briefly, setWebhook, then drop the old secret.

Discord

Ephemeral admin command

Guild install, permission check and ephemeral reply.

Slack

Socket Mode to HTTP

Expose a signed Request URL and turn Socket Mode off.

Data

Litestream for SQLite bots

Continuous backup without giving up single-node SQLite.

Telegram

grammY webhook secret

Reject requests that omit or mismatch the secret header.

Architecture

Queued broadcast

ACK the admin command, enqueue recipients, rate-limit sends.

DevOps

/readyz with dependencies

Liveness stays dumb; readiness fails when DB or queue is down.

Reliability

Anonymize fixtures

Replace tokens and PII while keeping signature-valid structure.

Hosting

Caddy TLS for webhooks

Automatic HTTPS reverse proxy to your local bot port.

Telegram

Register Telegram commands after deploy

Call setMyCommands for default and group scopes.

Telegram

Ship a one-shot inline button flow

Version callback_data and answerCallbackQuery.

Discord

Register guild slash commands

Guild registration for fast iteration.

Discord

ACK a Discord button interaction

Respond within about 3s or defer.

Slack

ACK Slack slash via response_url

Return 200 quickly then use response_url.

WhatsApp

Send an approved WhatsApp template

Cloud API template send outside the 24h window.

Security

Verify Slack signatures in Express

Raw body plus timing-safe compare.

Security

Short-lived JWTs for bot dashboards

Sign admin sessions with short TTL.

DevOps

Multi-stage Docker build for a Node bot

Non-root final image with HEALTHCHECK.

DevOps

Kubernetes Deployment for a bot

Probes, resources and Secret refs.

Data

Transactional outbox worker

Same-txn intents; async publish.

Reliability

Per-chat Redis token bucket

Key by platform, chat and action.

AI

OpenAI-compatible chat client wrapper

Base URL, model and timeouts from env.

AI

RAG document ingest pipeline

Chunk, embed, store with tenant ACL.

Matrix

matrix-nio echo in unencrypted room

Login, sync and reply.

Hosting

Caddyfile for bot webhooks

Automatic HTTPS reverse_proxy.

Hosting

Nginx TLS proxy for webhooks

Terminate TLS and proxy_pass to the bot.

DevOps

GitHub Actions CI for bots

Lint, tests and bad-signature fixture.

DevOps

Error tracker setup for bots

Init SDK, scrub PII, tag handlers.

Architecture

BullMQ jobs after webhook ACK

Enqueue slow work with concurrency caps.

Telegram

Filter grammY commands by chat type

Chat-type filters for menus.

Telegram

aiogram FSM conversation sketch

External state; expire abandoned flows.

Discord

Handle Discord modal submit

ACK submit and validate lengths.

Discord

Implement slash autocomplete

Filtered choices under the deadline.

Slack

Publish Slack App Home view

views.publish on app_home_opened.

Slack

Handle block_actions button

ACK then response_url update.

WhatsApp

WhatsApp webhook verify challenge

Echo hub.challenge on token match.

WhatsApp

Validate X-Hub-Signature-256

HMAC-SHA256 raw body with app secret.

AI

Allowlist tools for LLM agents

Named tools plus JSON Schema args.

AI

Prompt evals in CI

Golden prompts must not regress.

Data

Consistent SQLite backup script

Use backup API; encrypt the artifact.

Data

Expand-contract column add

Nullable first; backfill; tighten later.

DevOps

OTel span around webhook ACK

Start at entry; end after ACK.

DevOps

ACK latency Prometheus histogram

Observe verify plus ACK duration.

Security

Rotate Discord bot token safely

Deploy new; revoke old; audit.

Hosting

SSH tunnel for staging webhooks

Forward carefully; prefer staging DNS.

Data

Restore Litestream SQLite replica

Fresh dir; verify; then cutover.

Architecture

Launch command behind a flag

Default off; pilot; remove flag.

Privacy

Ship /privacy and /export stubs

Short privacy text; authenticated export.

Reliability

Expose JSON status document

Separate host from bot when possible.

Telegram

Graceful Telegraf SIGTERM stop

Stop polling; close; exit 0.

Slack

Switch Bolt to HTTP mode

Signing secret and Request URL; disable Socket.

Discord

Ephemeral follow-up after defer

Defer then ephemeral followUp.

DevOps

Add /healthz to Node http server

GET /healthz returns 200 JSON.

DevOps

Keep .env.example synced

CI checks example vs required keys.

Architecture

Webhook idempotency middleware

Short-circuit duplicate event ids.

Reliability

Admin DLQ single-message replay

Authz plus replay one redacted job.

Security

CSP on bot admin dashboard

Lock script-src; avoid inline JS.

Security

Encrypt DB dumps with age or GPG

Encrypt before upload; keys off-host.

Matrix

Handle leave or ban in Matrix sync

Stop room work on leave events.

Want the theory behind them? See the guides. Ready-made code lives in templates.