Skip to main content
Use telegram.config(...) with a Telegram bot token.

Config

telegram.config({
  botToken: "your-bot-token",
});
OptionDescriptionEnv fallback
botTokenBot token from @BotFather.SPECTRUM_TELEGRAM_BOT_TOKEN
webhookSecretOptional secret token for verifying webhook payloads.SPECTRUM_TELEGRAM_WEBHOOK_SECRET
baseUrlOptional Bot API base URL. Defaults to https://api.telegram.org.SPECTRUM_TELEGRAM_BASE_URL

Example

import { Spectrum } from "spectrum-ts";
import { telegram } from "spectrum-ts/providers/telegram";

const app = await Spectrum({
  projectId: process.env.PROJECT_ID!,
  projectSecret: process.env.PROJECT_SECRET!,
  providers: [
    telegram.config({
      botToken: process.env.TELEGRAM_BOT_TOKEN!,
    }),
  ],
});

for await (const [space, message] of app.messages) {
  if (message.content.type === "text") {
    await space.send(`Echo: ${message.content.text}`);
  }
}

Webhook registration

In cloud mode, when projectId and projectSecret are provided, the Telegram provider automatically registers its Fusor webhook on startup. In local or direct mode, configure the webhook yourself through the Telegram Bot API.