Echotron examples

March 6, 2026 · View on GitHub

Each subdirectory is a self-contained Go module that can be cloned as a project skeleton with gonew:

gonew github.com/NicoNex/echotron/v3/example/<name> <your-module-path>

For example:

gonew github.com/NicoNex/echotron/v3/example/polling github.com/you/mybot

Examples

NameWhat it shows
polling-simpleStateless bot driven by a plain PollingUpdates channel; no Dispatcher. Shortest possible starting point.
pollingPer-chat stateful bot using Dispatcher with long-polling. One struct instance per conversation.
polling-keyboardInline keyboards attached to messages and callback query handling.
polling-inlineInline mode: the bot responds to @botname <query> from any chat.
polling-ratelimitConfiguring the built-in dual-level rate limiter (global and per-chat).
polling-fsmFinite state machine pattern via a self-referential stateFn type. Multi-step conversations without external libraries.
polling-fsm-lifecycleFSM extended with session self-destruction: inactive bot instances remove themselves from the Dispatcher after a configurable idle timeout.
polling-fsm-persistenceFSM extended with disk persistence using katalis. Per-chat data survives process restarts.
webhookDispatcher with webhook delivery instead of long-polling.
webhook-simpleStateless bot driven by a plain WebhookUpdates channel; no Dispatcher.

Suggested reading order

  1. polling-simple — understand the raw update channel
  2. polling — add per-chat state with the Dispatcher
  3. polling-keyboard — interactive keyboards and callbacks
  4. polling-inline — inline mode and PollOptions
  5. polling-ratelimit — rate limiter configuration
  6. polling-fsm — state machines for multi-step conversations
  7. polling-fsm-lifecycle — memory management with session self-destruction
  8. polling-fsm-persistence — durable state across restarts
  9. webhook / webhook-simple — webhook delivery

Prerequisites

  • Go 1.21 or later
  • gonew: go install golang.org/x/tools/cmd/gonew@latest
  • A bot token from @BotFather, exported as TELEGRAM_TOKEN