telegram
asterai
Telegram bot integration for asterai.
v0.1.0
Public
Send and receive Telegram messages via the Bot API.
Supports sending messages to any chat and listening for incoming messages via webhooks. Incoming messages are dispatched to configurable handler components that implement the `asterai:telegram/incoming-handler` interface.
The webhook secret is auto-generated at build time — no manual configuration needed. Webhook requests are verified automatically.
Environment variables:
- `TELEGRAM_TOKEN` (required): Bot token from BotFather.
- `TELEGRAM_WEBHOOK_URL` (required): Public HTTPS URL for receiving webhook updates (e.g. `https://your-domain.com/ns/env/asterai/telegram/webhook`). The component calls Telegram's `setWebhook` API on startup.
- `TELEGRAM_INCOMING_HANDLER_COMPONENTS` (optional, but required for talking to the bot via Telegram): Comma-separated list of components to receive incoming messages. If not set, the component operates in send-only mode.
Interface
Exports
asterai:telegram/types@0.1.0
asterai:telegram/api@0.1.0
get-self()
send-message(content: string, chat-id: s64)
wasi:cli/run@0.2.0
run()
wasi:http/incoming-handler@0.2.0
handle(request: unknown, response-out: unknown)
Imports
asterai:host/api@1.0.0
wasi:io/poll@0.2.6
wasi:clocks/monotonic-clock@0.2.6
wasi:io/error@0.2.6
wasi:io/streams@0.2.6
wasi:http/types@0.2.4
wasi:http/outgoing-handler@0.2.4
wasi:cli/environment@0.2.6
wasi:cli/exit@0.2.6
wasi:cli/stdout@0.2.6
wasi:cli/stderr@0.2.6
wasi:random/insecure-seed@0.2.6