Teact
Packages

@teactjs/telegram

TelegramAdapter (grammY driver) plus conversation and streaming plugins, serializeOutput, and defineConversation.

The production transport for Teact. TelegramAdapter bridges the core reconciler to the Telegram Bot API via grammY and supports both polling and webhook (edge) modes. The package also ships the imperative conversation and streaming plugins.

bun add @teactjs/telegram

Exports

ExportKindDescription
TelegramAdapterclassAdapter passed to createBot({ adapter }).
serializeOutputfunctionSerialize a rendered output tree to a Telegram send payload.
conversationsPluginpluginEnables imperative async/await conversation flows.
defineConversationfunctionDeclare a named conversation handler.
streamPluginpluginEnables token streaming into a message (useStream).
TelegramAdapterConfig, TelegramSendPayloadtypesAdapter options and payload shape.
Conversation, ConversationHandler, ConversationDef, ConversationsPluginOptions, ConversationsConfig, MediaGroupItemtypesConversation typings.

Polling (default)

new TelegramAdapter() reads the bot token from the environment (via createBot). Guard the polling call so it does not run when the module is imported (e.g. on edge):

import { createBot } from "@teactjs/core";
import { TelegramAdapter } from "@teactjs/telegram";

const bot = createBot({
  component: App,
  adapter: new TelegramAdapter(),
});

if (import.meta.main) bot.start();

Webhook / edge

On serverless runtimes, call bot.fetch(request, { token, secretToken }) from your handler instead of start(). The isolate freezes once the Response resolves, so pass plugins directly to createBot({ plugins }) (the config file is not loaded on edge) and provide a durable SessionStore.

Conversations

import { conversationsPlugin, defineConversation } from "@teactjs/telegram";

const onboarding = defineConversation("onboarding", async (convo) => {
  const name = await convo.prompt("What's your name?");
  await convo.send(`Welcome, ${name}!`);
});

// createBot({ plugins: [conversationsPlugin()] })

Streaming

import { streamPlugin } from "@teactjs/telegram";
// createBot({ plugins: [streamPlugin()] }) — then useStream() in a component

See the Telegram adapter guide for polling vs webhook setup, the Conversations guide, and the Streaming guide.

On this page