Command Palette

Search for a command to run...

sasha-bot package icon
vivaneiona/sasha-bot
Public
wasmer run vivaneiona/sasha-bot

Business Bot

A minimal Telegram Business webhook bot: every regular or business message gets the same reply, Hi!.

The stack is intentionally small: FastAPI receives the webhook, python-telegram-bot parses the update, and Wasmer Edge runs the app as a WebAssembly package.

Mental Model

Wasm, or WebAssembly, is a compact portable binary format. It is useful for running apps in an isolated environment: fast, predictable, and without a full virtual machine.

Wasmer is a Wasm runtime and deployment platform. In this project, Wasmer Edge takes the Python/FastAPI app, packages its dependencies, and publishes it behind a public HTTPS URL.

First Run

cp .env.example .env

Fill BOT_TOKEN, GROQ_API_KEY, and PG_ADDR in .env, then run:

wasmer login
just install
just db-init
just run

Local health check:

curl http://127.0.0.1:8000/

First Deploy

just setup

This stores the token in Wasmer secrets, registers the Telegram webhook, and applies Postgres migrations before deploying the production version.

Regular Update

After changing the code:

just deploy

just deploy also reapplies DB migrations before packaging the app.

For a preview deploy without switching production traffic:

just deploy-preview

Useful Commands

just bump-version  # bump MAJOR.YYYYMMDD.PATCH and sync generated files
just db-init   # apply SQL migrations to Postgres
just db-cleanup  # prune expired or old approval rows
just format   # format Python code with Ruff
just lint     # lint Python code with Ruff
just health   # check the live URL
just webhook  # register the Telegram webhook again
just logs     # show recent Wasmer Edge logs
just clean    # remove local build files

Files

src/main.py is the ASGI entrypoint for Uvicorn and Wasmer.

src/bot.py contains the FastAPI app, health endpoint, and webhook endpoint.

src/handler.py is the thin Telegram adapter: it turns updates into webhook JSON responses.

src/flow.py contains the Pydantic AI assistant flow, including deferred tool approval and continuation after confirm/cancel.

src/postgres.py is the small Wasm-friendly Postgres wrapper built on short-lived pg8000 connections.

src/db.py applies SQL migrations and persists deferred approval state in Postgres.

wasmer.toml is the package manifest: Python runtime, mounted files, and the command that runs on Wasmer Edge.

The version lives in pyproject.toml. Use just bump-version for a normal release bump, or just sync-version to sync wasmer.toml and src/version.py after a manual edit.

Versioning Scheme

MAJOR.YYYYMMDD.PATCH from https://github.com/veiloq/scalver

Telegram business webhook bot for Wasmer Edge on FastAPI

More packages
Telegram Kimi K2.5 Bot on Wasmer Edge
A Wasm module for the Signal Bot
Frasbach
AI-powered Telegram channel aggregator with inline keyboard controls