Ultra Telegram Framework (UTF) is a modern, lightweight, and strongly typed Telegram Bot API framework built for TypeScript.
Designed with flexibility in mind, UTF features a unique adapter-based architecture that allows your bot to run seamlessly across various environments — from classic Node.js servers to Serverless Edge functions and Google Apps Script — without rewriting your core logic.
ctx.replyWithDraft()) with auto-debouncing for LLM integrations.ctx.channel, ctx.group, ctx.game) provide context-aware, lazy-loaded API shortcuts for channels, groups, and games.utf-build CLI tool. No manual webhook boilerplate needed.npm install ultra-telegram-framework
Here is a basic example using the Node.js adapter with long polling. The syntax is designed to be instantly familiar if you have used other popular frameworks.
import { TelegramBot, NodeApiClient } from 'ultra-telegram-framework';
const token = process.env.BOT_TOKEN;
if (!token) throw new Error('BOT_TOKEN is missing!');
// 1. Initialize with the Node adapter
const bot = new TelegramBot(new NodeApiClient(token));
// 2. Setup handlers
bot.command('start', async (ctx) => {
await ctx.reply('Hello! I am an Ultra Telegram Framework bot 🚀');
});
bot.on('text', async (ctx) => {
// 100% type-safe: ctx.text is guaranteed to exist here
await ctx.reply(`You said: ${ctx.text}`);
});
// 3. StartPolling
bot.startPolling().then(() => console.log('🚀 Bot is running...'));
To keep your code clean and autocompletion sharp, UTF groups channel, group, and game operations into dedicated sub-contexts. They are lazy-loaded and automatically resolve the current chatId, messageId, and threadId from the update context:
bot.on('message', async (ctx) => {
// 1. Channel Operations (automatically uses the active channel chat_id)
await ctx.channel.postMessage('Hello channel subscribers!');
// 2. Group Operations (automatically resolves group chat_id)
await ctx.group.ban(12345678); // Ban a user
await ctx.group.pin(); // Pins the current message
// 3. Game Operations (resolves chat_id, message_id, or inline_message_id)
await ctx.game.setScore(12345678, 100);
});
### Example 2: Google Apps Script
Write your bot logic once and deploy to GAS without any boilerplate.
```typescript
import { TelegramBot, GasApiClient } from 'ultra-telegram-framework';
// GasApiClient automatically finds your BOT_TOKEN in Script Properties!
const bot = new TelegramBot(new GasApiClient());
bot.command('start', (ctx) => ctx.reply('Hello from GAS! ☁️'));
Build and deploy with one command:
npx utf-build src/index.ts
clasp push
👉 Read the Full Documentation in our Wiki
To keep this README clean, all detailed guides, tutorials, and advanced concepts are documented in our GitHub Wiki. There you will find:
This project is licensed under the MIT License — see the LICENSE file for details.
If this framework helped you save time, bypass GAS limitations, or build something awesome, consider supporting its development!