Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.
Add this skill
npx mdskills install sickn33/telegram-bot-builderComprehensive guide with practical patterns, monetization strategies, and solid anti-patterns coverage
1---2name: telegram-bot-builder3description: "Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot."4source: vibeship-spawner-skills (Apache 2.0)5---67# Telegram Bot Builder89**Role**: Telegram Bot Architect1011You build bots that people actually use daily. You understand that bots12should feel like helpful assistants, not clunky interfaces. You know13the Telegram ecosystem deeply - what's possible, what's popular, and14what makes money. You design conversations that feel natural.1516## Capabilities1718- Telegram Bot API19- Bot architecture20- Command design21- Inline keyboards22- Bot monetization23- User onboarding24- Bot analytics25- Webhook management2627## Patterns2829### Bot Architecture3031Structure for maintainable Telegram bots3233**When to use**: When starting a new bot project3435```python36## Bot Architecture3738### Stack Options39| Language | Library | Best For |40|----------|---------|----------|41| Node.js | telegraf | Most projects |42| Node.js | grammY | TypeScript, modern |43| Python | python-telegram-bot | Quick prototypes |44| Python | aiogram | Async, scalable |4546### Basic Telegraf Setup47```javascript48import { Telegraf } from 'telegraf';4950const bot = new Telegraf(process.env.BOT_TOKEN);5152// Command handlers53bot.start((ctx) => ctx.reply('Welcome!'));54bot.help((ctx) => ctx.reply('How can I help?'));5556// Text handler57bot.on('text', (ctx) => {58 ctx.reply(`You said: ${ctx.message.text}`);59});6061// Launch62bot.launch();6364// Graceful shutdown65process.once('SIGINT', () => bot.stop('SIGINT'));66process.once('SIGTERM', () => bot.stop('SIGTERM'));67```6869### Project Structure70```71telegram-bot/72├── src/73│ ├── bot.js # Bot initialization74│ ├── commands/ # Command handlers75│ │ ├── start.js76│ │ ├── help.js77│ │ └── settings.js78│ ├── handlers/ # Message handlers79│ ├── keyboards/ # Inline keyboards80│ ├── middleware/ # Auth, logging81│ └── services/ # Business logic82├── .env83└── package.json84```85```8687### Inline Keyboards8889Interactive button interfaces9091**When to use**: When building interactive bot flows9293```python94## Inline Keyboards9596### Basic Keyboard97```javascript98import { Markup } from 'telegraf';99100bot.command('menu', (ctx) => {101 ctx.reply('Choose an option:', Markup.inlineKeyboard([102 [Markup.button.callback('Option 1', 'opt_1')],103 [Markup.button.callback('Option 2', 'opt_2')],104 [105 Markup.button.callback('Yes', 'yes'),106 Markup.button.callback('No', 'no'),107 ],108 ]));109});110111// Handle button clicks112bot.action('opt_1', (ctx) => {113 ctx.answerCbQuery('You chose Option 1');114 ctx.editMessageText('You selected Option 1');115});116```117118### Keyboard Patterns119| Pattern | Use Case |120|---------|----------|121| Single column | Simple menus |122| Multi column | Yes/No, pagination |123| Grid | Category selection |124| URL buttons | Links, payments |125126### Pagination127```javascript128function getPaginatedKeyboard(items, page, perPage = 5) {129 const start = page * perPage;130 const pageItems = items.slice(start, start + perPage);131132 const buttons = pageItems.map(item =>133 [Markup.button.callback(item.name, `item_${item.id}`)]134 );135136 const nav = [];137 if (page > 0) nav.push(Markup.button.callback('◀️', `page_${page-1}`));138 if (start + perPage < items.length) nav.push(Markup.button.callback('▶️', `page_${page+1}`));139140 return Markup.inlineKeyboard([...buttons, nav]);141}142```143```144145### Bot Monetization146147Making money from Telegram bots148149**When to use**: When planning bot revenue150151```javascript152## Bot Monetization153154### Revenue Models155| Model | Example | Complexity |156|-------|---------|------------|157| Freemium | Free basic, paid premium | Medium |158| Subscription | Monthly access | Medium |159| Per-use | Pay per action | Low |160| Ads | Sponsored messages | Low |161| Affiliate | Product recommendations | Low |162163### Telegram Payments164```javascript165// Create invoice166bot.command('buy', (ctx) => {167 ctx.replyWithInvoice({168 title: 'Premium Access',169 description: 'Unlock all features',170 payload: 'premium_monthly',171 provider_token: process.env.PAYMENT_TOKEN,172 currency: 'USD',173 prices: [{ label: 'Premium', amount: 999 }], // $9.99174 });175});176177// Handle successful payment178bot.on('successful_payment', (ctx) => {179 const payment = ctx.message.successful_payment;180 // Activate premium for user181 await activatePremium(ctx.from.id);182 ctx.reply('🎉 Premium activated!');183});184```185186### Freemium Strategy187```188Free tier:189- 10 uses per day190- Basic features191- Ads shown192193Premium ($5/month):194- Unlimited uses195- Advanced features196- No ads197- Priority support198```199200### Usage Limits201```javascript202async function checkUsage(userId) {203 const usage = await getUsage(userId);204 const isPremium = await checkPremium(userId);205206 if (!isPremium && usage >= 10) {207 return { allowed: false, message: 'Daily limit reached. Upgrade?' };208 }209 return { allowed: true };210}211```212```213214## Anti-Patterns215216### ❌ Blocking Operations217218**Why bad**: Telegram has timeout limits.219Users think bot is dead.220Poor experience.221Requests pile up.222223**Instead**: Acknowledge immediately.224Process in background.225Send update when done.226Use typing indicator.227228### ❌ No Error Handling229230**Why bad**: Users get no response.231Bot appears broken.232Debugging nightmare.233Lost trust.234235**Instead**: Global error handler.236Graceful error messages.237Log errors for debugging.238Rate limiting.239240### ❌ Spammy Bot241242**Why bad**: Users block the bot.243Telegram may ban.244Annoying experience.245Low retention.246247**Instead**: Respect user attention.248Consolidate messages.249Allow notification control.250Quality over quantity.251252## Related Skills253254Works well with: `telegram-mini-app`, `backend`, `ai-wrapper-product`, `workflow-automation`255
Full transparency — inspect the skill content before installing.