@opentag/telegram
v0.2.0
Published
Telegram message normalization and callback helpers for OpenTag.
Readme
@opentag/telegram
Telegram message normalization and callback helpers for OpenTag.
Use this package to normalize Telegram bot messages into OpenTagEvent objects
and to encode or parse Telegram callback thread keys.
Install
pnpm add @opentag/telegramExports
normalizeTelegramMessage: converts a Telegram message into anOpenTagEvent.encodeTelegramThreadKey: encodes bot, chat, and message coordinates for callback routing.parseTelegramThreadKey: decodes a Telegram callback thread key.renderTelegramAcknowledgement: renders the Telegram acknowledgement body.renderTelegramFinalResult: renders the Telegram final result body.createTelegramSendMessagePayload: creates a Telegram Bot APIsendMessagepayload.
Example
import { normalizeTelegramMessage } from "@opentag/telegram";
const event = normalizeTelegramMessage({
botId: "bot_123",
botUsername: "opentag_bot",
chatId: "456",
chatType: "private",
userId: "789",
username: "alice",
text: "investigate this deploy failure",
messageId: 101,
updateId: 202,
binding: {
botId: "bot_123",
chatId: "456",
repoProvider: "github",
owner: "acme",
repo: "demo"
}
});
if (event) {
// Send the event to @opentag/client or your own OpenTag-compatible control plane.
}Stability
Telegram thread key format is public because callback sinks depend on it. Change it only with a migration path.
