Skip to content

EN Quick Start

Andrewkydev edited this page Aug 26, 2026 · 3 revisions

Quick Start

Русский: RU-Quick-Start

Requirements

  • Go 1.26.4 or newer for AstraEngine v2.0.3;
  • a Telegram, VK, or Discord token;
  • for VK, a positive community ID.
mkdir hello-astra
cd hello-astra
go mod init hello-astra
go get github.com/andrewkydev/astraengine/v2@latest

Create main.go:

package main

import (
	"context"
	"os"
	"os/signal"
	"syscall"

	astraengine "github.com/andrewkydev/astraengine/v2"
	botctx "github.com/andrewkydev/astraengine/v2/core/context"
	"github.com/andrewkydev/astraengine/v2/platform/telegram"
)

func main() {
	ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
	defer stop()

	app := astraengine.New("hello-astra")
	app.Platform(telegram.New(telegram.Config{Token: os.Getenv("TELEGRAM_TOKEN")}))
	app.Command("start", func(ctx *botctx.Context) error {
		return ctx.SendText("Hello from AstraEngine")
	})

	if err := app.Start(ctx); err != nil && err != context.Canceled {
		panic(err)
	}
}

Run it:

$env:TELEGRAM_TOKEN = "your-token"
go run .

Send /start to the bot. App.Start runs until the context is canceled and shuts the runtime down cleanly when you press Ctrl+C.

Never store tokens in Git. Next steps: EN-Routing-and-Middleware, EN-Localization, EN-Configuration, EN-Platform-Adapters.

Clone this wiki locally