telegram-bot-builder
FreeNo executable scriptsNot checkedBuilds Telegram bots using the Bot API (grammy/telegraf/python-telegram-bot). Use when the user wants to create a Telegram bot, handle commands, build inline…
by TerminalSkills★ 221 GitHub starsAbout this skill
Telegram Bot Builder
Overview
Builds production-ready Telegram bots covering the full Bot API surface: commands, inline keyboards, callback queries, conversations with state machines, media handling, group management, payments, and Mini Apps. Supports both long polling (development) and webhooks (production).
Instructions
1. Bot Creation
- Message @BotFather on Telegram
- Send
/newbot, choose name and username - Save the bot token (format:
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11) - Configure with
/setcommands,/setdescription,/setabouttext
2. Project Scaffolding
Recommended frameworks by language:
Node.js — grammY (recommended):
npm init -y && npm install grammy @grammyjs/conversations
Node 20.6+ loads env files natively: node --env-file=.env bot.js (no dotenv needed).
Node.js — Telegraf (4.16.3 is its latest release; it lags behind newer Bot API features, so prefer grammY for new bots):
npm install telegraf
Python — python-telegram-bot:
pip install python-telegram-bot # v22, async API, Python 3.10+
# bot.py
import os
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("Welcome!")
app = Application.builder().token(os.environ["BOT_TOKEN"]).build()
app.add_handler(CommandHandler("start", start))
app.run_polling()
Standard project structure:
telegram-bot/
├── bot.js # Entry point, bot initialization
├── handlers/
│ ├── commands.js # /start, /help, custom commands
│ ├── callbacks.js # Inline keyboard callback handlers
│ ├── conversations.js # Multi-step conversation flows
│ └── middleware.js # Auth, logging, rate limiting
├── keyboards/ # Inline and reply keyboard builders
├── services/ # Business logic
├── .env # BOT_TOKEN, WEBHOOK_URL, WEBHOOK_SECRET, ADMIN_ID (gitignored)
└── package.json
3. Core Patterns (grammY)
Bot setup (ESM, "type": "module" in package.json):
import { Bot, InlineKeyboard, InputFile, session, webhookCallback } from 'grammy';
import { conversations, createConversation } from '@grammyjs/conversations';
const bot = new Bot(process.env.BOT_TOKEN);
bot.catch((err) => console.error('Update failed:', err.error));
Basic command handler:
bot.command('start', async (ctx) => {
await ctx.reply('Welcome!', {
reply_markup: {
inline_keyboard: [[
{ text: '📊 Dashboard', callback_data: 'dashboard' },
{ text: '⚙️ Settings', callback_data: 'settings' }
]]
}
});
});
Callback query handler:
bot.callbackQuery('dashboard', async (ctx) => {
await ctx.answerCallbackQuery();
await ctx.editMessageText('Here is your dashboard...', {
reply_markup: backButton
});
});
Conversation (conversations plugin v2; no session needed):
async function onboarding(conversation, ctx) {
await ctx.reply('What is your name?');
const name = await conversation.waitFor('message:text');
await ctx.reply('What is your email?');
const email = await conversation.waitFor('message:text');
await ctx.reply(`Thanks ${name.message.text}! Registered with ${email.message.text}`);
}
bot.use(conversations());
bot.use(createConversation(onboarding, 'onboarding')); // function first, name second
bot.command('register', (ctx) => ctx.conversation.enter('onboarding'));
Register conversations() after any session() middleware and before the conversation. Code in a conversation is replayed, so wrap side effects (database writes, API calls) in conversation.external(...).
Middleware for auth:
function adminOnly(ctx, next) {
if (ctx.from?.id !== Number(process.env.ADMIN_ID)) {
return ctx.reply('⛔ Not authorized');
}
return next();
}
bot.command('admin', adminOnly, handleAdmin); // grammY: bot.command(name, ...middleware)
4. Keyboard Types
Inline Keyboard (attached to message):
- Callback buttons (
callback_data) — triggers callbackQuery handler - URL buttons (
url) — opens a link - Web App buttons (
web_app) — opens a Mini App - Switch Inline buttons (
switch_inline_query) — triggers inline mode
Reply Keyboard (replaces phone keyboard):
- Custom keyboard with predefined responses
one_time_keyboard: trueto auto-hide after selectionresize_keyboard: truefor compact display
Remove Keyboard:
{ reply_markup: { remove_keyboard: true } }
5. Polling vs Webhooks
Long Polling (development):
bot.start(); // Calls getUpdates in a loop
- No public URL needed
- Slightly higher latency
- Good for development and low-traffic bots
Webhooks (production):
import express from 'express';
const app = express();
app.use(express.json());
// A s
Install telegram-bot-builder in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the telegram-bot-builder skill do?
Builds Telegram bots using the Bot API (grammy/telegraf/python-telegram-bot). Use when the user wants to create a Telegram bot, handle commands, build inline keyboards, process callbacks, send media, build conversational flows, handle payments (Telegram Stars), or create Mini Apps. Trigger words: telegram bot, telegram integration, telegram commands, inline keyboard, telegram webhook, telegram polling, telegram mini app, telegram payments, BotFather, grammy, telegraf.
How do I install the telegram-bot-builder skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the telegram-bot-builder skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic